Account information#
About#
Notifies consumer about changes to account balance or equity.
For more information see AsyncApi documentation
Description#
This event is emitted by MetaApi upon initial terminal state synchronization
You can track account equity using information about open positions, current symbol price and tick value as described in Calculating position profits and account equity
The message below can be received from the synchronization
event.
Name | Type | Required | Description |
---|---|---|---|
type | string | Yes | The value of this field will be accountInformation |
synchronizationId | string | Yes | Id of the synchronization request |
accountInformation | object | Yes | MetaTrader account information. Account information schema: MetatraderAccountInfo |
accountId | string | Yes | account id specified in the request |
sequenceNumber | number | Yes | an ordinal number of the packet. Increases by 1 with each new packet. Starts with 0 in every new session. Can be used to check for packet loss during synchronization. |
sequenceTimestamp | number | Yes | an ordinal number of packets, but this field is increased by a random number in each new packet. Always increases regardless of the session. |
Code example:
import ioClient from 'socket.io-client';
const socket = ioClient('https://mt-client-api-v1.agiliumtrade.agiliumtrade.ai', {
path: '/ws',
reconnection: false,
query: {
'auth-token': 'token'
}
});
const request = {
accountId: '865d3a4d-3803-486d-bdf3-a85679d9fad2',
type: 'synchronize',
requestId: '57bfbc9f-108d-4131-a300-5f7d9e69c11b',
startingDealTime: '2019-01-13T10:29:26.000Z',
startingHistoryOrderTime: '2019-01-13T10:29:26.000Z'
};
socket.on('connect', () => {
socket.emit('request', request);
});
socket.on('synchronization', data => {
console.log(data);
if (data.type === 'authenticated') {
request.requestId = uuid.v4();
socket.emit('request', request);
}
});
socket.on('processingError', err => {
console.error(err);
});
An example of a synchronization payload:
{
"type": "accountInformation",
"synchronizationId": "57bfbc9f-108d-4131-a300-5f7d9e69c11b",
"accountInformation": {
"broker": "True ECN Trading Ltd",
"currency": "USD",
"server": "ICMarketsSC-Demo",
"balance": 7320.22,
"equity": 7210.460000000002,
"margin": 88.27,
"freeMargin": 7133.74,
"leverage": 100,
"marginLevel": 8181.7265209,
"tradeAllowed": true,
"marginMode": "ACCOUNT_MARGIN_MODE_RETAIL_HEDGING",
"name": "Will Turner",
"login": 367906877,
"credit": 0,
"accountCurrencyExchangeRate": 1
},
"accountId": "865d3a4d-3803-486d-bdf3-a85679d9fad2"
}