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

Fix KuCoin average price #823

Merged
merged 1 commit into from
Jan 11, 2024
Merged

Conversation

v36u
Copy link
Contributor

@v36u v36u commented Jan 10, 2024

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"
    }
}

@vslee vslee merged commit ea0dc3b into DigitalRuby:main Jan 11, 2024
0 of 2 checks passed
@v36u v36u deleted the fix-kucoin-average-price branch January 21, 2024 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants