I'm pretty new to this so probably doing something silly. But I'm running a backtest, and some of the first orders placed are to sell stocks that I haven't yet placed buy orders for? Any ideas?
QUANTCONNECT COMMUNITY
I'm pretty new to this so probably doing something silly. But I'm running a backtest, and some of the first orders placed are to sell stocks that I haven't yet placed buy orders for? Any ideas?
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.
JumboFlan
Attached image of orders:
JumboFlan
OK, now I'm even more confused. The Sell Order is for a stock that shouldn't even be in my universe as it over my price limit. Would love any advice here!
(And trying and failing to attach an image of the orders...it just won't show)
JumboFlan
Hmm - is the sell order for stocks not yet in my portfolio, me unintentionally shorting?
Still no idea how the stock is included in my universe at $45 when my selection limits up to $15
JumboFlan
Apologies for spamming comments - I am just very confused. So the stock should be in the universe, as its price was within my limits, but for some reason my order is getting filled at $45/share instead of $5.
Jovad Uribe
Hi JumboFlan,
I took a brief look over your code and the logic error seems like it may be coming from your OnSecuritiesChanged method. You need to also loop through changes.RemovedSecurities and remove the corresponding security from any variables and containers you created. Let me know if this helps.
Cheers
Derek Melchin
Hi JumboFlan,
To resolve the issue of fill prices being above the $15 threshold, we need to replace
universe = [c for c in coarse if 1 < c.Price < 15 and c.Volume > 1000000]
with
universe = [c for c in coarse if 1 < c.AdjustedPrice < 15 and c.Volume > 1000000]
See the attached backtest for reference.
> is the sell order for stocks not yet in my portfolio, me unintentionally shorting?
Correct. The backtest view page shows that insights with a down direction are emitted.
Continuing the development of this algorithm, consider the following:
Best,
Derek Melchin
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.
JumboFlan
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!