Back

How does Liquidate() Behave?

Hi QC,

Can you please confirm if "Liquidate()" neutralizes portfolio or creates a short position? The trades tab attached makes it look like its a alternate Long/Short strategy?
Update Backtest








The liquidate function will bring your holdings to zero via MarketOrders. So if you hold 10 long shares of SPY, it will submit a market order for -10 shares (short). Likewise, if you hold -10 short shares of SPY, it will submit a market order for +10 shares (long).

At the implementation level it loops over all of your holdings and submits a market order whose quantity is equal to the negative of your existing quantity.
1

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.


Thanks Michael!
0

Does it cancel existing LimitOrder who were not filled yet?
0

All non-market orders will be cancelled when using the Liquidate function.
0

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.


Hi Michael,

Sort of reviving an old thread, but I wanted to ask if the liquidate() function also closes positions that are not native to QC. For example, suppose my QC algorithm was strictly trading SPY (e.g., self.AddEquity("SPY")), but I also manually have short SPX puts in my account. Would the liquidate function also open market orders for my SPX puts as well?

Thanks!
Fang

0

Correct; further if you place any trades outside of QC it will terminate the algorithm

0

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.


Great! Thank you!

0

Update Backtest





0

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.


Loading...

This discussion is closed