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.
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 |
---|---|---|---|
risk_free_rate | 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.
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 |
---|---|---|---|
get_interest_rate_func | 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).
self.set_risk_free_interest_rate_model(InterestRateProvider())
To view the implementation of this model, see the LEAN GitHub repository.