New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to set custom stoploss before entry #9233
Comments
I don't think that this type of order placement has wide-spread support (so far, i've only seen it on bybit futures). I only see this as worth the time if it's supported by multiple exchanges, in which case it can provide benefits to a wider userbase - so please let me know which of binance/okx/gate do support this (obviously using the same ccxt interface - and on which markets this support exists (spot, futures)). Also, please investigate how this needs to be handled after the fact (like - how do we get the order-id for these additional orders - across the supported exchanges)? i've briefly looked at this for bybit, and it seems that while the placement of the initial orders is pretty simple - you only get one order id back, so you essentially can't track what happens to the "other" orders once the initial order fills. From an interface perspective - that's the wront point in time for this. I've marked this as question for now - as i'm pretty sure it'll be a bybit only feature - but proof me wrong, and it may be a nice enhancement. |
You are right on the fact that this type of order is not a standard and It could be complicated to track the order once created within an entry. You can see on majority of exchange, for perpetual contracts, I can put theses trigger order before having an actual position, even an open order. This way we can have a separate "orderid" that will allow us to manage the order normally. |
it's a possibility eventually in the future - but you need to be VERY cautious to ensure orders are properly canceled alongside other orders / deleting the trade - which is all logic we currently don't need/have. i don't see the need for anything new though from an interface perspective. The way i see the process:
that's a gap of milliseconds (depending on the exchange) - if you place your order to "not fill immediately" - it shouldn't be a problem It'll however not happen soon ... things like stoploss_order_id will make this cumbersome and difficult to handle. |
Context
Using custom entry or exit price, user can wait postpone his entry or exit when the market reach a price level.
It is a great tool to enter at key levels or market structure (last period low, last period high, Fibonacci retracement / extension, etc...)
However, for an entry case, if the market reach the desired price, but violently move deeper, there is a big loss potential, as the stop loss is not yet placed on exchange.
Describe the enhancement
Being able to take advantage of the possibility to create entry stop loss directly within entry order could mitigate greatly that risk.
Why?
It will allow an increased risk protection on the position in case of sudden price change, as there is no gap in time between entry and stop-loss on exchange activation.
It will allow more precise stop loss based on user defined market structure.
Explain the enhancement you would like
Ability to set custom stop-loss in entry order
Note
This feature will be particularly useful if user want to enter at custom price, and exit immediately if a price level is not held.
Tested with ccxt and bybit with this sample code:
On exchange Order:
Implementation idea:
As
custom_stoploss
require an active Trade object, I would add a new callback namedinitial_custom_stoploss
orentry_custom_stoploss
The text was updated successfully, but these errors were encountered: