Welcome to our new support center! Some articles may still be missing; they will be added shortly. For the old support documentation go to https://support.altrady.com. If you have questions, open a new ticket here. New tickets on support.altrady.com won’t be answered; existing tickets will be finalised there.

Altrady Support Altrady Support
12
Closed This request is closed. You can still comment, but it stays closed unless the team reopens it. Trading

Creating orders on Altrady with TP/SL is not atomic

I just created an order on Binance using AltradyI set the TP/SL parameters but they did not appear on Binance but they remained in a "Pending" state. This is how a correct order would look like on Binance:The problem with not setting orders properly is that in case the network, your server, or Binance's API goes down, while the order is triggered, the TP/SL won't be added to the position leading to potential losses.

Note that this is a bug, not a feature request. Binance supports atomically creating an order with TP/SL eg: creating the order and adding TP/SL in one step.

I was told that you're handling the pending orders internally, but this is a leaky abstraction it will cause problems and losses down the road when this inevitably happens.

Suggested over 1 year ago

3 comments

[email protected]

Please note, that once an entry order fills, the Take Profit order should be opened on the exchange. However, Stop Losses are always handled internally by Altrady (once the Stop price is reached, the order is immediately sent to the exchange).

For Futures, it is possible to place them both on the exchange at the same time, from the start of the position, by following the guide in the video linked below:

https://youtu.be/LvxaUT487WI  (https://youtu.be/LvxaUT487WI%C2%A0)

For Spot however, this is not possible, as coins cannot be reserved in both a Take Profit and Stop Loss concurrently.

over 1 year ago

[email protected]

The main thing is that the TP/SL should be added together with the order. If you don't do it atomically (eg: in one step that either succeeds or fails altogether) there is a chance that it won't be added at all (for example if binance API goes down when you're trying to call it, or your server goes down, or the network goes down).Losses are always handled internally by Altrady (once the Stop price is reached, the order is immediately sent to the exchange).👆 this is exactly the problem. it is possible that you can't immediately send the order to the exchange for reasons outlined above. As soon as you have 3rd parties to rely on your system turns into a distributed system and these operations should be executed in a transaction. What you don't seem to realize is that you have a distributed transaction currently that can fail and leave the system in an inconsistent state. This inconsistent state can lead to people losing $$$. Don't think that you can always send those orders immediately because not even AWS guarantees a 100% uptime in their SLA. It is just not possible.

over 1 year ago

[email protected]

In fact what you said makes this even worse. Up until now I thought that you set the SL/TP immediately after my position is created (eg: I'm tagged into the trade). If you are monitoring the price action and manually sending out stop loss orders it means that there will be slippage since you always have network latency. In case of crypto price can swing wildly within seconds. So what you're doing is inherently a bad idea.

over 1 year ago

Sign in to join the discussion.