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

How to best implement Kraken fetchOrderTrades? #3414

Closed
miracle2k opened this issue Jul 17, 2018 · 3 comments
Closed

How to best implement Kraken fetchOrderTrades? #3414

miracle2k opened this issue Jul 17, 2018 · 3 comments
Assignees
Labels

Comments

@miracle2k
Copy link
Contributor

Kraken has an API called QueryTrades: https://www.kraken.com/help/api#query-trades-info

By my experiments, txid must be a trade id, and the trades parameter seems to have no effect at all. In other words, this API does not allow us to query the trades for a given order id.

However, the "fetch order" api knows the trade ids (but only the ids). So to implement fetchOrderTrades we'd have to do:

  • Fetch the order
  • Use the trade ids with QueryTrades to get the trade details.

Is this something we should do? We'd have to do two queries (at least). Also, the user likely already did a fetchOrder by themselves already, and now for the trades, another one would happen implicitly.

Alternative options:

  • A special parameter for fetchOrder, includeTrades, which will call the QueryTrades API, and the trades would then be included under the trades key (the way Bitstamp includes the trades directly in a fetchOrder response).

  • Do not do anything, Kraken-users can just call QueryTrades manually.

@kroitor kroitor self-assigned this Jul 17, 2018
@kroitor
Copy link
Member

kroitor commented Jul 17, 2018

The general approach is:

  • If the exchange in question outputs trades within an order – use them to fill the trades property of the order, derive fees, etc... Parse trades inside the order to a "view" that is detailed as much as possible.
  • If it does not support that in the order API, but offers a standalone fetchOrderTrades endpoint that will output an array of trades by order id (and a symbol, if required by the exchange) – add fetchOrdeTrades.

However, with Kraken QueryTrades, the intent and the meaning of txid parameter is to query their trades database by trade ids, something that only makes sense in case you are building a history-retrieving app... Indeed, neither ledger ids nor order ids work for txid, just the trade ids.

Also, note that txid is actually a "comma delimited list of transaction ids to query info about (20 maximum)", so you can query any set of trades, whether they belong to the same order or to different orders.

If I were to align it with the CCXT structure, instead of fetchOrderTrades I would add fetchMyTrades with a required txid extra param and a proper exception if that param is not set. That would correspond to the functional intent behind QueryTrades which is to fetch your trades (despite that Kraken only does that by trade ids). Does this answer your question?

@kroitor kroitor changed the title Kraken: fetchOrderTrades How to best implement Kraken fetchOrderTrades? Jul 17, 2018
@miracle2k
Copy link
Contributor Author

I like the idea. Kraken already has fetchMyTrades (which calls a different API: https://www.kraken.com/help/api#get-trades-history), but it could be given an optional txid extra param, and if given, it uses QueryTrades instead.

@kroitor
Copy link
Member

kroitor commented Jul 17, 2018

@miracle2k ok, i'd close this for now, if you don't mind, feel free to reopen it if needed or just ask further questions, will answer asap. Thx!

@kroitor kroitor closed this as completed Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants