Suppose I have a universe selection that runs on Midnight on Fridays, and some equities are removed from my universe. Subsequently, I use a Liquidate call to remove them in my Execute class. For US equities, those calls happen outside of market hours. Do the Liquidate orders get converted to On Market Orders for the next Monday (except for holidays, etc.)?
If there are no holdings for the equity in question, I presume the call is a no-op. Is that a good assumption?
This is the method I am using in my execution model:
class OrderExecution(ExecutionModel):
...
def OnSecuritiesChanged(self, algorithm, changes):
# Event handler for securities added and removed.
# changes.AddedSecurities:
# We do not need to do anything for AddedSecurities.
# changes.RemovedSecurities:
# Liquidate removed securities.
for removed in changes.RemovedSecurities:
algorithm.Log("Liquidating removed security {}".format(removed.Symbol.Value))
algorithm.Liquidate(removed.Symbol)
algorithm.Log("Available cash now ${:.2f}".format(algorithm.Portfolio.Cash))
Thank you for your help.
Varad Kabade
Hi Thomas Beauchamp-Arnold,
Do the Liquidate orders get converted to On Market Orders for the next Monday (except for holidays, etc.)?
Yes, you are right; any order created during non-market hours gets converted to MarketOnOpenOrder order.
If there are no holdings for the equity in question, I presume the call is a no-op. Is that a good assumption?
Yes, when we call the Liquidate method, the algorithm checks for holding and then liquidates accordingly. So if we are not invested there, won't be any order placed. Refer to the attached backtest.
Best,
Varad Kabade
Thomas Beauchamp-Arnold
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!