book
Checkout our new book! Hands on AI Trading with Python, QuantConnect, and AWS Learn More arrow

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.

Select Language:
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.

Select Language:
security.set_settlement_model(DelayedSettlementModel(7, timedelta(hours=8)))

The following table describes the arguments the model accepts:

ArgumentData TypeDescriptionDefault Value
number_of_daysintThe number of days required for settlement
time_of_daytimedeltaThe 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.

Select Language:
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.

Select Language:
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: