Skip to content

Read historical trades by time range#

About#

Returns historical trades with specific time range for MetaApi account. Updates the historical trades data and the API call will be counted towards billable MetaStats API calls by default. Not billed if updateHistory parameter is false

GET /users/current/accounts/:accountId/historical-trades/:startTime/:endTime

For more information see swagger documentation. Note, that this URL is valid for vint-hill 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
startTime string Yes start of time range, inclusive, in broker timezone, in YYYY-MM-DD HH:mm:ss.SSS format
endTime strinf Yes end of time range, exclusive, in broker timezone, in YYYY-MM-DD HH:mm:ss.SSS format

Query parameters#

Name Type Required Description
limit integer pagination limit, default: 1000, min: 1, max: 1000
offset integer pagination offset, default: 0, min: 0
updateHistory boolean update historical trades before returning results. If set to true, the API call will be counted towards billable MetaStats API calls. If set to false, the API call is not billable. Default is true

Response#

Responses:

  • 200 - Historical trades with requested time range for a specified MetaTrader account returned successfully. Response schema: {trades: Array}
  • 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
  • 404 - MetaTrader account not found or not provisioned yet. 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.vint-hill.agiliumtrade.ai/users/current/accounts/865d3a4d-3803-486d-bdf3-a85679d9fad2/historical-trades/2020-09-08%2022:21:36.000/2020-09-09%2022:21:36.000'

Example synchronous response: ```json { "trades": [ { "_id": "865d3a4d-3803-486d-bdf3-a85679d9fad2+1", "accountId": "865d3a4d-3803-486d-bdf3-a85679d9fad2", "positionId": "1", "volume": 1, "durationInMinutes": 16, "profit": 3.01, "gain": 106, "success": "won", "openTime": "2020-09-08 22:21:36.000", "type": "DEAL_TYPE_BUY", "symbol": "EURUSD", "closeTime": "2020-09-08 24:37:36.000", "openPrice": 1.1835, "closePrice": 1.1935, "pips": 100 } ] }