Javascript SDK for MetaStats forex trading statistics API. Can calculate metrics for MetaTrader accounts added to MetaApi. Supports both MetaTrader 5 (MT5) and MetaTrader 4 (MT4). (https://metaapi.cloud)
npm install metaapi.cloud-metastats-sdkUsing MetaStats API you can develop applications similar to Myfxbook or MetriX extremely fast, saving time you otherwise spend for coding, optimizing and testing your own trading metrics calculation engine, since we already did it for you.
MetaStats API is a member of MetaApi project (https://metaapi.cloud), a powerful cloud forex trading API which supports both MetaTrader 4 and MetaTrader 5 platforms.
- support for MetaTrader 4 and MetaTrader 5 platforms
- metrics calculation for MetaTrader accounts added to MetaApi
- optionally include open positions in metrics calculation
- get historical trades for MetaApi account. The historical trades data is updated when you invoke metrics calculation endpoint or when set query parameter updateHistory to true
- get open trades for MetaApi account
The features described above are available for use via a professional, fast, easy to use, standards-driven REST API which can be easily consumed from any programming language.
The primary intended use of MetaStats API is creating trade monitoring applications.
You pay a fee executing MetaTrader terminal on MetaApi cloud. See https://metaapi.cloud/#pricing for more details. In some cases a free tier access can be available.
MetaStats REST API docs are available at https://metaapi.cloud/docs/metastats/
- Javascript: https://github.com/metaapi/metaapi-javascript-sdk/tree/master/examples/node/metastats
bash
npm install --save metaapi.cloud-sdk
`Installing SDK in browser SPA applications
`bash
npm install --save metaapi.cloud-sdk
`Installing SDK in browser HTML applications
`html
`
Retrieving API token
Please visit https://app.metaapi.cloud/token web UI to obtain your API token.Configuring trading statistics
`javascript
import {MetaStats} from 'metaapi.cloud-sdk';const token = '...';
const metaStats = new MetaStats(token);
`
See esdoc in-code documentation for full definition of possible configuration options.Retrieving trading statistics
`javascript
let accountId = '...'; // MetaApi account id// retrieve MetaApi MetaTrader account statistics
console.log(await metaStats.getMetrics(accountId));
// retrieve MetaApi MetaTrader account statistics including open positions
console.log(await metaStats.getMetrics(accountId, true));
// retrieve MetaApi MetaTrader account trades
console.log(await metaStats.getAccountTrades(accountId, '2020-01-01 00:00:00.000', '2021-01-01 00:00:00.000'));
// retrieve MetaApi MetaTrader account open trades
console.log(await metaStats.getAccountOpenTrades(accountId));
// reset MetaApi MetaTrader account metrics
console.log(await metaStats.resetMetrics(accountId));
``Some of the APIs you might decide to use together with this module:
1. MetaApi cloud forex trading API https://metaapi.cloud/docs/client/
2. CopyFactory copy trading API https://metaapi.cloud/docs/copyfactory/
3. MetaTrader account management API https://metaapi.cloud/docs/provisioning/
4. MetaApi MT manager API https://metaapi.cloud/docs/manager/
5. MetaApi risk management API https://metaapi.cloud/docs/risk-management/