peterszombati / xapi-node

xStation5 Trading API for NodeJS/JS
https://peterszombati.github.io/xapi-node/
Other
58 stars 19 forks source link

getBalance() #7

Closed bda2206 closed 4 years ago

bda2206 commented 4 years ago

Hi, final question I hope, How do I getBalance? I've set up the same callback as for trades but nothing ever comes through. is there a command to request the info to the callback?

Oh I see I get a balance if there are trades going. but not before?

thanks

peterszombati commented 4 years ago

Hi @bda2206

You can get balance by this request

https://github.com/peterszombati/xapi-node/blob/1e8e6bd05d2d4d5e5a7d5fc396b220e7c25c530a/src/core/Socket/Socket.ts#L74

x.Socket.send.getMarginLevel().then(r => console.log(r))

You will get this response type

{
    balance: number
    credit: number
    currency: string
    equity: number
    margin: number
    margin_free: number
    margin_level: number
}

This docs (https://peterszombati.github.io/xapi-node/) can help you in the future every commands are exists in functions in xapi-node