Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Price shift before continous future roll

Open ashutoshrana171 opened this issue 1 year ago • 1 comments

Expected Behavior

Continuous future should have prices for the new contract only after the contract is rolled to the new contract.

Actual Behavior

Continuous future have prices for the new contract before the contract is rolled to the new contract. Continuous future price should match the prices of "self.Securities[self.esContinuous.Mapped].Close". This starts to break outside regular trading hours from 19:00 - 23:59.

Example:

2022-12-13 22:00:00 :	Time: 2022-12-13 22:00:00 .... Mapped: ES16Z22 .... Close: 4063.375 .... Mapped Close: 4030.375
//Close price is the close of the new contract "Y6URRFPZ86BL" before the roll event is triggered at 00:00:00"
2022-12-13 23:00:00 :	Time: 2022-12-13 23:00:00 .... Mapped: ES16Z22 .... Close: 4069.375 .... Mapped Close: 4036.25
//Close price is the close of the new contract "Y6URRFPZ86BL" before the roll event is triggered at 00:00:00"

2022-12-14 00:00:00 :	Time: 2022-12-14 00:00:00 .... Contract rollover from ES Y4D62XFM9IPT to ES Y6URRFPZ86BL

2022-12-14 00:00:00 :	Time: 2022-12-14 00:00:00 .... Mapped: ES17H23 .... Close: 4067.625 .... Mapped Close: 4067.625
2022-12-14 01:00:00 :	Time: 2022-12-14 01:00:00 .... Mapped: ES17H23 .... Close: 4067.875 .... Mapped Close: 4067.875

Reproducing the Problem

Reference backtest Check out prices before and after the roll event is triggered. "Continuous future" price should match "Continuous Future Mapped" prices but from 19:00 - 23:59 it starts to show prices for the next contract before the roll at 00:00

Screenshot 2024-03-26 at 10 07 49 AM

System Information

QC Cloud

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

ashutoshrana171 avatar Mar 21 '24 17:03 ashutoshrana171

Also https://github.com/QuantConnect/Lean/issues/7997

jaredbroad avatar Jul 12 '24 15:07 jaredbroad