Closed jhonabreul closed 9 months ago
Under Writing Algorithm > Reality Models:
Interest Rate
Key Concepts
Introduction It is used in Algorithm Statistics. E.g. Sharpe and Sortino ratios https://www.quantconnect.com/docs/v2/writing-algorithms/statistics/algorithm-statistics It is used in QCAlgorithm helpers for Sharpe and Sortino ratios
Set Models
Default Behavior (It is the InterestRateProvider: primary credit rate from the Federal Open Market Committee (FOMC))
Model Structure
Disable Interest Rate (self.SetRiskFreeInterestRateModel(ConstantRiskFreeRateInterestRateModel(0)))
Examples:
self.interest_rate = self.RiskFreeInterestRateModel.GetInterestRate(self.Time)
risk_free_rate = self.RiskFreeInterestRateModel.GetRiskFreeRate(self.Time - timedelta(365), self.Time)
Supported Models
Introduction
ConstantRiskFreeRateInterestRateModel
FuncRiskFreeRateInterestRateModel (it doesn't have a Python overload for now)
var interestRateModel= new FuncRiskFreeRateInterestRateModel((datetime) => Func(datetime));
InterestRateProvider
On Writing Algorithms > Statistics. In the Introduction, refer that some metrics depend on the Interest Rate, and link to the new reality model page
On Differences From Third-Party Indicators, add an H4 for Interest Rate and list Sharpe and Sortino as dependent of our modeling if we don't provide a value.
We must fix the Indicator script to add this information to SR and SORTINO.
Expected Behavior
A risk-free interest rate model can now be set to the algorithm for it's usage in indicators, statistics and potentially other calculations: https://github.com/QuantConnect/Lean/pull/7594
RiskFreeInterestRateModel
interface and implementing classes:InterestRateProvider
.ConstantRiskFreeInterestRateModel
.FuncRiskFreeInterestRateModel
.QCAlgorithm.RiskFreeInterestRateModel
property andQCAlgorithm.SetRiskFreeInterestRateModel
setterActual Behavior
N/A
Checklist
master
branch