Trigger price missing for stop order. Error in strategy

I get the above error while placing order (during backtests)



I tried to set the trigger price with below piece of code

# Original order 
# order_id = order(asset, 1, stop_price=current["open"])
# Set trigger price
order_id = order(asset, 1, trigger=current["open"], stop_price=current["open"])

A more general question would be is it possible to place these orders (menitoned in the document) in backtest scenario

I am specifially interested in placing a buy order

  • that gets triggered when price reaches certain level (on the upper side)
  • post the trigger, it could be market order / limit order

At present we do not support stoploss (or take-profit) orders (please see the order API function documentation). However, it is straight-forward to simulate this behaviour. For a given asset, you need to keep track of your current price and match the stop and target levels to trigger the desired action. You can define this in a function and then call the function in the handle data to run this check at the maximum possible frequency. See here for some example (note, this is not tested yet on the new version).



Also, if you find your strategy is highly sensitive to stoploss/ take profit parameters (and you plan to use actual stoploss orders than chceking the price as above in live trading), you need to test it on higher frequency data. For minute level data, limit price behaviour can be simulated more reliably than stoploss or other highly path dependent orders.

Thanks for the response

I understood how to simulate stoploss (or take-profit).



Do you have plans to support this in the future ?

Having it in the API makes the life of a developer a lot more easy



 

I think I missed addressing this question before. Yes we do have a plan to introduce these directly through Blueshift APIs for live trading only (for brokers that support streaming data and order updates). However, the ETA for this is not very clear. Expect sometimes towards mid of this year perhaps. Do let us know if you have any questions.