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 integration documentation pages. 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.SettlementModel = new ImmediateSettlementModel();
security.SettlementModel = 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.SettlementModel = new DelayedSettlementModel(7, TimeSpan.FromHours(8));
security.SettlementModel = DelayedSettlementModel(7, timedelta(hours=8))

The following table describes the arguments the model accepts:

ArgumentData TypeDescriptionDefault Value
numberOfDaysintThe number of days required for settlement
timeOfDayTimeSpantimedeltaThe 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.SettlementModel = new AccountCurrencyImmediateSettlementModel();
security.SettlementModel = AccountCurrencyImmediateSettlementModel()

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: