Settlement

Supported Models

Introduction

This page describes all of the pre-built settlement models in LEAN. For more brokerage-specific settlement models, see the brokerage model documentation. If none of these models perform exactly how you want, create a custom settlement model.

Immediate Model

The ImmediateSettlementModel immediately adds or removes the cash from your portfolio when your transactions fill.

security.SetSettlementModel(new ImmediateSettlementModel());
security.set_settlement_model(ImmediateSettlementModel())

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

Delayed Model

The DelayedSettlementModel immediately removes the cash from your portfolio when your buy orders fill. When your sell orders fill, it adds the cash to your unsettled cash book. When the settlement period ends, the unsettled cash is added to your portfolio.

security.SetSettlementModel(new DelayedSettlementModel(7, TimeSpan.FromHours(8)));
security.set_settlement_model(DelayedSettlementModel(7, timedelta(hours=8)))

The following table describes the arguments the model accepts:

ArgumentData TypeDescriptionDefault Value
numberOfDaysnumber_of_daysintThe number of days required for settlement
timeOfDaytime_of_dayTimeSpantimedeltaThe time of day used for settlement

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

Account Currency Immediate Model

The AccountCurrencyImmediateSettlementModel applies cash settlement immediately and automatically converts the settlement cash into the account currency.

security.SetSettlementModel(new AccountCurrencyImmediateSettlementModel());
security.set_settlement_model(AccountCurrencyImmediateSettlementModel())

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

Future Model

The FutureSettlementModel settles the daily profit and loss at the start of each day.

security.SetSettlementModel(new FutureSettlementModel());
security.set_settlement_model(FutureSettlementModel())

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: