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:

ArgumentData TypeDescriptionDefault Value
riskFreeRaterisk_free_ratedecimalfloatThe 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:

ArgumentData TypeDescriptionDefault Value
getInterestRateFuncFunc<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.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: