hi there,
just wondering if there is any solution to this problem: i try to submit a stoplimit order directly after a buy order. however, it gets rejected by alpaca becuase I cannot submit sell order with a current buy order open.
i just wanna figure out how to delay the stoplimit going in until after the buy is filled so it doesnt get cancelled.
i have tried stuff like(and other similar stuff):
Limitorder(stock, qty, 109.00)
if (ticket.Status == orderstatus.filled);
stoplimit order
but it doesnt work for some reason. any ideas anyone on how to make sure both of these order get submitted?
also, i would like to send my thanks to the Quantconnect team. always helpful, always there. thanks ;)
Shile Wen
Hi Christian,
We can place a Stop Limit Order in OnOrderEvent if we check if (orderEvent.Status == OrderStatus.Filled && orderEvent.Direction == OrderDirection.Buy). I've shown this in the attached backtest.
Best,
Shile Wen
Christian Olsen
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!