@sharplygroup/xtb-api-js
Version:
A module for interacting with the XTB API
38 lines (37 loc) • 1.06 kB
TypeScript
export interface IXtbCredentials {
userId: string;
password: string;
demo: boolean;
}
export interface IWebSocketResponse {
status: boolean;
returnData?: any;
errorCode?: string;
errorDescr?: string;
streamSessionId?: string;
}
export interface ICommand {
command: string;
arguments: any;
[key: string]: any;
}
export declare class WebSocketManager {
private mainSocket;
private streamSocket;
private pingInterval;
private streamSessionId;
getStreamSessionId(): string | null;
private readonly credentials;
private readonly isDemo;
constructor(credentials: IXtbCredentials);
private getMainSocketUrl;
private getStreamSocketUrl;
connect(): Promise<void>;
private waitForConnection;
login(): Promise<IWebSocketResponse>;
private startPingInterval;
sendCommand(command: ICommand): Promise<IWebSocketResponse>;
sendStreamCommand(command: ICommand): Promise<void>;
onStreamMessage(callback: (data: any) => void): void;
disconnect(): Promise<void>;
}