Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Backtesting: Flexible Settlement date

Open Romazes opened this issue 9 months ago • 0 comments

Expected Behavior

Create flexible DefaultSettlementDays depending on Securities. For instance: Run algo before May 28, 2024 the DefaultSettlementDays for Equites => 2 days.

Actual Behavior

Use the DefaultSettlementDays for Equites => 1 day always.

Potential Solution

Should use different SettlementDays by Securties and backtesting time. The SettlementDays was changed (look at attached PR) to 1 day, but if the user runs algo before SettlementDays changed it will use the wrong amount of settled cash in the user balance.

Also, we should pay attention to different markets (international ones). Different SettlementDaya values can be used.

Reproducing the Problem

Run algo before May 28, 2024. Buy or sell' SPY' on the same day and ensure that cash is settled successfully.

Related PRs

  • https://github.com/QuantConnect/Lean/pull/8657

System Information

N/a

Checklist

  • [x] I have completely filled out this template
  • [x] I have confirmed that this issue exists on the current master branch
  • [x] I have confirmed that this is not a duplicate issue by searching issues
  • [x] I have provided detailed steps to reproduce the issue

Romazes avatar Mar 28 '25 13:03 Romazes