Margin Interest Rate

Supported Models

Introduction

This page describes the pre-built margin interest rate models in LEAN. If none of these models perform exactly how you want, create a custom margin interest rate model.

Null Model

The NullMarginInterestRateModel doesn't charge any margin interest. It's the default margin interest rate of the DefaultBrokerageModel.

security.margin_interest_rate_model = MarginInterestRateModel.NULL;
security.margin_interest_rate_model = MarginInterestRateModel.NULL

For more information about this model, see the class reference and implementation.

For more information about this model, see the class reference and implementation.

Short Equity Model

The ShortMarginInterestRateModel simulates the margin cost and payments of your Equity holdings. This model use the fee rate to compute the amount due to borrowing the asset to short, and the rebate rate to compute the amount due to lending the asset for shorting. For more information about these rates providers, see Short Availability.

security.SetShortableProvider(new InteractiveBrokersShortableProvider());
security.MarginInterestRateModel = new ShortMarginInterestRateModel();
security.set_shortable_provider(InteractiveBrokersShortableProvider())
security.margin_interest_rate_model = ShortMarginInterestRateModel()

For more information about this model, see the class reference and implementation.

For more information about this model, see the class reference and implementation.

Binance Futures Model

The BinanceFutureMarginInterestRateModel simulates the margin cost and payments of your Crypto Future holdings. When the funding rate is positive, the price of the perpetual contract is higher than the mark price, so traders who are long pay for short positions. Conversely, a negative funding rate indicates that perpetual prices are below the mark price, so traders who are short pay for long positions. The interest amount is

$$ Nominal \ Value \ of \ Positions * Funding \ Rate $$

The interest amount is periodically credited or debited from your currency holdings while you hold open positions. The interest amount is charged at 12 AM, 8 AM, 4 PM in your algorithm time zone.

security.MarginInterestRateModel = new BinanceFutureMarginInterestRateModel();
security.margin_interest_rate_model = BinanceFutureMarginInterestRateModel()

For more information about this model, see the class reference and implementation.

For more information about this model, see the class reference and implementation.

Bybit Futures Model

The BybitFutureMarginInterestRateModel has the same behavior as the BinanceFutureMarginInterestRateModel.

security.MarginInterestRateModel = new BybitFutureMarginInterestRateModel();
security.margin_interest_rate_model = BybitFutureMarginInterestRateModel()

For more information about this model, see the class reference and implementation.

For more information about this model, see the class reference and implementation.

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: