Skip to content
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

One-cancels-other could be safer #152

Open
badgerwithagun opened this issue Jan 22, 2019 · 3 comments
Open

One-cancels-other could be safer #152

badgerwithagun opened this issue Jan 22, 2019 · 3 comments
Assignees
Labels
enhancement New feature or request java Requires Java skills javascript Requires JS/React skills urgent
Projects

Comments

@badgerwithagun
Copy link
Member

I plan to create a proper OCO implementation, equivalent in effective functionality to Bitfinex's:

  • A stop order
  • A limit order
  • A job with a "flip price" equidistant between the two where it cancels one order and activates the other depending on which side of that price the market currently stands.

So, as the price approaches the target price, the job will maintain a limit order to catch a wick into it. As the price approaches the stop price, the limit order is cancelled and replaced with a proper exchange-side stop (if supported, otherwise a server side stop).

@badgerwithagun badgerwithagun added enhancement New feature or request javascript Requires JS/React skills java Requires Java skills labels Jan 22, 2019
@badgerwithagun badgerwithagun self-assigned this Jan 22, 2019
@badgerwithagun badgerwithagun added this to To do in Initial public announcement via automation Jan 22, 2019
@badgerwithagun badgerwithagun moved this from To do to In progress in Initial public announcement Jan 22, 2019
@badgerwithagun
Copy link
Member Author

This is now possible since Orko now supports proper server side stops.

@badgerwithagun badgerwithagun removed this from In progress in Initial public announcement Feb 6, 2019
@badgerwithagun badgerwithagun added this to To do in v1.0.0 Feb 6, 2019
@badgerwithagun
Copy link
Member Author

Urgency of this is now reduced since the existing OCO mechanism is more reliable (it adjusts the trade size down to match the balance) but really a proper OCO where there is permanently a live server side order would be better.

@badgerwithagun
Copy link
Member Author

I've been looking at this on and off and the big problem is how to place an order and record the order id in the Orko database without the risk of a failure between the two operations, leading to Orko losing its reference to the server side order.

The the right answer is clearly to use client order ids, where Orko specifies its own order ID. It can then simply check the exchange to see if such an order is present. This is supported by Binance, but is sketchily supported by other exchanges.

I already use this in {{LImitOrderJobProcessor}} to ensure orders are placed atomically. Looks like this thing will need to do the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request java Requires Java skills javascript Requires JS/React skills urgent
Projects
v1.0.0
  
In progress
Development

No branches or pull requests

1 participant