DigitalRuby / ExchangeSharp

ExchangeSharp is a powerful, fast and easy to use .NET/C# API for interfacing with many crypto currency exchanges. REST and web sockets are supported.
https://www.digitalruby.com
MIT License
737 stars 374 forks source link

Fix KuCoin average price #823

Closed v36u closed 5 months ago

v36u commented 6 months ago

When interacting with the KuCoin orders API, the price field is always returned with the value 0. Luckily, there are two other documented fields we can use to calculate the average price: dealFunds (the amount of base (e.g., USDT) spent/received) and dealSize (the amount of target (e.g., BLUR) spent/received). Example responses:

{
    "code": "200000",
    "data": {
        "id": "<redacted>",
        "symbol": "BLUR-USDT",
        "opType": "DEAL",
        "type": "market",
        "side": "sell",
        "price": "0",
        "size": "25",
        "funds": "0",
        "dealFunds": "11.275",
        "dealSize": "25",
        "fee": "0.015785",
        "feeCurrency": "USDT",
        "stp": "",
        "stop": "",
        "stopTriggered": false,
        "stopPrice": "0",
        "timeInForce": "GTC",
        "postOnly": false,
        "hidden": false,
        "iceberg": false,
        "visibleSize": "0",
        "cancelAfter": 0,
        "channel": "API",
        "clientOid": "<redacted>",
        "remark": null,
        "tags": null,
        "isActive": false,
        "cancelExist": false,
        "createdAt": 1704809539502,
        "tradeType": "TRADE"
    }
}
{
    "code": "200000",
    "data": {
        "id": "<redacted>",
        "symbol": "BLUR-USDT",
        "opType": "DEAL",
        "type": "market",
        "side": "buy",
        "price": "0",
        "size": "0",
        "funds": "33.7429",
        "dealFunds": "33.74289428",
        "dealSize": "75.3526",
        "fee": "0.047240051992",
        "feeCurrency": "USDT",
        "stp": "",
        "stop": "",
        "stopTriggered": false,
        "stopPrice": "0",
        "timeInForce": "GTC",
        "postOnly": false,
        "hidden": false,
        "iceberg": false,
        "visibleSize": "0",
        "cancelAfter": 0,
        "channel": "WEB",
        "clientOid": null,
        "remark": null,
        "tags": null,
        "isActive": false,
        "cancelExist": false,
        "createdAt": 1704809877399,
        "tradeType": "TRADE"
    }
}