After Order is filled tyo buy i set
Trail Stop Loss and Stop Limit for profit , this works for QuantConnectBrokerage and InteractiveBrokersBrokerage but for Alpaca i get error below.
OnOrderEvent(OrderEvent orderEvent)
StopMarketOrder(orderEvent.Symbol,
-Portfolio[orderEvent.Symbol].Quantity,
higehstPrice * _stopLossPercent);
LimitOrder( orderEvent.Symbol,
-Portfolio[orderEvent.Symbol].Quantity,
orderEvent.FillPrice * _maxProfit);
Backtest Handled Error: OrderID: 3 Warning - Code: NotSupported - The AlpacaBrokerageModel does not support submitting orders which could potentially reverse the position (from long to short) [position:2388, order quantity:-2388, open sell orders quantity:-2388, available sell quantity:0].
Shile Wen
Hi SherpaTrader,
According to the list of supported orders, Bracket Orders are not supported at the moment. However, we can submit the opposite order once one side of the order is filled, which I've explained how to do in this thread.
Best,
Shile Wen
Shile Wen
Hi SherpaTrader,
Before we submit the order, we need to check that the Order Id of the OrderEvent matches the Order Id of the original order. This prevents the recursive calls to OnOrderEvent, which is the source of the error message. I've attached the backtest posted in the thread I mentioned, updated with this check.
Best,
Shile Wen
SherpaTrader
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!