LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
In my algorithm, on the "sell" or "close" side of things when I receive a trigger to get rid of the investment, I've tried both of the calls above, and they yield signifantly different overall backtesting results over the period and symbols I'm using.
I guess I would have expected SetHoldings to 0 would be the same as a MarketOrder to sell however many shares of the stock I'm holding in my portfolio.
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.
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.
Alexandre Catarino
,
When you call SetHoldings with `liquidateExistingHoldings` set to true, this method send a market order that will liquidate the existings holding and, after that, send another market order to set the holdings according to the second parameter (percentage). On the other hand, when percentage is zero, the second market order will be sent with the quantity of shares we still hold. Since there is no time to account the effects of the first order, the algorithm is sending two market orders with the same quantity (and sign).
or, when using SetHolding, do not set `liquidateExistingHoldings` to true. Simply use `SetHoldings(item.Symbol)`.
0
TedVZ
540
,
Ah, OK. I intentionally didn't use Liquidate as I thought that was an EOD operation, and I didn't want to wait for market close to close the position. Thanks for the info.
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...
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!