Get up to 1000 master orders at a time
Please note: We are storing max 14 weeks of history for the orders, and via the API it was limited to 30 days.
URL: https://www.trade-copier.com/webservice/v4/order/getMasterOrders.php
The request may specify an optional filter object containing parameters to retrieve successful, failed and/or skipped orders, or a start position to search from. You can also limit the number of rows in the result.
Response: JSON object list
| Field Name | Field Type | Field Description |
|---|---|---|
| data | array | |
| timestamp | string | Date/Time |
| name | string | Name of the "Master" account |
| side | string | Combination of side and action. Side can be Buy, Sell, BuyLimit, SellLimit, BuyStop and SellStop; action can be N/A, PendingOpen, PendingModify, PendingCancel, PendingFill, PendingFillToClose, PositionOpen, PositionModify, PositionClosePartial, PositionClose, ProtectionModify, ProtectionFill |
| symbol | string | Instrument name |
| master_ticket | string | Ticket given by broker |
| quantity | float | Quantity requested for the order |
| quantity_usd | float | Quantity requested for the order in USD |
| cnt_success | int | Number of successful slave orders from this master order |
| cnt_fail | int | Number of failed slave orders from this master order |
| cnt_skip | int | Number of skipped slave orders from this master order |
| slave_count | int | Total number of slave orders linked to this master order |
| order_id_master | string | Unique identifier of this master order |
| stopLoss | float | StopLoss value of the initial order |
| takeProfit | float | TakeProfit value of the initial order |
| price | float | Price of the order |
| recordsTotal | int | Total number of master orders you have |
| recordsFIltered | int | Number of results corresponding to your filter. Will have the same value as recordsTotal if no filter is given |
Optional Parameters:
Parameter - Type - Description
fromDate - string - Start date (YYYY-MM-DD or ISO 8601). Max 7-day range with toDate.
toDate - string - Optional end date (defaults to today).
historyDays - int - Alternative to date range. Number of days in the past (1–14).
length - int - Max number of rows to return. Default/max: 10,000.
PHP example
<?php
echo "<link rel='stylesheet' type='text/css' href='https://www.trade-copier.com/webservice/example.css'>";
$url="https://www.trade-copier.com/webservice/v4/order/getMasterOrders.php";
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer [[TOKEN]]',
);
// Open connection
$ch = curl_init();
// Setting the options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Filter can specify a mix of fields, they are all optional
$filter = ['start' => 0, 'length' => 10];
//$filter = ['successOrders' => true, 'failOrders' => false, 'skipOrders' => true];
//$filter = ['start' => 10, 'length' => 300, 'successOrders' => true];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($filter));
// Execute request
$json = json_decode(curl_exec($ch));
// Close connection
curl_close($ch);
//We access the order(s) list
if(array_key_exists('data', $json)) {
echo '<table id="api_data">';
foreach($json->data as $row) {
foreach($row as $key => $val) {
echo '<th>'.$key.'</th>';
}
break;
}
foreach($json->data as $order) {
echo '<tr>';
foreach($order as $key => $val) {
echo '<td>'.$val.'</td>';
}
echo '</tr>';
}
echo '</table>';
} else {
//This is an error message that can be access like this:
//echo $json->code." ".$json->error;
echo json_encode($json);
}
?>