Calculate metrics#
About#
Calculates and returns a MetaApi account metrics. This API call is billable
GET /users/current/accounts/:accountId/metrics
For more information see swagger documentation. Note, that this URL is valid for new-york region only. You can find URLs for other regions on API access page.
Headers#
Name | Type | Required | Description |
---|---|---|---|
auth-token | string | Yes | MetaApi account token. See Authentication & authorization |
Path parameters#
Name | Type | Required | Description |
---|---|---|---|
accountId | string | Yes | MetaApi account id |
Query parameters#
Name | Type | Required | Description |
---|---|---|---|
includeOpenPositions | boolean | indicates inclusion of open positions in the calculation |
Response#
Responses:
- 200 - metrics for a specified MetaTrader account returned successfully. Response schema: {metrics: Metrics}
- 202 - metrics for the specified MetaTrader account in processing. Response schema: {status: string, message: string}. Response headers: {"retry-after": integer} - interval in seconds to retry
- 401 - Authorization failed due to auth-token invalid. Response schema: Error
- 403 - MetaStats API is not enabled on provided trading account. Response schema: Error
- 500 - Failed to calculate metrics for a specified MetaApi account. Response schema: Error
Examples#
Example request:
curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' 'https://metastats-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/metrics'
Example synchronous response:
{
"metrics": {
"equity": 101120.7,
"lots": 2.21,
"profit": 1120.6999999999985,
"trades": 3,
"deposits": 100000,
"averageTradeLengthInMilliseconds": 72082075,
"bestTrade": 849,
"bestTradeDate": "2020-12-18 02:52:10.986",
"worstTrade": -80.3,
"worstTradeDate": "2020-12-15 11:23:04.332",
"dailyGain": 0.02299061669379654,
"monthlyGain": 0.7012819632221667,
"absoluteGain": 1.1206999999999985,
"wonTradesPercent": 66.66666666666666,
"lostTradesPercent": 33.33333333333333,
"wonTrades": 2,
"lostTrades": 1,
"balance": 101120.7,
"highestBalance": 100768.7,
"highestBalanceDate": "2020-12-18 02:52:10.986",
"longWonTrades": 1,
"shortWonTrades": 1,
"longTrades": 1,
"shortTrades": 2,
"longWonTradesPercent": 100,
"shortWonTradesPercent": 50,
"equityPercent": 100,
"averageWin": 600.4999999999993,
"averageLoss": -80.3,
"periods": {
"thisYear": {
"trades": 0,
"tradesDifference": -2,
"profitDifference": -768.7,
"lotsDifference": -2.01,
"gainDifference": -0.7687,
"wonTradesPercentDifference": -50
}
},
"currencySummary": [
{
"currency": "EURUSD",
"long": {
"profit": 849,
"trades": 1
},
"short": {
"profit": -80.3,
"trades": 1
},
"total": {
"lostTradesPercent": 50,
"wonTradesPercent": 50,
"profit": 768.7,
"trades": 2,
"wonTrades": 1,
"lostTrades": 1
},
"history": [
{
"shortProfit": -80.3,
"totalProfit": -80.3,
"date": "2020-12-15"
},
{
"longProfit": 849,
"shortProfit": -80.3,
"totalProfit": 768.7,
"date": "2020-12-18"
}
]
}
],
"gain": 1.1206999999999967,
"geometricHoldingPeriodReturn": 0.3721797704011598,
"expectancy": 373.5666666666662,
"profitFactor": 14.956413449564119,
"standardDeviationProfit": 465.02522870628576,
"sortinoRatio": 0.000707281402889009,
"kurtosisProfit": 9.41311416749099,
"riskOfRuin": [
{
"lossSize": 0.1,
"probabilityOfLoss": 4.4157980586753144e-108,
"consecutiveLosingTrades": 125
},
{
"lossSize": 0.2,
"probabilityOfLoss": 1.9499272495000674e-215,
"consecutiveLosingTrades": 251
},
{
"lossSize": 0.3,
"probabilityOfLoss": 8.4e-323,
"consecutiveLosingTrades": 377
},
{
"lossSize": 0.4,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 503
},
{
"lossSize": 0.5,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 629
},
{
"lossSize": 0.6,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 755
},
{
"lossSize": 0.7,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 881
},
{
"lossSize": 0.8,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 1007
},
{
"lossSize": 0.9,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 1133
},
{
"lossSize": 1,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 1259
}
],
"monthlyAnalytics": [
{
"trades": 2,
"lots": 2.01,
"profit": 768.7,
"gains": 0.769382294882791,
"date": "2020-12",
"currencies": [
{
"rewardToRiskRatio": 9.572851805728519,
"popularityPercent": 100,
"currency": "EURUSD",
"averageHoldingTimeLongsInMilliseconds": 204603354,
"averageHoldingTimeShortsInMilliseconds": 11642871
}
]
}
],
"closeTradesByWeekDay": [
{
"day": 2,
"lostTradesPercent": 100,
"shortTradesPercent": 100,
"lostGains": -0.0803,
"lostProfit": -80.3,
"lostTrades": 1,
"shortGains": -0.0803,
"shortProfit": -80.3,
"shortTrades": 1,
"gains": -0.0803,
"profit": -80.3,
"trades": 1
},
{
"day": 5,
"wonTradesPercent": 100,
"longTradesPercent": 100,
"wonGains": 0.849682294882791,
"wonProfit": 849,
"wonTrades": 1,
"longGains": 0.849682294882791,
"longProfit": 849,
"longTrades": 1,
"gains": 0.849682294882791,
"profit": 849,
"trades": 1
}
],
"openTradesByHour": [
{
"trades": 1,
"profit": 351.9999999999985,
"gains": 0.3493148170017064,
"shortTrades": 1,
"shortProfit": 351.9999999999985,
"shortGains": 0.3493148170017064,
"wonTrades": 1,
"wonProfit": 351.9999999999985,
"wonGains": 0.3493148170017064,
"shortTradesPercent": 100,
"wonTradesPercent": 100,
"hour": 2
},
{
"hour": 8,
"lostTradesPercent": 100,
"shortTradesPercent": 100,
"lostGains": -0.0803,
"lostProfit": -80.3,
"lostTrades": 1,
"shortGains": -0.0803,
"shortProfit": -80.3,
"shortTrades": 1,
"gains": -0.0803,
"profit": -80.3,
"trades": 1
},
{
"hour": 18,
"wonTradesPercent": 100,
"longTradesPercent": 100,
"wonGains": 0.849682294882791,
"wonProfit": 849,
"wonTrades": 1,
"longGains": 0.849682294882791,
"longProfit": 849,
"longTrades": 1,
"gains": 0.849682294882791,
"profit": 849,
"trades": 1
}
],
"dailyGrowth": [
{
"drawdownPercentage": 0.08030000000000291,
"drawdownProfit": 80.30000000000291,
"lots": 1.01,
"totalProfit": -80.3,
"profit": -80.3,
"totalGains": -0.0803,
"gains": -0.0803,
"balance": 99919.7,
"date": "2020-12-15"
},
{
"balance": 100768.7,
"lots": 1,
"totalProfit": 768.7,
"profit": 849,
"totalGains": 0.769382294882791,
"gains": 0.849682294882791,
"date": "2020-12-18"
}
],
"tradeDuration": {
"won": [
{
"durationInMinutes": 3410,
"lots": [
1
],
"profits": [
849
],
"gains": [
0.85
]
}
],
"lost": [
{
"durationInMinutes": 194,
"lots": [
1.01
],
"profits": [
-80.3
],
"gains": [
-0.08
]
}
]
},
"tradeDurationDiagram": [
{
"minDurationInSeconds": 11643,
"name": "hours",
"lost": {
"lots": [
1.01
],
"profits": [
-80.3
],
"gains": [
-0.08
]
},
"trades": 1,
"durations": 1
},
{
"minDurationInSeconds": 204603,
"name": "days",
"won": {
"lots": [
1
],
"profits": [
849
],
"gains": [
0.85
]
},
"trades": 1,
"durations": 1
}
]
}
}
Example asynchronous response:
{
"state": "processing",
"message": "Metrics calculation in the process. It can take some time. Try again later"
}
with headers:
{
"retry-after": 60
}
Example request (include open positions into calculations):
curl -X GET --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'auth-token: token' 'https://metastats-api-v1.new-york.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/metrics?includeOpenPositions=true'
Example synchronous response:
{
"metrics": {
"equity": 101120.7,
"lots": 2.21,
"profit": 1120.6999999999985,
"trades": 3,
"deposits": 100000,
"averageTradeLengthInMilliseconds": 72082075,
"bestTrade": 849,
"bestTradeDate": "2020-12-18 02:52:10.986",
"worstTrade": -80.3,
"worstTradeDate": "2020-12-15 11:23:04.332",
"dailyGain": 0.02299061669379654,
"monthlyGain": 0.7012819632221667,
"absoluteGain": 1.1206999999999985,
"wonTradesPercent": 66.66666666666666,
"lostTradesPercent": 33.33333333333333,
"wonTrades": 2,
"lostTrades": 1,
"balance": 101120.7,
"highestBalance": 100768.7,
"highestBalanceDate": "2020-12-18 02:52:10.986",
"longWonTrades": 1,
"shortWonTrades": 1,
"longTrades": 1,
"shortTrades": 2,
"longWonTradesPercent": 100,
"shortWonTradesPercent": 50,
"equityPercent": 100,
"averageWin": 600.4999999999993,
"averageLoss": -80.3,
"periods": {
"thisYear": {
"trades": 0,
"tradesDifference": -2,
"profitDifference": -768.7,
"lotsDifference": -2.01,
"gainDifference": -0.7687,
"wonTradesPercentDifference": -50
}
},
"currencySummary": [
{
"currency": "EURUSD",
"long": {
"profit": 849,
"trades": 1
},
"short": {
"profit": -80.3,
"trades": 1
},
"total": {
"lostTradesPercent": 50,
"wonTradesPercent": 50,
"profit": 768.7,
"trades": 2,
"wonTrades": 1,
"lostTrades": 1
},
"history": [
{
"shortProfit": -80.3,
"totalProfit": -80.3,
"date": "2020-12-15"
},
{
"longProfit": 849,
"shortProfit": -80.3,
"totalProfit": 768.7,
"date": "2020-12-18"
}
]
}
],
"gain": 1.1206999999999967,
"geometricHoldingPeriodReturn": 0.3721797704011598,
"expectancy": 373.5666666666662,
"profitFactor": 14.956413449564119,
"standardDeviationProfit": 465.02522870628576,
"riskOfRuin": [
{
"lossSize": 0.1,
"probabilityOfLoss": 4.4157980586753144e-108,
"consecutiveLosingTrades": 125
},
{
"lossSize": 0.2,
"probabilityOfLoss": 1.9499272495000674e-215,
"consecutiveLosingTrades": 251
},
{
"lossSize": 0.3,
"probabilityOfLoss": 8.4e-323,
"consecutiveLosingTrades": 377
},
{
"lossSize": 0.4,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 503
},
{
"lossSize": 0.5,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 629
},
{
"lossSize": 0.6,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 755
},
{
"lossSize": 0.7,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 881
},
{
"lossSize": 0.8,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 1007
},
{
"lossSize": 0.9,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 1133
},
{
"lossSize": 1,
"probabilityOfLoss": 0,
"consecutiveLosingTrades": 1259
}
],
"monthlyAnalytics": [
{
"trades": 2,
"lots": 2.01,
"profit": 768.7,
"gains": 0.769382294882791,
"date": "2020-12",
"currencies": [
{
"rewardToRiskRatio": 9.572851805728519,
"popularityPercent": 100,
"currency": "EURUSD",
"averageHoldingTimeLongsInMilliseconds": 204603354,
"averageHoldingTimeShortsInMilliseconds": 11642871
}
]
}
],
"closeTradesByWeekDay": [
{
"day": 2,
"lostTradesPercent": 100,
"shortTradesPercent": 100,
"lostGains": -0.0803,
"lostProfit": -80.3,
"lostTrades": 1,
"shortGains": -0.0803,
"shortProfit": -80.3,
"shortTrades": 1,
"gains": -0.0803,
"profit": -80.3,
"trades": 1
},
{
"day": 5,
"wonTradesPercent": 100,
"longTradesPercent": 100,
"wonGains": 0.849682294882791,
"wonProfit": 849,
"wonTrades": 1,
"longGains": 0.849682294882791,
"longProfit": 849,
"longTrades": 1,
"gains": 0.849682294882791,
"profit": 849,
"trades": 1
}
],
"openTradesByHour": [
{
"trades": 1,
"profit": 351.9999999999985,
"gains": 0.3493148170017064,
"shortTrades": 1,
"shortProfit": 351.9999999999985,
"shortGains": 0.3493148170017064,
"wonTrades": 1,
"wonProfit": 351.9999999999985,
"wonGains": 0.3493148170017064,
"shortTradesPercent": 100,
"wonTradesPercent": 100,
"hour": 2
},
{
"hour": 8,
"lostTradesPercent": 100,
"shortTradesPercent": 100,
"lostGains": -0.0803,
"lostProfit": -80.3,
"lostTrades": 1,
"shortGains": -0.0803,
"shortProfit": -80.3,
"shortTrades": 1,
"gains": -0.0803,
"profit": -80.3,
"trades": 1
},
{
"hour": 18,
"wonTradesPercent": 100,
"longTradesPercent": 100,
"wonGains": 0.849682294882791,
"wonProfit": 849,
"wonTrades": 1,
"longGains": 0.849682294882791,
"longProfit": 849,
"longTrades": 1,
"gains": 0.849682294882791,
"profit": 849,
"trades": 1
}
],
"dailyGrowth": [
{
"drawdownPercentage": 0.08030000000000291,
"drawdownProfit": 80.30000000000291,
"lots": 1.01,
"totalProfit": -80.3,
"profit": -80.3,
"totalGains": -0.0803,
"gains": -0.0803,
"balance": 99919.7,
"date": "2020-12-15"
},
{
"balance": 100768.7,
"lots": 1,
"totalProfit": 768.7,
"profit": 849,
"totalGains": 0.769382294882791,
"gains": 0.849682294882791,
"date": "2020-12-18"
}
],
"tradeDuration": {
"won": [
{
"durationInMinutes": 3410,
"lots": [
1
],
"profits": [
849
],
"gains": [
0.85
]
}
],
"lost": [
{
"durationInMinutes": 194,
"lots": [
1.01
],
"profits": [
-80.3
],
"gains": [
-0.08
]
}
]
},
"tradeDurationDiagram": [
{
"minDurationInSeconds": 11643,
"name": "hours",
"lost": {
"lots": [
1.01
],
"profits": [
-80.3
],
"gains": [
-0.08
]
},
"trades": 1,
"durations": 1
},
{
"minDurationInSeconds": 204603,
"name": "days",
"won": {
"lots": [
1
],
"profits": [
849
],
"gains": [
0.85
]
},
"trades": 1,
"durations": 1
}
],
"daysSinceTradingStarted": 80.37,
"inclusive": true
}
}
Example asynchronous response:
{
"state": "processing",
"message": "Metrics calculation in the process. It can take some time. Try again later"
}
with headers:
{
"retry-after": 60
}