Back

Probably a Stupid Question..... SetHoldings() and Liquidate()

If certain conditions are met and I am holding random stock "A" can I just call SetHoldings("B", 1), or would I have to call Liquidate("B") first before to sell all of stock B before being able to move my Portfolio to B?

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.


Hi Tebzzz,

I have two interpretations of your question. In case I misunderstood your question, I will provide answers for both interpretations.

  1. You are asking if SetHoldings("B", 1) would automatically liquidate "A" in your portfolio and switch to only holdings in "B". The answer is no. If you wish to switch your portfolio to only have holdings in "B" and liquidate all of the old security "A", you would use self.SetHoldings("B", 1, True). Otherwise, since the default leverage for equities is 2, the old security "A" would remain in your portfolio, and SetHoldings("B", 1) would achieve 100% of current TotalPortfolioValue using the available margin.
  2. You are asking if you should liquidate "B" before using SetHoldings("B", 1). The answer is no because SetHoldings will create a market order to automatically adjust the quantity of "B" to achieve 100% of the available margin. If you call Liquidate("B") and then SetHoldings("B", 1), it would achieve almost the same result, but this would incur more orders and result in higher fees.

You can find this information in the Documentation. Hope this helps!

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.


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