QuantConnect / Lean

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
https://lean.io
Apache License 2.0
9.05k stars 3.15k forks source link

Create default IMarginInterestRateModel #6981

Open Martin-Molinero opened 1 year ago

Martin-Molinero commented 1 year ago

Expected Behavior

lucasbrynte commented 1 year ago

Nice!

I take it this would be some crude generic margin fee model, to replace the null model for the brokerages / security types that do not have a specific model.

Martin-Molinero commented 1 year ago

Hey @lucasbrynte!

I take it this would be some crude generic margin fee model, to replace the null model for the brokerages / security types that do not have a specific model.

Thank you! Exactly 💯, if AccountType is AccountType.Margin

Is it also on the roadmap at the moment to implement realistic margin fee models for other brokerages than Binance, e.g. Bitfinex?

Not at the moment but we do accept contributions 👍

May I also ask how LEAN manages historical margin interest data in practice? E.g. in the case of Binance futures, can the historical margin interests be downloaded from QuantConnect via lean-CLI, to be stored in a CSV file or similar?

Can see details on the implementation of binance futures at https://github.com/QuantConnect/Lean/pull/6807, it's file driven generated by https://github.com/QuantConnect/Lean.DataSource.BinanceFundingRate. We have now added support for downloading it with the lean-CLI 👍

Regarding the DefaultMarginInterestRateModel I think applying a fix rate cost (which can be an argument) would be enough given it would be generic, defaulting to a low reasonable value

Martin-Molinero commented 1 year ago

Regarding the DefaultMarginInterestRateModel I think applying a fix rate cost (which can be an argument) would be enough given it would be generic, defaulting to a low reasonable value

After chatting with @jaredbroad we agreed on DefaultMarginInterestRateModel reusing InterestRateProvider internally to calculated the interest rate model based on the us treasury rate + 1%