Export Trades By Login¶
Exports the full filtered trade list for the authenticated account into a file stored on the server.
POST
https://{some_domain}/trades/export
Authorization¶
All requests must include a JWT token:
Authorization: <JWT_TOKEN>
The account login is resolved from the authenticated session.
Request¶
Content-Type: application/json
Body Parameters¶
| Field | Type | Required | Description |
|---|---|---|---|
tradeType |
int | Yes | Trade type filter in range 0..4 |
format |
string | Yes | Output format: csv or excel |
where |
array | No | Additional filter rules |
whereNot |
array | No | Negated filter rules |
whereIn |
array | No | Inclusion filter rules in [[field, [value1, value2, ...]], ...] format |
whereNotIn |
array | No | Exclusion filter rules in [[field, [value1, value2, ...]], ...] format |
whereBetween |
array | No | Range filter rules in [[field, [from, to]], ...] format |
whereNotBetween |
array | No | Negative range filter rules in [[field, [from, to]], ...] format |
orderBy |
array | No | Sort instructions |
select |
array | No | List of fields to export. If omitted or empty, the default column layout for the selected tradeType is used |
total |
array | No | List of numeric fields that must be summed in a final Total: row |
tradeType Values¶
0= all trades1= open trades2= closed trades3= pending trades4= finance trades
Supported select Fields¶
If select is passed, every item must be one of the fields below. Any unknown field causes 400 INVALID_DATA.
orderlogincmdstatesymbolreasonvolumeopen_timeclose_timeopen_priceclose_pricesltpprofitnet_profitcommissionstoragecommentdigitsexpiration
Supported total Fields¶
If total is passed and is not empty, the export appends one summary row at the bottom. The first column contains Total:, and sums are written only under the requested columns. Fields that do not apply to the selected tradeType cause 400 INVALID_DATA.
| Field | Applies to |
|---|---|
volume |
Open, closed, pending, and all trades |
profit |
Open, closed, and all trades |
net_profit |
Open, closed, and all trades |
commission |
Open, closed, and all trades |
swap |
Open, closed, and all trades |
amount |
Finance and all trades |
Alias is supported: storage is treated as swap.
Export Formatting Notes¶
- if
selectis omitted or passed as an empty array, the default layout fortradeTypeis used - exported values follow the same order as the selected columns
volumeis exported in display format, divided by100open_time,close_time,creation_time, andexpirationare exported as UTC datetime strings indd.mm.yyyy HH:MM:SS- prices are formatted using
TradeRecord::digits - finance amounts are formatted with 2 decimal places
- totals are formatted with up to 2 decimal places
net_profitis calculated asprofit + commission + storage- column headers in exported files are human-readable, for example
Order typeinstead oforder_type
Default Export Layouts¶
Open trades¶
Order Symbol Login Order type Volume Open time Open price Market price Profit Net profit Sl Tp Commission Swap Comment
Closed trades¶
Order Symbol Login Order type Volume Open time Open price Close time Close price Profit Net profit Sl Tp Commission Swap Comment
Pending trades¶
Order Symbol Login Order type Volume Open time Activation price Market price Sl Tp Expiration Comment
Finance trades¶
Transaction Login Name Transaction type Amount Creation time Comment
All trades¶
tradeType = 0 exports a combined layout covering open, closed, pending, and finance fields. Fields that do not apply to a particular row are exported as empty values.
Request Example¶
{
"tradeType": 1,
"format": "csv",
"select": ["order", "symbol", "open_time", "volume", "profit", "net_profit"],
"total": ["volume", "profit", "net_profit"],
"where": [],
"whereNot": [],
"orderBy": [["open_time", "DESC"]]
}
Response¶
Success (200)¶
{
"file_name": "550e8400-e29b-41d4-a716-446655440000.csv"
}
Notes¶
format = "csv"generates a.csvfileformat = "excel"generates a.xlsxfile- the response contains only the generated file name with extension
- the export always contains the full filtered result set
limitandoffsetare not supported by this method
Error Responses¶
| Code | Error | Description |
|---|---|---|
| 400 | INVALID_DATA |
Validation failed or select contains an unsupported field |
| 400 | INVALID_USER |
Authenticated account is not available |
| 401 | PERMISSION_DENIED |
Missing or invalid authenticated session |
| 500 | EXPORT_CREATE_DIR_ERROR |
Failed to create the storage directory |
| 500 | EXPORT_OPEN_FILE_ERROR |
Failed to open the export file |
| 500 | EXPORT_WRITE_FILE_ERROR |
Failed to write the export file |