UNPKG

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)

65 lines (64 loc) 3.22 kB
import MetaApiConnection from './metaApiConnection'; /** * Exposes MetaApi MetaTrader RPC API connection to consumers */ export default class RpcMetaApiConnection extends MetaApiConnection { private _openedInstances; /** * Constructs MetaApi MetaTrader RPC Api connection * @param {MetaApiOpts} options MetaApi options * @param {MetaApiWebsocketClient} websocketClient MetaApi websocket client * @param {MetatraderAccount} account MetaTrader account id to connect to * @param {ConnectionRegistry} connectionRegistry metatrader account connection registry */ constructor(options: any, websocketClient: any, account: any, connectionRegistry: any); /** * Opens the connection. Can only be called the first time, next calls will be ignored. * @param {string} instanceId connection instance id * @return {Promise} promise resolving when the connection is opened */ connect(instanceId: any): Promise<void>; /** * Closes the connection. The instance of the class should no longer be used after this method is invoked. * @param {string} instanceId connection instance id */ close(instanceId: any): Promise<void>; /** * Invoked when connection to MetaTrader terminal established * @param {String} instanceIndex index of an account instance connected * @param {Number} replicas number of account replicas launched * @return {Promise} promise which resolves when the asynchronous event is processed */ onConnected(instanceIndex: any, replicas: any): Promise<void>; /** * Invoked when connection to MetaTrader terminal terminated * @param {String} instanceIndex index of an account instance connected * @return {Promise} promise which resolves when the asynchronous event is processed */ onDisconnected(instanceIndex: any): Promise<void>; /** * Invoked when a stream for an instance index is closed * @param {String} instanceIndex index of an account instance connected */ onStreamClosed(instanceIndex: any): Promise<void>; /** * Returns flag indicating status of state synchronization with MetaTrader terminal * @returns {Boolean} a flag indicating status of state synchronization with MetaTrader terminal */ isSynchronized(): boolean; /** * Waits until synchronization to RPC application is completed * @param {Number} timeoutInSeconds synchronization timeout in seconds. Defaults to 5 minutes * @return {Promise} promise which resolves when synchronization to RPC application is completed * @throws {TimeoutError} if application failed to synchronize with the teminal within timeout allowed */ waitSynchronized(timeoutInSeconds?: number): Promise<void>; /** * Invoked when connection to MetaApi websocket API restored after a disconnect * @param {String} region reconnected region * @param {Number} instanceNumber reconnected instance number * @return {Promise} promise which resolves when connection to MetaApi websocket API restored after a disconnect */ onReconnected(region: any, instanceNumber: any): Promise<void>; _getState(instanceIndex: any): any; }