JKorf / Kraken.Net

A C# .netstandard client library for the Kraken REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Kraken.Net/
MIT License
102 stars 54 forks source link

GetUserTradeDetailsAsync Doesn't Return The Right Data #75

Closed jaylagorio closed 1 year ago

jaylagorio commented 1 year ago

Describe the bug When returning data, the KrakenUserTrade data structure is used improperly. It contains fields like ClosedAverageCost or ClosedPriced, which are not returned from the underlying GetTradesInfo call and are set to null or Nothing. The cost, fee, etc fields that are present in the return data are not passed back to the application using the library. At this point I don't see any way to get that information for trades, although that information was present at least a year ago when I needed it last.

To Reproduce Call GetUserTradeDetailsAsync with any Trade ID and observe that the fields named Closed* are null or Nothing, and none of the cost or fee data is contained anywhere in the returned structure.

Expected behavior I would have expected cost and fee data to be returned.

Debug logging 2023/03/10 19:05:11:984 | Information | Kraken | [4] Creating request for https://api.kraken.com/0/private/TradesHistory 2023/03/10 19:05:12:148 | Debug | Kraken | [4] Response received in 157ms 2023/03/10 19:05:12:161 | Information | Kraken | [5] Creating request for https://api.kraken.com/0/private/QueryTrades 2023/03/10 19:05:12:343 | Debug | Kraken | [5] Response received in 155ms

JKorf commented 1 year ago

Looks like the the API is implemented as described on

  1. https://docs.kraken.com/rest/#tag/User-Data/operation/getTradesInfo
  2. https://docs.kraken.com/rest/#tag/User-Data/operation/getTradeHistory

If data is not returned for some reason thats outside of my control. If you feel like something should be fixed because the mapping or something is incorrect please let me know.

jaylagorio commented 1 year ago

I think something should be fixed because the mapping or something is incorrect. For example, calling GetUserTradeAsync (which hits the TradeHistory endpoint) returns this information:

image

However, running the Python example client (https://support.kraken.com/hc/en-us/articles/360025180232-REST-API-command-line-client-Python-) with the TradeHistory endpoint returns this data:

{"error":[],"result":{"count":5384,"trades":{"TAY77K-FMNYL-KGCUHN":{"ordertxid":"OLQWKA-HUCZS-NNV5MY","postxid":"TKH2SE-M7IF5-CFI7LT","pair":"TBTCXBT","time":1679144288.0316086,"type":"sell","ordertype":"limit","price":"1.03006000","cost":"0.00005892","fee":"0.00000012","vol":"0.00005720","margin":"0.00000000","leverage":"0","misc":"","trade_id":77183}

Note the cost data is in the JSON being returned in the Python data. This is data that should be present in GetUserTradeAsync and at least at one point was present when I used the same code to retrieve that data last year.

JKorf commented 1 year ago

Its under QuoteQuantity right?

jaylagorio commented 1 year ago

That appears to be right - it wasn't obvious that was what it was being mapped to. Thanks!