book
Checkout our new book! Hands on AI Trading with Python, QuantConnect, and AWS Learn More arrow

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.

Select Language:
self.set_risk_free_interest_rate_model(ConstantRiskFreeRateInterestRateModel(0.02))

The following table describes the arguments the model accepts:

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

Select Language:
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
get_interest_rate_funcCallable[[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).

Select Language:
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: