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.
The group field is resolved from the trade account by login
(AccountRecord.group). It is not stored on the trade record itself.
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 |
orWhere |
array | No | OR comparison group in [[field, operator, value], ...] format; at least one condition must match |
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 |
dateTimeFormat |
string | No | Output mask for all exported datetime values (open_time, creation_time, close_time, expiration, update_time), 1–64 bytes, for example YYYY.MM.DD HH:mm:ss. If omitted, the default format DD.MM.YYYY HH:mm:ss is used. See Datetime Format Mask |
group can be used in where, orWhere, whereNot, whereIn, whereNotIn, range
filters, and orderBy.
Access Scope¶
For staff sessions, the request groupFilter only narrows the exported set. The server also applies the current cached manager scope: access_backoffice, see_trades, groups, and brand. Export totals are calculated after this visibility filter. Token payload is used only to resolve the manager id and session type.
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 |
group |
Trading group of the account that owns the trade |
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.
Datetime Format Mask¶
dateTimeFormat uses moment.js-style tokens. Tokens are case-sensitive.
| Token | Value | Example |
|---|---|---|
YYYY |
4-digit year | 2026 |
YY |
2-digit year | 26 |
MM |
Month, 01–12 | 10 |
DD |
Day of month, 01–31 | 13 |
HH |
Hour, 00–23 | 09 |
mm |
Minute, 00–59 | 30 |
ss |
Second, 00–59 | 41 |
- any character that is not a Latin letter (
.,-,/,:, space, and so on) is written as is - any other Latin letter or token, for example
T,Y,YYYYYorMMM, causes400 INVALID_DATAwith messageunsupported dateTimeFormat - a non-string value, an empty string or a value longer than 64 bytes causes
400 INVALID_DATAwith the request validation message - datetime values are always formatted in UTC; the mask changes only the representation
- without
dateTimeFormatdatetimes keep the trade export defaultDD.MM.YYYY HH:mm:ss, which differs from the account export default - empty datetime values (
0) are exported as an empty cell - the mask is applied to both
csvandexcelexports; in Excel the value is written as a text cell - the
Total:row is not affected
Example: open_time = 1791883841 with dateTimeFormat = "YYYY-MM-DD HH:mm" is exported as 2026-10-13 09:30.
Default Export Layouts¶
If select is omitted or empty, the export layout depends on tradeType.
Open trades¶
Order Symbol Login Group Order type Volume Open time Open price Market price Profit Net profit Sl Tp Commission Swap Comment
Closed trades¶
Order Symbol Login Group Order type Volume Open time Open price Close time Close price Profit Net profit Sl Tp Commission Swap Comment
Pending trades¶
Order Symbol Login Group Order type Volume Open time Activation price Market price Sl Tp Expiration Comment
Finance trades¶
Transaction Login Group 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", "group", "symbol", "open_time", "volume", "profit", "net_profit"],
"total": ["volume", "profit", "net_profit"],
"where": [["group", "like", "real"]],
"whereNot": [],
"orderBy": [["open_time", "DESC"]],
"dateTimeFormat": "YYYY.MM.DD HH:mm:ss"
}
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 UTC
DD.MM.YYYY HH:mm:ss, or thedateTimeFormatmask when it is passed - exported column headers are human-readable, for example
Order typeinstead oforder_type
Errors¶
| Code | Description |
|---|---|
| 400 | Invalid request payload, unsupported field in select, or unsupported dateTimeFormat |
| 500 | Export directory creation or file write failed |