UNPKG

@fraserdarwent/xapi-node

Version:

This project is made possible to get data from Forex market, execute market or limit order with NodeJS/JS through WebSocket connection

41 lines 2.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Stream = void 0; const StreamConnection_1 = require("./StreamConnection"); class Stream extends StreamConnection_1.StreamConnection { constructor(XAPI) { super(XAPI, 'wss://' + XAPI.hostName + '/' + XAPI.accountType + 'Stream'); this.listen = { getBalance: (callBack, key = null) => this.addListener('command_' + 'balance', callBack, key), getCandles: (callBack, key = null) => this.addListener('command_' + 'candle', callBack, key), getKeepAlive: (callBack, key = null) => this.addListener('command_' + 'keepAlive', callBack, key), getNews: (callBack, key = null) => this.addListener('command_' + 'news', callBack, key), getProfits: (callBack, key = null) => this.addListener('command_' + 'profit', callBack, key), getTickPrices: (callBack, key = null) => this.addListener('command_' + 'tickPrices', callBack, key), getTrades: (callBack, key = null) => this.addListener('command_' + 'trade', callBack, key), getTradeStatus: (callBack, key = null) => this.addListener('command_' + 'tradeStatus', callBack, key), }; this.subscribe = { getBalance: () => this.sendSubscribe('Balance'), getCandles: (symbol) => this.sendSubscribe('Candles', { symbol }), getKeepAlive: () => this.sendSubscribe('KeepAlive'), getNews: () => this.sendSubscribe('News'), getProfits: () => this.sendSubscribe('Profits'), getTickPrices: (symbol, minArrivalTime = 0, maxLevel = 6) => this.sendSubscribe('TickPrices', { symbol, minArrivalTime, maxLevel }), getTrades: () => this.sendSubscribe('Trades'), getTradeStatus: () => this.sendSubscribe('TradeStatus'), }; this.unSubscribe = { getBalance: () => this.sendUnsubscribe('Balance'), getCandles: (symbol) => this.sendUnsubscribe('Candles', { symbol }), getKeepAlive: () => this.sendUnsubscribe('KeepAlive'), getNews: () => this.sendUnsubscribe('News'), getProfits: () => this.sendUnsubscribe('Profits'), getTickPrices: (symbol) => this.sendUnsubscribe('TickPrices', { symbol }), getTrades: () => this.sendUnsubscribe('Trades'), getTradeStatus: () => this.sendUnsubscribe('TradeStatus'), }; } } exports.Stream = Stream; //# sourceMappingURL=Stream.js.map