xapi-node
Advanced tools
Comparing version 2.7.5 to 2.7.6
@@ -6,2 +6,3 @@ import { WebSocketWrapper } from '../../utils/WebSocketWrapper'; | ||
export declare class SocketConnection { | ||
connectedTime: Time | null; | ||
lastReceivedMessage: Time | null; | ||
@@ -8,0 +9,0 @@ capacity: Time[]; |
@@ -22,2 +22,3 @@ "use strict"; | ||
constructor(url, callListener, socketId) { | ||
this.connectedTime = null; | ||
this.lastReceivedMessage = null; | ||
@@ -35,2 +36,3 @@ this.capacity = []; | ||
var _a, _b; | ||
this.connectedTime = new Time_1.Time(); | ||
(_a = this.connectionProgress) === null || _a === void 0 ? void 0 : _a.resolve(); | ||
@@ -53,2 +55,3 @@ (_b = this.disconnectionProgress) === null || _b === void 0 ? void 0 : _b.reject(new Error('onOpen')); | ||
var _a, _b; | ||
this.connectedTime = null; | ||
(_a = this.disconnectionProgress) === null || _a === void 0 ? void 0 : _a.resolve(); | ||
@@ -55,0 +58,0 @@ (_b = this.connectionProgress) === null || _b === void 0 ? void 0 : _b.reject(new Error('onClose')); |
@@ -19,10 +19,10 @@ import { STREAMING_BALANCE_RECORD, STREAMING_CANDLE_RECORD, STREAMING_KEEP_ALIVE_RECORD, STREAMING_NEWS_RECORD, STREAMING_PROFIT_RECORD, STREAMING_TICK_RECORD, STREAMING_TRADE_RECORD, STREAMING_TRADE_STATUS_RECORD } from '../../interface/Definitions'; | ||
subscribe: { | ||
getBalance: () => Promise<Time>; | ||
getCandles: (symbol: string) => Promise<Time>; | ||
getKeepAlive: () => Promise<Time>; | ||
getNews: () => Promise<Time>; | ||
getProfits: () => Promise<Time>; | ||
getTickPrices: (symbol: string, minArrivalTime?: number, maxLevel?: number) => Promise<Time>; | ||
getTrades: () => Promise<Time>; | ||
getTradeStatus: () => Promise<Time>; | ||
getBalance: (streamId?: string | undefined) => Promise<Time>; | ||
getCandles: (symbol: string, streamId?: string | undefined) => Promise<Time>; | ||
getKeepAlive: (streamId?: string | undefined) => Promise<Time>; | ||
getNews: (streamId?: string | undefined) => Promise<Time>; | ||
getProfits: (streamId?: string | undefined) => Promise<Time>; | ||
getTickPrices: (symbol: string, minArrivalTime?: number, maxLevel?: number, streamId?: string | undefined) => Promise<Time>; | ||
getTrades: (streamId?: string | undefined) => Promise<Time>; | ||
getTradeStatus: (streamId?: string | undefined) => Promise<Time>; | ||
}; | ||
@@ -29,0 +29,0 @@ unSubscribe: { |
@@ -19,10 +19,10 @@ "use strict"; | ||
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'), | ||
getBalance: (streamId = undefined) => this.sendSubscribe('Balance', {}, streamId), | ||
getCandles: (symbol, streamId = undefined) => this.sendSubscribe('Candles', { symbol }, streamId), | ||
getKeepAlive: (streamId = undefined) => this.sendSubscribe('KeepAlive', {}, streamId), | ||
getNews: (streamId = undefined) => this.sendSubscribe('News', {}, streamId), | ||
getProfits: (streamId = undefined) => this.sendSubscribe('Profits', {}, streamId), | ||
getTickPrices: (symbol, minArrivalTime = 0, maxLevel = 6, streamId = undefined) => this.sendSubscribe('TickPrices', { symbol, minArrivalTime, maxLevel }, streamId), | ||
getTrades: (streamId = undefined) => this.sendSubscribe('Trades', {}, streamId), | ||
getTradeStatus: (streamId = undefined) => this.sendSubscribe('TradeStatus', {}, streamId), | ||
}; | ||
@@ -29,0 +29,0 @@ this.unSubscribe = { |
@@ -5,2 +5,3 @@ import { WebSocketWrapper } from '../../utils/WebSocketWrapper'; | ||
export declare class StreamConnection { | ||
connectedTime: Time | null; | ||
lastReceivedMessage: Time | null; | ||
@@ -7,0 +8,0 @@ capacity: Time[]; |
@@ -20,2 +20,3 @@ "use strict"; | ||
constructor(url, session, callListener, streamId, socketId) { | ||
this.connectedTime = null; | ||
this.lastReceivedMessage = null; | ||
@@ -35,2 +36,3 @@ this.capacity = []; | ||
var _a, _b; | ||
this.connectedTime = new Time_1.Time(); | ||
(_a = this.connectionProgress) === null || _a === void 0 ? void 0 : _a.resolve(); | ||
@@ -45,2 +47,3 @@ (_b = this.disconnectionProgress) === null || _b === void 0 ? void 0 : _b.reject(new Error('onOpen')); | ||
var _a, _b; | ||
this.connectedTime = null; | ||
(_a = this.disconnectionProgress) === null || _a === void 0 ? void 0 : _a.resolve(); | ||
@@ -47,0 +50,0 @@ (_b = this.connectionProgress) === null || _b === void 0 ? void 0 : _b.reject(new Error('onClose')); |
@@ -14,4 +14,4 @@ import { Listener } from '../../utils/Listener'; | ||
private getStreamId; | ||
protected sendSubscribe(command: string, completion?: Record<string, string | number>): Promise<import("../../utils/Time").Time>; | ||
protected sendSubscribe(command: string, completion?: Record<string, string | number>, streamId?: string | undefined): Promise<import("../../utils/Time").Time>; | ||
protected sendUnsubscribe(command: string, completion?: Record<string, string | number>): Promise<undefined> | Promise<import("../../utils/Time").Time>; | ||
} |
@@ -84,7 +84,12 @@ "use strict"; | ||
} | ||
sendSubscribe(command, completion = {}) { | ||
const streamId = this.getStreamId(command); | ||
sendSubscribe(command, completion = {}, streamId = undefined) { | ||
if (!streamId) { | ||
throw new Error('there is no connected stream'); | ||
streamId = this.getStreamId(command); | ||
if (!streamId) { | ||
throw new Error('there is no connected stream ' + JSON.stringify({ streamId })); | ||
} | ||
} | ||
if (!this.connections[streamId]) { | ||
throw new Error('there is no connected stream ' + JSON.stringify({ streamId })); | ||
} | ||
const promise = this.connections[streamId].sendCommand('get' + command, completion); | ||
@@ -91,0 +96,0 @@ if (this.subscribes[command]) { |
@@ -37,3 +37,6 @@ import { Listener, ListenerChild } from "../utils/Listener"; | ||
timeout: number; | ||
}): Promise<void>; | ||
}): Promise<{ | ||
socketId: string; | ||
streamId: string; | ||
}>; | ||
getAccountCurrencyValue(anotherCurrency: RelevantCurrencies): Promise<number>; | ||
@@ -40,0 +43,0 @@ getPriceHistory({ symbol, period, ticks, startUTC, }: { |
@@ -110,3 +110,3 @@ "use strict"; | ||
} | ||
resolve(); | ||
resolve({ socketId, streamId }); | ||
} | ||
@@ -113,0 +113,0 @@ catch (e) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Time = void 0; | ||
const isNodeJS = typeof window === 'undefined'; | ||
function calculateElapsedTime(time) { | ||
if (typeof window === 'undefined') { | ||
if (isNodeJS) { | ||
const hrtime = process.hrtime(time); | ||
@@ -15,3 +16,3 @@ return Math.floor(hrtime[0] * 1000 + hrtime[1] / 1000000); | ||
constructor() { | ||
this.unit = typeof window === 'undefined' ? process.hrtime() : [performance.now(), 0]; | ||
this.unit = isNodeJS ? process.hrtime() : [performance.now(), 0]; | ||
this.UTCTimestamp = Date.now(); | ||
@@ -18,0 +19,0 @@ return this; |
{ | ||
"name": "xapi-node", | ||
"version": "2.7.5", | ||
"version": "2.7.6", | ||
"description": "This project makes it possible to get data from Forex market, execute market or limit order with NodeJS/JS through WebSocket connection", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
415822
6329