peterszombati / xapi-node

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

How to get notice when position is closed? #10

Closed mskorb closed 3 years ago

mskorb commented 3 years ago

I've started using your wrapper to XTB. I know how to open position, but don't know how to get notice when position is closed? If you can give me short example I would be gratefull.

mskorb commented 3 years ago

Ok i Found out that I can create callback like this: x.Socket.listen.getTrades(this.getTrades);

getTrades(data: TRADE_RECORD[]) {
    console.log(data);
  }

This seems to be executed after around 10 seconds, is it possible to get this info faster? Could you tell me if this is right way to do it?

There is also tradeTransactionStatus (http://developers.xstore.pro/documentation/2.5.0#tradeTransactionStatus) but they say that recommended way is to use stream and getTradeStatus function (how to do it?)

Ok I got it, all is need to listen stream like this: x.Stream.listen.getTradeStatus(this.getTrades);