I am runing a daily universe selection and I use Liquidate() to terminate all positions that exited my universe. It seems to work fine, except that in the list of orders I can see that the "Sell market on open" orders do not always contain the complete share quantity. Whenever the whole quantity is sold, there is a tag "Liquidated" next to the order.
2021-01-05 00:00:00 ARPO Buy Market On Open Fill: $1.05 USD 949 Filled
2021-01-05 00:00:00 AIV Buy Market On Open Fill: $5.08 USD 197 Filled
2021-01-06 00:00:00 ARPO Sell Market On Open Fill: $1.15 USD -949 Filled Liquidated
2021-01-06 00:00:00 AIV Sell Market On Open Fill: $5.03 USD -194 Filled
Is this intended behavior? Is it because of some volume restriction for the "on open" order? How can I make sure to liquidate the complete position?
Alexandre Catarino
Hi Deep Frickin Value ,
Could you please share a backtest that reproduces this behavior?
The orders that are placed by the Liquidate method are tagged accordingly, so I would guess that the second order for AIV was not a liquidation, but a rebalance. Instead of holding 197 shares, the algorithm has determined that it should hold 3.
Deep Frickin Value
Hi Alexandre Catarino
You were righ. Thanks for pointing me in the right direction!
My checks whether I already own the stock were not correct.
On that note, what is the best way to compare securities objects? Using Symbol.Equals() method? Or can we use the == operator on Symbols?
Alexandre Catarino
Hi Deep Frickin Value ,
The best way to compare Symbol objects would be using the == operator because of simplicity and it's the Pythonista way. However, they are equivalent, so we can use the one we like the most.
Deep Frickin Value
Thanks Alexandre Catarino
Somehow I noticed that when having symbols in a list/array, the "in" operator didn't work correctly. It seems to work with dictionaries though. I'm not sure if there is a difference in "Symbols", depending on where they come from (universe, SecurityHolding, self.Securities.. etc.)? In the end I decided to compare the Symbol.Value which works but is not ideal.
Alexandre Catarino
Hi Deep Frickin Value ,
If you can attach a backtest with concrete examples of what works and doesn't, we can take a look at it.
Deep Frickin Value
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!