Refactor Delistings Processing (#6059)
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled

* Move processing of delistings to Brokerage

* Deal with case that exchange is not open on OptionSymbol.ID.Date

* Refactor solution to use DelistingNotification event

* Adjust some regression expected liquidation time

* Mark some todos on deprecated functions

* Update expected liqudation time for Py regressions

* Update regressions that have been validated

* Use HandlePositionAssigned for assignment orders

* Update regressions

* Update some missed unit tests; remove one that is already covered by regression

* Cleanup deprecated backend functions

* nit - small cleanup adjustment

* Post rebase fix

* Address review

* Minor tweak to py regression
This commit is contained in:
Colton Sellers
2021-11-17 12:43:35 -08:00
committed by GitHub
parent 325e788728
commit 33599b473d
55 changed files with 615 additions and 656 deletions
@@ -28,6 +28,7 @@ class BasicTemplateOptionsDailyAlgorithm(QCAlgorithm):
self.SetStartDate(2015, 12, 23)
self.SetEndDate(2016, 1, 20)
self.SetCash(100000)
self.optionExpired = False
equity = self.AddEquity(self.UnderlyingTicker, Resolution.Daily)
option = self.AddOption(self.UnderlyingTicker, Resolution.Daily)
@@ -56,3 +57,17 @@ class BasicTemplateOptionsDailyAlgorithm(QCAlgorithm):
def OnOrderEvent(self, orderEvent):
self.Log(str(orderEvent))
# Check for our expected OTM option expiry
if orderEvent.Message == "OTM":
# Assert it is at midnight 1/16 (5AM UTC)
if orderEvent.UtcTime.month != 1 and orderEvent.UtcTime.day != 16 and orderEvent.UtcTime.hour != 5:
raise AssertionError(f"Expiry event was not at the correct time, {orderEvent.UtcTime}")
self.optionExpired = True
def OnEndOfAlgorithm(self):
# Assert we had our option expire and fill a liquidation order
if not self.optionExpired:
raise AssertionError("Algorithm did not process the option expiration like expected")