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

90 lines (89 loc) 3.32 kB
import { Listener } from "../modules/Listener"; import { Logger4Interface } from "logger4"; import { ConnectionStatus, PERIOD_FIELD, Time } from ".."; import { TradePosition, TradeStatus } from "../interface/Interface"; import { RelevantCurrencies } from "../enum/Enum"; import { Socket } from "./Socket/Socket"; import { Stream } from "./Stream/Stream"; export declare const DefaultHostname = "ws.xapi.pro"; export declare const DefaultRateLimit = 850; export interface XAPIConfig { accountId: string; password: string; type: string; appName?: string; host?: string | undefined; rateLimit?: number | undefined; logger?: Logger4Interface; safe?: boolean; subscribeTrades?: boolean; } export interface XAPIAccount { accountId: string; type: string; appName?: string | undefined; host: string; safe: boolean; subscribeTrades: boolean; } export interface Orders { [order: number]: { order: number; resolve: any; reject: any; data: TradeStatus | null; time: Time; }; } export declare class XAPI extends Listener { Stream: Stream; Socket: Socket; private _rateLimit; private _tryReconnect; private _positions; private _positionsUpdated; private _serverTime; private timer; protected account: XAPIAccount; orders: Orders; get logger(): Logger4Interface; get accountType(): string | null; get isTradingDisabled(): boolean; get accountId(): string; get appName(): string | undefined; get hostName(): string; get rateLimit(): number; get tryReconnect(): boolean; get isSubscribeTrades(): boolean; get openPositions(): TradePosition[]; get limitPositions(): TradePosition[]; get positionsUpdated(): Time | null; get positions(): TradePosition[]; get isConnectionReady(): boolean; get isReady(): boolean; get serverTime(): number; constructor({ accountId, password, type, appName, host, rateLimit, logger, safe, subscribeTrades, }: XAPIConfig); private refreshOrderStatus; private stopTimer; connect(): void; disconnect(): Promise<unknown>; getAccountCurrencyValue(anotherCurrency: RelevantCurrencies): Promise<number>; getPriceHistory({ symbol, period, ticks, startUTC, }: { symbol: string; period?: PERIOD_FIELD | undefined; ticks?: number; startUTC?: number; }): Promise<{ symbol: string; period: PERIOD_FIELD; candles: number[][]; digits: number; }>; onReady(callBack: () => void, key?: string | null): import("..").ListenerChild; onReject(callBack: (err: any) => void, key?: string | null): import("..").ListenerChild; onConnectionChange(callBack: (status: ConnectionStatus) => void, key?: string | null): import("..").ListenerChild; onCreatePosition(callBack: (position: TradePosition) => void, key?: string | null): import("..").ListenerChild; onDeletePosition(callBack: (position: TradePosition) => void, key?: string | null): import("..").ListenerChild; onChangePosition(callBack: (position: TradePosition) => void, key?: string | null): import("..").ListenerChild; onPendingPosition(callBack: (position: TradePosition) => void, key?: string | null): import("..").ListenerChild; }