Skip to content

Export Trades By Login

ExportTradesByLogin

Description: Exports the full filtered trade list for the authenticated account into a file stored in the server storage directory.

The account login is resolved from the authenticated session. The method does not return trade rows in JSON.

Request Parameters

Name 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 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 trades
  • 1 = open trades
  • 2 = closed trades
  • 3 = pending trades
  • 4 = 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.

  • order
  • login
  • cmd
  • state
  • symbol
  • reason
  • volume
  • open_time
  • close_time
  • open_price
  • close_price
  • sl
  • tp
  • profit
  • net_profit
  • commission
  • storage
  • comment
  • digits
  • expiration

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 select is omitted or passed as an empty array, the default layout for tradeType is used
  • exported values follow the same order as the selected columns
  • volume is exported in display format, divided by 100
  • open_time, close_time, creation_time, and expiration are exported as UTC datetime strings in dd.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_profit is calculated as profit + commission + storage
  • column headers in exported files are human-readable, for example Order type instead of order_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": "excel",
  "select": ["order", "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.xlsx"
}

Notes

  • format = "csv" generates a .csv file
  • format = "excel" generates a .xlsx file
  • the response contains only the generated file name with extension
  • the export always contains the full filtered result set
  • limit and offset are not supported by this method

Errors

Code Description
400 Invalid request payload or unsupported field in select
400 Authenticated account is not available
500 Export directory creation or file write failed