tiagosiebler / okx-api

Node.js SDK for the OKX APIs and WebSockets, with TypeScript & browser support, integration tests, beautification & more.
MIT License
86 stars 26 forks source link

getSubAccountBalances method returns empty details array #12

Closed Mehdi-Verfaillie closed 1 year ago

Mehdi-Verfaillie commented 1 year ago

Good evening @tiagosiebler,

I encounter a problem with the function getSubAccountBalances but I have no idea to what this issue is related to.

const subAccountBalances = await OKX.client.getSubAccountBalances(subAcct)

returns an empty details array

[
  {
    adjEq: '',
    details: [],
    imr: '',
    isoEq: '0',
    mgnRatio: '',
    mmr: '',
    notionalUsd: '',
    ordFroz: '',
    totalEq: '0',
    uTime: '1673472785871'
  }
]

I expect to actually get the amount in here:

Screenshot 2023-01-11 at 23 31 34

Did I miss something on the OKX documentation ?

Thanks you~


okx-api: 1.0.2

tiagosiebler commented 1 year ago

Hi, looks like the endpoint configuration is correct. The API expects something like this:

GET /api/v5/account/subaccount/balances?subAcct=test1

https://www.okx.com/docs-v5/en/#rest-api-subaccount-get-sub-account-trading-balance

Which is what the request correctly builds: https://github.com/tiagosiebler/okx-api/blob/master/src/rest-client.ts#L733-L735

Near the end of the api docs for that endpoint, it does state:

"" will be returned for inapplicable fields with the current account level.

I'll ask OKX what that means, using your issue here as context.

tiagosiebler commented 1 year ago

OKX comments are that this is expected since some of the fields are special to the account level. Account level refers to the account mode level (e.g. simple/single/multi/portfolio). You can see it via this endpoint "acctLv": https://www.okx.com/docs-v5/en/#rest-api-account-get-account-configuration https://github.com/tiagosiebler/okx-api/blob/master/src/rest-client.ts#L560

Since this is more a question about their API behaviour, if you have further questions I recommend reaching out in their API group on telegram: https://t.me/OKXAPI

Let me know if you run into any issues with this SDK though. Thanks