You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When liquidated, the shares are sold at market price equal to ExecContext.sell_fill_price, which is configurable and defaults to the midpoint between the bar’s open and close price.
But the definition of MIDDLE is:
Midpoint between low price and high price of the current bar.
There is a discrepancy between these two. So the question is, what is the PriceType of tailing stop trades?
Is it possible to set a particular PriceType for trailing stop? Currently, it gives following error:
ValueError: sell_shares or hold_bars must be set when sell_fill_price is set.
The text was updated successfully, but these errors were encountered:
Thanks for catching this! The notebook is incorrect, the MIDDLE type is the midpoint between the low and high price. I have updated the notebook.
A trailing stop does not use MIDDLE. It is filled at the stop threshold, e.g. if the stop is hit at $99, then the fill price will be $99. The low price is used to test whether the stop is hit for long positions, and high for short:
if low <= self._stop_data[stop.id].value:
return self._stop_data[stop.id].value # fill price
This is not configurable via sell_fill_price. If you need greater control over how the stop is filled, I would suggest creating your own stop, similar to what is done in #24. The stop APIs are provided for quick convenience, but you can achieve the same, and even more sophisticated logic, by checking your own conditions during execution.
I guess the PriceType is MIDDLE, based on
But the definition of MIDDLE is:
There is a discrepancy between these two. So the question is, what is the PriceType of tailing stop trades?
Is it possible to set a particular PriceType for trailing stop? Currently, it gives following error:
The text was updated successfully, but these errors were encountered: