Get Trades By Filter
MngGetTradesByFilter¶
Description: Returns a filtered list of trades for managers. Supports pagination, tradeType, optional where/whereNot, and optional orderBy sorting.
Each returned trade row includes group, resolved from the trade account by
login (AccountRecord.group). group is not stored on the trade record
itself.
Request Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
groupFilter |
string | Yes | Group mask to filter trades |
limit |
int | Yes | Max number of records to return |
offset |
int | Yes | Number of records to skip |
tradeType |
int | Yes | Trade type filter in range 0..4 |
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 |
group can be used in where, whereNot, whereIn, whereNotIn, range filters, and orderBy. It is resolved from the account that owns the trade.
net_profit can be used in where, whereNot, whereIn, whereNotIn, range filters, and orderBy as a calculated field. It is calculated as profit + commission + storage.
update_time is available as a normal timestamp field in filters and orderBy. Use it to request trades that were changed by business actions such as open, close, cancel, delete, restore, manual edit, finance operation, or history import. The field is not refreshed by every market tick/profit recalculation.
Partial-close fields are available in filters:
parent_orderlinks aTS_CLOSED_PARThistory record to the original positionclosed_volumeshows accumulated closed volume on the original open positionpartial_close_volumeis normally0, except while a partial-close request is pending
Trade Types¶
0= all trades1= open trades2= closed trades, including partial-close history records withstate = TS_CLOSED_PART3= pending trades4= finance trades
Request Example¶
{
"groupFilter": "*",
"limit": 100,
"offset": 0,
"tradeType": 1,
"where": [["group", "like", "real"]],
"whereNot": [],
"orderBy": [["open_time", "desc"]]
}
Response Parameters¶
| Name | Type | Description |
|---|---|---|
structure |
array | List of trade fields in the result |
rows |
array | List of trades |
count |
int | Total number of trades matched |
total_profit |
double | Cumulative profit |
total_net_profit |
double | Cumulative net profit: profit + commission + storage |
total_storage |
double | Cumulative storage |
total_commission |
double | Cumulative commission |
total_volume |
int | Cumulative volume |
The default structure includes group after login, and includes
net_profit after profit.
Default structure:
[
"order",
"login",
"group",
"cmd",
"state",
"symbol",
"reason",
"volume",
"open_time",
"close_time",
"open_price",
"close_price",
"sl",
"tp",
"profit",
"net_profit",
"commission",
"storage",
"comment",
"digits",
"expiration"
]