StopLoss & AlpacaBrokerageModel not supporting submitting sell orders with open buy orders

Back

hi there,

I was wondering if anybody had a good way of preventing -"The AlpacaBrokerageModel does not support submitting sell orders with open buy orders"

Everything shows up fine on backtests but when deployed live the stoplimit orders do not get accepted because my buy orders havent been filled yet. The stop limit order then immediatly gets rejected.

Does anyone have a good idea on how to prevent this problem?

 

ps thanks for the help ;)

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.


This is a limitation of the brokerage (specifically the clearing firm they use). The solution, in this case, is to accurately model backtest with the realistic limitations of the brokerage; this is done by adding the Alpaca brokerage model:

SetBrokerageModel(BrokerageName.Alpaca);

Now you'll get all the invalidated orders in backtesting too! =) 

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 Jared,

thanks for your help. Is there any way to delay the stop order going in so it doesnt get rejected?

0

The best way would be to monitor for the order events in the OnOrderEvent handler, and when you see fills for orders you can place a stop order for the ticker. We don't have an example of this specific approach in the documentation but you would look at the fill events and compare it with the order id of the other pair you're connecting. 

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