Export Trades By Filter
MngExportTradesByFilter¶
Description: Exports trades selected by the same tabular filter model as MngGetTradesByFilter into a file stored in the server storage directory.
The method does not return trade rows in JSON. Instead, it creates a file and returns only its generated name.
The export always contains the full filtered result set.
Request Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
groupFilter |
string | Yes | Group mask to filter trades |
tradeType |
int | Yes | Trade type filter in range 0..4 |
format |
string | Yes | Output format: csv or excel |
where |
array | No | Additional conditions for filtering trades |
whereNot |
array | No | Exclusion conditions for filtering trades |
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 |
Trade Types¶
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.
| Field | Description |
|---|---|
order |
Trade order ID |
login |
Account login |
cmd |
Trade command/type |
state |
Internal trade state |
symbol |
Symbol name |
reason |
Trade creation reason |
volume |
Trade volume exported in display format (volume / 100) |
open_time |
Open time exported as UTC datetime string |
close_time |
Close time exported as UTC datetime string |
open_price |
Open price exported using TradeRecord::digits precision |
close_price |
Close price exported using TradeRecord::digits precision |
sl |
Stop loss exported using TradeRecord::digits precision |
tp |
Take profit exported using TradeRecord::digits precision |
profit |
Profit value exported with 2 digits after the decimal point |
net_profit |
Net profit exported with 2 digits after the decimal point. Calculated as profit + commission + storage |
commission |
Commission value exported with 2 digits after the decimal point |
storage |
Swap/storage value exported with 2 digits after the decimal point |
comment |
Trade comment |
digits |
Symbol digits |
expiration |
Expiration time exported as UTC datetime string |
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.
Default Export Layouts¶
If select is omitted or empty, the export layout depends on tradeType.
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¶
{
"groupFilter": "*",
"tradeType": 1,
"format": "csv",
"select": ["order", "login", "symbol", "open_time", "volume", "profit", "net_profit"],
"total": ["volume", "profit", "net_profit"],
"where": [],
"whereNot": [],
"orderBy": [["open_time", "DESC"]]
}
Response Parameters¶
| Name | Type | Description |
|---|---|---|
file_name |
string | Generated file name stored in storage/ |
Successful Response Example¶
{
"file_name": "550e8400-e29b-41d4-a716-446655440000.csv"
}
Notes¶
format = "csv"generates a.csvfileformat = "excel"generates a.xlsxfile- the response does not include a host or absolute URL, only the file name with extension
- the file can then be downloaded from the server storage route using the returned name
- if
selectis omitted or passed as an empty array, the default layout fortradeTypeis used - exported values follow the same order as the selected columns
- prices are formatted using
TradeRecord::digits - finance amounts are formatted with 2 decimal places
- totals are formatted with up to 2 decimal places
- exported datetimes use
dd.mm.yyyy HH:MM:SS - exported column headers are human-readable, for example
Order typeinstead oforder_type
Errors¶
| Code | Description |
|---|---|
| 400 | Invalid request payload or unsupported field in select |
| 500 | Export directory creation or file write failed |