Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Outdated OptionContract is not removed from OptionChain

Open LouisSzeto opened this issue 3 years ago • 2 comments

Expected Behavior

When an option contract fits the criteria of the filter, it will be added to the OptionChain. Likewise, if it does not fit anymore (outdated), it should be removed from the OptionChain.

Actual Behavior

Outdated OptionContract is not removed from OptionChain. The new ones would still come in, accumulating the contracts within the chain.

Potential Solution

Reproducing the Problem

https://www.quantconnect.com/terminal/processCache?request=embedded_backtest_625c9f58fbf496c9a109fc62145ea1de.html

System Information

NA

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

LouisSzeto avatar Apr 20 '22 17:04 LouisSzeto

This behavior is on purpose to avoid a performance penalty of adding and remove the option contracts every minute, take a look at https://github.com/QuantConnect/Lean/blob/master/Common/Data/UniverseSelection/OptionChainUniverse.cs#L212, changed by https://github.com/QuantConnect/Lean/pull/943 . But they are removed on the next day though, in live trading this would happen every 15 min instead

Martin-Molinero avatar Apr 20 '22 20:04 Martin-Molinero

Maybe this behavior could be refactored so that it respects the given UniverseSettings.MinimumTimeInUniverse instead, same for the FuturesChainUniverse

Martin-Molinero avatar Apr 20 '22 21:04 Martin-Molinero