Lean
Lean copied to clipboard
Add Automatic Contract Rollover
Expected Behavior
Have user-defined future/option control rollover rules. This will be useful for trading continuous contracts for futures and certain option strategies that rely on rollovers.
Actual Behavior
Currently, contracts expire and positions are liquidated.
Potential Solution
Have user-defined rollover module which allows contracts to rollover on expiration.
Reproducing the Problem
Holding a contract until expiration liquidates our position and doesn't rollover.
System Information
Windows 10
Checklist
- [x] I have completely filled out this template
- [x] I have confirmed that this issue exists on the current
masterbranch - [x] I have confirmed that this is not a duplicate issue by searching issues
- [x] I have provided detailed steps to reproduce the issue
Related to https://github.com/QuantConnect/Lean/issues/1650
Initial discussion
future.SetRolloverModel()
MappingRolloverModel { }
- AlgorithmManager 291 OnSymbolChanged event trigger ApplyRollover() model for future securities.
- Give the model the algorithm or portfolio to place trades directly.
- Best ease of use would be to allow purchase of continuous contract.
- We should default to auto roll as its 10x easier than current manual rolling. Warning current users of manual rolling or disabling it based on trading the mapped symbol? 🤔 Or sadly slow rollout with transition period to let all the users know.
- Create NullRolloverModel to disable auto rolling.
- Create PythonRolloverModelWrapper for custom python implementations.