Risk Free Interest Rate
Supported Models
Introduction
This page describes all of the pre-built risk free interest rate models in LEAN. If none of these models perform exactly how you want, create a custom risk free interest rate model.
Constant Model
The ConstantRiskFreeRateInterestRateModel
returns a constant rate across time. It's the default risk free interest rate model.
SetRiskFreeInterestRateModel(new ConstantRiskFreeRateInterestRateModel(0.02m));
self.set_risk_free_interest_rate_model(ConstantRiskFreeRateInterestRateModel(0.02))
The following table describes the arguments the model accepts:
Argument | Data Type | Description | Default Value |
---|---|---|---|
riskFreeRate risk_free_rate | decimal float | The risk free interest rate |
To view the implementation of this model, see the LEAN GitHub repository.
Function Model
The FuncRiskFreeRateInterestRateModel
calls a function you provide to get the risk free interest rate. The function you pass to the constructor effectively replaces the GetInterestRate method.
SetRiskFreeInterestRateModel(new FuncRiskFreeRateInterestRateModel(getInterestRateFunc));
self.set_risk_free_interest_rate_model(FuncRiskFreeRateInterestRateModel(self.get_interest_rate_func))
The following table describes the arguments the model accepts:
Argument | Data Type | Description | Default Value |
---|---|---|---|
getInterestRateFunc get_interest_rate_func | Func<DateTime, decimal> Callable[[datetime], float] | A function that returns the risk free interest rate for a given date |
To view the implementation of this model, see the LEAN GitHub repository.
Interest Rate Provider Model
The InterestRateProvider
returns the primary credit rate from the Federal Open Market Committee (FOMC).
SetRiskFreeInterestRateModel(new InterestRateProvider());
self.set_risk_free_interest_rate_model(InterestRateProvider())
To view the implementation of this model, see the LEAN GitHub repository.