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.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.set_settlement_model(DelayedSettlementModel(7, timedelta(hours=8)))
The following table describes the arguments the model accepts:
Argument | Data Type | Description | Default Value |
---|---|---|---|
number_of_days | int | The number of days required for settlement | |
time_of_day | timedelta | The 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.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.set_settlement_model(FutureSettlementModel())
To view the implementation of this model, see the LEAN GitHub repository.