metaapi.cloud-sdk
Version:
SDK for MetaApi, a professional cloud forex API which includes MetaTrader REST API and MetaTrader websocket API. Supports both MetaTrader 5 (MT5) and MetaTrader 4 (MT4). CopyFactory copy trading API included. (https://metaapi.cloud)
64 lines (56 loc) • 1.84 kB
text/typescript
/** Request from client, sent to server to restore connection */
export type RestoreConnectionRequest = {
/** Sticky connnection ID */
sessionId: string;
/** Last sent packeet index. If no packets sent, defaults to `-1` */
lastSentIndex: number;
/** Last received packet index. If no packets received, defaults to `-1` */
lastReceivedIndex: number;
/** First history packet index which is still stored at client, so can be sent again */
firstHistoryIndex?: number;
};
/** Response, sent to client on `restore_connection` event */
export type RestoreConnectionResponse = {
/** Whether restored */
restored: boolean;
/** Index since which the client should send packets. Exists if restored */
sendSinceIndex?: number;
};
/** Emitted history packet */
export type EmitHistoryPacket = {
/** Sent packet index */
index: number;
/** Event */
event: string;
/** Packet date */
data: any[];
/** Send time */
time: Date;
};
/** Emitted packet */
export type EmitPacket = Pick<EmitHistoryPacket, 'index' | 'data'>;
/** Restore connection event */
export const RESTORE_CONNECTION_EVENT = 'restore_connection';
/** User event */
export const EVENT = 2;
/** User event with binary data */
export const BINARY_EVENT = 5;
/** Common socket options */
export type SocketOptions = {
/** Emit history buffer TTL. Defaults to `10` seconds */
emitHistoryTtlInSeconds?: number;
};
/** Client socket.io socket disconnect reason */
export type ClientSocketDisconnectReason =
| 'io server disconnect'
| 'io client disconnect'
| 'ping timeout'
| 'transport close'
| 'transport error';
/** Server socket.io socket disconnect reason */
export type ServerSocketDisconnectReason =
| 'transport error'
| 'server namespace disconnect'
| 'client namespace disconnect'
| 'ping timeout'
| 'transport close';