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

To view the implementation of this model, see the LEAN GitHub repository.

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()

To view the implementation of this model, see the LEAN GitHub repository.

Bybit Futures Model

The BybitFutureMarginInterestRateModel has the same behavior as the BinanceFutureMarginInterestRateModel.

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

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: