Web Service API Free Forex Trade Copier for MT4, MT5, cTrader, FXCM and LMax

Trade Copier Web API Documentation

Access to our advanced technology through a RESTful API.

Use our Trade Copier Web Service API to develop your website as a white label or gain access to your cockpit. You would use our technology, but you would host the Cockpit on your own website.

1. Connection

Duplikium offers a Web Service API to manage your cockpit.

How to connect to the Web Service API:

  • Auth-Token: an Auth-Token is required to connect to the Web Service API. If you reach the minimum requirements, and you don't have an Auth-Token yet, you can request it to our support team at This email address is being protected from spambots. You need JavaScript enabled to view it.
  • Auth-Username: the Auth-Username is your cockpit username
  • Web Service URL address: https://www.trade-copier.com/webservice/
  • In your request, you must include your Auth-Username AND Auth-Token in the request Headers.
  • Only connection through SSL is supported.

2. Accounts

Get a full list of your account(s) existing in your Trade Copier cockpit

URL: https://www.trade-copier.com/webservice/account/getAccounts.php
The request may specify an optional filter object containing the account_id that you want to select. If the filter is empty or absent, it select all your accounts.

Response: JSON object list

Field NameField TypeField Description
account_id string Unique identifier of the account
type string 0=Master or 1=Slave
name string Custom account name
broker string mt4, mt5, ctrader, fxcm_fc or lmax (always in lower case)
login string Your broker account login
server string MT4: IG-DEMO, FxPro.com-Real02, Ava-Real 1, etc.
MT5: ActivTrades-Server, Binary.com-Server, FxPro-MT5, etc.
cTrader: leave blank
LMax Demo: https://web-order.london-demo.lmax.com
LMax Live: https://api.lmaxtrader.com
FXCM_FC: http://www.fxcorporate.com/Hosts.jsp
environment string Real or Demo
status string The account is 0=disabled, 1=enabled
state string Last state of the account: CONNECTED, DISCONNECTED, WRONG_CREDENTIALS, FAILED_MARGIN, ...
group string One of your existing group name or it can be empty.
subscription string Subscription name (Free V2, Light, Unlimited, Unlimited Pack (5), ...) and its expiration date.
pending string Copy pending order is 0=disabled, 1=enabled
stop_loss string Copy StopLoss is 0=disabled, 1=enabled
take_profit string Copy TakeProfit is 0=disabled, 1=enabled
comment string Custom comment that appears in MT4, MT5 and cTrader  terminal trade comment. Only for MT4, MT5 and cTrader
alert_email string Send warning email is 0=disabled, 1=enabled
alert_sms string Send warning sms is 0=disabled, 1=enabled
balance string Updated after each trade and every 5 minutes. Balance should be used carefully since it is not updated regularly
equity string Updated after each trade and every 5 minutes. Equity should be used carefully since it is not updated regularly
free_margin string Updated after each trade and every 5 minutes. FreeMargin should be used carefully since it is not updated regularly
credit string Updated after each trade and every 5 minutes. Credit should be used carefully since it is not updated regularly
ccy string Account currency
mode string Accounting type: 0: Hedging, 1:Netting

PHP example


<?php

    $url="https://www.trade-copier.com/webservice/account/getAccounts.php";
    $headers =  array(
        'Content-Type: application/x-www-form-urlencoded',
        'Auth-Username: username',
        'Auth-Token: key',
    );

    // Open connection
    $ch = curl_init();

    // Setting the options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $filter = ['account_id' => '29516'];
    //$filter = [];

    curl_setopt($ch, CURLOPT_POST, count($filter));
    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 existing account(s) list
    if(array_key_exists('accounts', $json))
    {
        echo "Accounts list:<BR>";
        foreach($json->accounts as $account)
        {
            echo $account->account_id." ".$account->name." ".$account->login." ".$account->server." ".$account->state."<BR>";
        }
    }
    else
    {
        //This is an error message that can be access like this:
        //echo $json->code." ".$json->error;
        echo json_encode($json);
    }

?>

Add a Master or a Slave account in your Trade Copier cockpit

URL: https://www.trade-copier.com/webservice/account/addAccount.php

Response: JSON object with the account_id unique identifier

Field NameField TypeField Description
type string 0=Master or 1=Slave
name string Custom account name
broker string mt4, mt5, ctrader, fxcm_fc or lmax (always in lower case)
login string Your broker account login
password string Your broker account password
server string MT4: IG-DEMO, FxPro.com-Real02, Ava-Real 1, etc.
MT5: ActivTrades-Server, Binary.com-Server, FxPro-MT5, etc.
cTrader: leave blank
LMax Demo: https://web-order.london-demo.lmax.com
LMax Live: https://api.lmaxtrader.com
FXCM_FC: http://www.fxcorporate.com/Hosts.jsp
environment string Real or Demo
status string The account is 0=disabled, 1=enabled
group string One of your existing group name or it can be empty.
subscription string Subscription name (Free V2, Light, Unlimited, Unlimited Pack (5), ...) and its expiration date
['name' => 'Unlimited Pack (5)', 'expiration_date' => '2019-03-10 19:10:43']
or "auto" => this automatically select an available subscription for this account.
pending string Copy pending order is 0=disabled, 1=enabled
stop_loss string Copy StopLoss is 0=disabled, 1=enabled
take_profit string Copy TakeProfit is 0=disabled, 1=enabled
comment string Custom comment that appears in MT4, MT5 and cTrader  terminal trade comment. Only for MT4, MT5 and cTrader
alert_email string Send warning email is 0=disabled, 1=enabled
alert_sms string Send warning sms is 0=disabled, 1=enabled
     

PHP example


<?php

	$url="https://www.trade-copier.com/webservice/account/addAccount.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);
	
	// 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);

	//We define the Risk Factor's group, you can get the existing groups with the "getGroups.php" webservice
	$group = '2Lots';//Group's name
	//$group = '';//No group
	
	//We define the subscription for the account, you can get available subscriptions with the "getSubscriptions.php" webservice
	$subscription = 'auto';//Automaticaly select an available subscription
	//$subscription = ['name' => 'Unlimited Pack (5)', 'expiration_date' => '2019-03-10 19:10:43'];//Subscription's name and expiration_date
	//$subscription = '';//No subscription
	
		
	// Adding data to POST
	$account = [
	  'type' => 1,//0=Master, 1=Slave
	  'name' => 'name',//Custom name for your account
	  'broker' => 'mt4',//mt4, mt5, ctrader, lmax, fxcm_fc
	  'login' => 'login12',
	  'password' => 'password',
	  'server' => 'fxpro.com',
	  'environment' => 'Demo', //Demo, Real
	  'status' => '0',//The account is 0=disabled, 1=enabled
	  'group' => $group,//Always an EMPTY string for Master
	  'subscription' => $subscription,//Always an EMPTY string for Master.
	  'pending' => '0',//0=disabled, 1=enabled
	  'stop_loss' => '0',//0=disabled, 1=enabled
	  'take_profit' => '0',//0=disabled, 1=enabled
	  'comment' => '',//Custom comment that appears in MT4 terminal trade comment. Only for MT4.
	  'alert_email' => '0',//0=disabled, 1=enabled
	  'alert_sms' => '0'//0=disabled, 1=enabled
	];

	//echo http_build_query($account);
	
	curl_setopt($ch, CURLOPT_POST, count($account));
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($account));
			
	// Execute request
	$json = json_decode(curl_exec($ch));

	// Close connection
	curl_close($ch);

	if(array_key_exists('account', $json))
	{
		//We access the added account data
		echo "New account added: ".$json->account->account_id." ".$json->account->name.
		" ".$json->account->login." ".$json->account->server;
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}
?>
                                                        

To update a Master or Slave account of your Trade Copier cockpit

URL: https://www.trade-copier.com/webservice/account/updateAccount.php

Response: JSON object with the account_id unique identifier

Fields noted with a * are optional

Field NameField TypeField Description
account_id string Account ID of the account that you want to delete
type* string 0=Master or 1=Slave
name* string Custom account name
broker* string mt4, mt5, ctrader, fxcm_fc or lmax (always in lower case)
login* string Your broker account login
password* string Your broker account password
server* string MT4: IG-DEMO, FxPro.com-Real02, Ava-Real 1, etc.
MT5: ActivTrades-Server, Binary.com-Server, FxPro-MT5, etc.
cTrader: leave blank
LMax Demo: https://web-order.london-demo.lmax.com
LMax Live: https://api.lmaxtrader.com
FXCM_FC: http://www.fxcorporate.com/Hosts.jsp
environment* string Real or Demo
status* string The account is 0=disabled, 1=enabled
group* string One of your existing group name or it can be empty.
subscription* string Subscription name (Free V2, Light, Unlimited, Unlimited Pack (5), ...) and its expiration date
['name' => 'Unlimited Pack (5)', 'expiration_date' => '2019-03-10 19:10:43']
"auto" => this automatically select an available subscription for this account.
pending* string Copy pending order is 0=disabled, 1=enabled
stop_loss* string Copy StopLoss is 0=disabled, 1=enabled
take_profit* string Copy TakeProfit is 0=disabled, 1=enabled
comment* string Custom comment that appears in MT, MT5 and cTrader  terminal trade comment. Only for MT4, MT5 and cTrader
alert_email* string Send warning email is 0=disabled, 1=enabled
alert_sms* string Send warning sms is 0=disabled, 1=enabled
     

PHP example


<?php

	$url="https://www.trade-copier.com/webservice/account/updateAccount.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// 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);

	//If needed, we update the Risk Factor's group, you can get the existing groups with the "getGroups.php" webservice
	$group = '2Lots';//Group's name
	//$group = '';//No group
	
	//If needed, we update the subscription for the account, you can get available subscriptions with the "getSubscriptions.php" webservice
	$subscription = 'auto';//Automaticaly select an available subscription
	//$subscription = ['name' => 'Free v1', 'expiration_date' => '0000-00-00 00:00:00'];
	//$subscription = "";//NULL string to remove the subscription
	
	// Account data to be updated
	$account = [
	  'account_id' => '41613',//Mandatory
	  'name' => 'nameZZ',
	  'broker' => 'mt4',//mt4, mt5, ctrader, lmax, fxcm_fc
	  'login' => 'login111',
	  'password' => 'password',
	  'group' => $group,
	  'subscription' => $subscription,
	  'alert_sms' => '0'
	];

	curl_setopt($ch, CURLOPT_POST, count($account));
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($account));
			
	// Execute request
	$json = json_decode(curl_exec($ch));

	// Close connection
	curl_close($ch);

	//We access the updated account data
	if(array_key_exists('account', $json))
	{
		//We access the added account data
		echo "Account ".$json->account->account_id." updated: ".$json->account->name." ".$json->account->login." ".$json->account->server;
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}
?>
                                                        

To delete a Master or Slave account from your Trade Copier cockpit

URL: https://www.trade-copier.com/webservice/account/deleteAccount.php

Response: JSON object with the account_id unique identifier

Field NameField TypeField Description
account_id string Account ID of the account that you want to delete

PHP example


<?php

	$url="https://www.trade-copier.com/webservice/account/deleteAccount.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// 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);

	// Account ID to be removed
	$account = [
	  'account_id' => '41607'
	];

	curl_setopt($ch, CURLOPT_POST, count($account));
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($account));
			
	// Execute request
	$json = json_decode(curl_exec($ch));
	
	// Close connection
	curl_close($ch);
	
	if(array_key_exists('account', $json))
	{
		//We access the deleted account data
		echo "Account ".$json->account->account_id." has been deleted!";
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}

?>
                                                        

Get a full list of servers name that you can use based on your broker/technology

URL: https://www.trade-copier.com/webservice/account/getServersList.php
The request must contain a filter object containing the broker/technology for which you want to get the possible server name. It can be "mt4", "mt5", "fxcm_fc", "lmax", etc.

Response: JSON array

Field NameField TypeField Description
servers array Servers name array

PHP example


<?php

	$url="https://www.trade-copier.com/webservice/account/getServersList.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	$filter = ['broker' => 'mt4'];//mt4, mt5, lmax, fxcm_fc,...

	curl_setopt($ch, CURLOPT_POST, count($filter));
	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 existing account(s) list
	if(array_key_exists('servers', $json))
	{
		echo "Servers list:";
		foreach($json->servers as $server)
		{
			echo $server."";
		}
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}

?>
                                                        

3. Subscriptions

Get a full list of your active subscriptions

URL: https://www.trade-copier.com/webservice/subscription/getSubscriptions_v2.php

Response: JSON object {"subscriptions":"..." }:
Example: {"subscriptions":[{"name":"Flexible Pack","available":"1","expiration_date":"2019-03-10 19:10:43"},{"name":"Free v2","available":"1","expiration_date":"0000-00-00 00:00:00"}]}

Field NameField TypeField Description
subscriptions JSON object list  
-> name string Name of the subscription
-> expiration_date string Expiration date of the subscription
-> type string Subscription type. 0:master, 1:slave, 2:prepay, 3:add-on, 4:accounts (flexible pack)
->price string Subscription price
-> available_accounts string Number of remaining Slave and/or Master that you can add with this subscription
-> available_slaves string Number of remaining Slave that you can add with this subscription
-> available_masters string Number of remaining Master that you can add with this subscription
-> equinix string 0 = not available, 1 = available

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/subscription/getSubscriptions_v2.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	// Execute request
	$json = json_decode(curl_exec($ch));

	// Close connection
	curl_close($ch);
	
	//We access the existing Slaves subscription(s) list
	if(array_key_exists('subscriptions', $json))
	{
		echo '<table id="api_data">';
		
			foreach($json->subscriptions as $row) {
				foreach($row as $key => $val) {
					echo '<th>'.$key.'</th>';
				}
				break;
			}
			
			foreach($json->subscriptions as $subscription)
			{
				echo '<tr>';			
					foreach($subscription 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);
	}

?>
                                                        

4. Slave/Group Settings

Get a full list of your Slave/Group Settings' existing in your trade copier cockpit

URL: https://www.trade-copier.com/webservice/settings/getSettings.php
The request may specify an optional filter object containing the slave_id/group_id and/or master_id

Response: JSON object list
Repsonse is a "settingslist" array of Slave/Group Settings optionally filtered by slave_id/group_id and/or master_id

Field NameField TypeField Description
slave_id string Slave account_id
group_id string Group id
master_id string Master account_id
risk_factor_value string Risk Factor value
risk_factor_type string Risk Factor type:
0: Auto Risk (Equity)
1: Auto Risk (Balance)
2: Auto Risk (Free Margin)
3: Multiplier (Notional)
11: Multiplier (Lot)
4: Fixed Lot
10: Fixed Units
5: Fixed Leverage (Equity)
6: Fixed Leverage (Balance)
7: Fixed Leverage (Free Margin)
max_order_size string Max order size in lot/volume
copier_status string -1=Close Only, 0=Frozen, 1=On, 2=Open Only

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/settings/getSettings.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	// slave_id and master_id filter
	$filter = [
	  //'slave_id' => '29516',//Optional => Not defined to show the settings for all your Slaves
	  'group_id' => '3626',//Optional =>  Not defined to show the settings for all your Groups
	  //'master_id' => '',//Optional => Not defined to show the settings for all your Masters or emtpy String for settings that apply to "all your Masters"
	];

	curl_setopt($ch, CURLOPT_POST, count($filter));
	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 existing symbolssetting(s) list
	if(array_key_exists('settingslist', $json))
	{
		echo '<table id="api_data">';
		
			foreach($json->settingslist as $row) {
				foreach($row as $key => $val) {
					echo '<th>'.$key.'</th>';
				}
				break;
			}
			
			foreach($json->settingslist as $setting)
			{
				echo '<tr>';			
					foreach($setting 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);
	}

?>
                                                        

Set (add, update or remove) an Slave/Group Settings' list

URL: https://www.trade-copier.com/webservice/settings/setSettings.php
request: array of Slave/Group Settings object

Response: JSON object list with success code 200

Field NameField TypeField Description
slave_id string Slave account_id or not defined if you define a group_id
group_id string Group id or not defined if you define a slave_id
master_id string Master account_id or not defined if you want it to be applied to all your Masters
risk_factor_value string Risk Factor value or not defined
risk_factor_type string Risk Factor type:
0: Auto Risk (Equity)
1: Auto Risk (Balance)
2: Auto Risk (Free Margin)
3: Multiplier (Notional)
11: Multiplier (Lot)
4: Fixed Lot
10: Fixed Units
5: Fixed Leverage (Equity)
6: Fixed Leverage (Balance)
7: Fixed Leverage (Free Margin)
max_order_size string Max order size in lot/volume or not defined
copier_status string -1=Close Only, 0=Frozen, 1=On, 2=Open Only or not defined

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/settings/setSettings.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	// Slave/Group Settings list to be added, updated or removed
	$settings = [
	  ['slave_id' => '29524', 'master_id' => '33934', 'risk_factor_value' => '0.11', 'risk_factor_type' => '3', 'max_order_size' => '1.23', 'copier_status' => '0'],
	  ['slave_id' => '29524', 'risk_factor_value' => '0.99', 'risk_factor_type' => '4', 'max_order_size' => '0.12', 'copier_status' => '1'],
	  ['group_id' => '4735', 'risk_factor_value' => '1.02', 'risk_factor_type' => '5', 'max_order_size' => '0.12'],
	];

	curl_setopt($ch, CURLOPT_POST, count($settings));
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($settings));
	
	// Execute request
	$json = json_decode(curl_exec($ch));

	// Close connection
	curl_close($ch);
	
	//If updated is successful, we use the getRiskFactors webservice to check the new value
	if(array_key_exists('success', $json))
	{
		echo $json->code."-".$json->success;
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}

?>
                                                        

5. Symbol Settings

Get a full list of your Symbol Settings existing in your Trade Copier cockpit

URL: https://www.trade-copier.com/webservice/settings/getSymbolSettings.php
The request may specify an optional filter object containing the slave_id, group_id, master_id, symbol and/or symbol_master filters

Response: JSON object list
repsonse is a "symbolsettingslist" array of SymbolSettings optionally filtered by slave_id, group_id, master_id, symbol and/or symbol_master

Field NameField TypeField Description
slave_id string Slave account_id
group_id string Group_id
master_id string Master account_id
symbol string The slave or group symbol
symbol_master string The master symbol

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/settings/getSymbolSettings.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);
	
	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	// slave_id, group_id, master_id, symbol and/or symbol_master filters
	$filter = [
		//'slave_id' => '29524',//Optional => Not defined to show the settings for all your Slaves
		//'group_id' => '538',//Optional =>  Not defined to show the settings for all your Groups		
		//'master_id' => '33934',//Optional => Not defined to show the settings for all your Masters or emtpy String for settings that apply to "all your Masters"	
		//'symbol' => 'XAUUSD',//Optional => Not defined for all
	    //'symbol_master' => 'GOLD',//Optional => Not defined for all
	];

	curl_setopt($ch, CURLOPT_POST, count($filter));
	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 existing symbolssetting(s) list
	if(array_key_exists('symbolsettingslist', $json))
	{
		echo '<table id="api_data">';
		
			foreach($json->symbolsettingslist as $row) {
				foreach($row as $key => $val) {
					echo '<th>'.$key.'</th>';
				}
				break;
			}
			
			foreach($json->symbolsettingslist as $setting)
			{
				echo '<tr>';			
					foreach($setting 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);
	}

?>
                                                        

Set (add, update or remove) a SymbolSettings' list

URL: https://www.trade-copier.com/webservice/settings/setSymbolSettings.php
request: array of SymbolSettings object

Response: JSON object list with success code 200

Field NameField TypeField Description
slave_id string Slave account_id or not defined if you define a group_id
group_id string Group id or not defined if you define a slave_id
master_id string Master account_id or not defined if you want it to be applied to all your Masters
symbol string The slave or group symbol or not defined
symbol_master string The master symbol or not defined if you do no define a master_id neither
risk_factor_value string Risk Factor value or not defined
risk_factor_type string Risk Factor type:
0: Auto Risk (Equity)
1: Auto Risk (Balance)
2: Auto Risk (Free Margin)
3: Multiplier (Notional)
11: Multiplier (Lot)
4: Fixed Lot
10: Fixed Units
5: Fixed Leverage (Equity)
6: Fixed Leverage (Balance)
7: Fixed Leverage (Free Margin)
max_order_size string Max order size in lot/volume or not defined
copier_status string -1=Close Only, 0=Frozen, 1=On, 2=Open Only or not defined

PHP example


<?php
	
	echo "<link rel='stylesheet' type='text/css' href='http://www.trade-copier.com/webservice/example.css'>";
	
	$url="https://www.trade-copier.com/webservice/settings/setSymbolSettings.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	// SymbolSettings list to be added or updated
	// To remove a SymbolSettings, please define (slave_id or group_id) and (symbol and/or (symbol_master and master_id)) and leave empty risk_factor_type, risk_factor_value, max_order_size and copier_status
	$riskFactors = [
	  [	
		'slave_id' => '29524',
		//'group_id' => '538', 
		'master_id' => '43765',
		'symbol' => 'EURUSD',
		'symbol_master' => 'EURUSDi',
		'risk_factor_type' => '7',
		'risk_factor_value' => '0.11',		
		//'max_order_size' => '1.23',
		'copier_status' => '1'
	  ],
	  [	
		//'slave_id' => '29524',
		'group_id' => '538',
		//'master_id' => '44625',
		'symbol' => 'GOLD',
		//'symbol_master' => '',
		//'risk_factor_type' => '4',
		//'risk_factor_value' => '0.99',
		//'max_order_size' => '3.21',
		'copier_status' => '0'
	  ],
	];

	curl_setopt($ch, CURLOPT_POST, count($riskFactors));
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($riskFactors));
	
	// Execute request
	$json = json_decode(curl_exec($ch));

	// Close connection
	curl_close($ch);
	
	//We check if the request is successful
	if(array_key_exists('success', $json))
	{
		echo $json->code."-".$json->success;
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}

?>
                                                        

6. Global Protection

Get a full list of your Slave(s) Global Protection

URL: https://www.trade-copier.com/webservice/protection/getGlobalProtection.php
request: the request may specify an optional filter object containing the slave_id(s)

Response: JSON object list with success code 200

Field NameField TypeField Description
slave_id string Slave account_id
takeprofit_status string 0=disabled, 1=enabled
takeprofit_type string Protection type:
0: CloseOnly
1: SellOut
2: Frozen
takeprofit_value string Equity value above which it will trigger the GlobalProtection
stoploss_status string 0=disabled, 1=enabled
stoploss_type string Protection type:
0: CloseOnly
1: SellOut
2: Frozen
stoploss_value string Equity value below which it will trigger the GlobalProtection

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/protection/getGlobalProtection.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	$filter = ['slave_id' => '29524'];//Optional => Not defined to show the settings for all your Slaves

	curl_setopt($ch, CURLOPT_POST, count($filter));
	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 existing account(s) list
	if(array_key_exists('globalprotections', $json))
	{
		echo "Global Protection list:<BR>";
		echo '<table id="api_data">';
			
			echo '<th>slave_id</th><th>stoploss_status</th><th>stoploss_type</th><th>stoploss_value</th><th>takeprofit_status</th><th>takeprofit_type</th><th>takeprofit_value</th>';
			
			foreach($json->globalprotections as $protection)
			{
				echo '<tr>';
					echo '<td>'.$protection->slave_id.'</td><td>'.$protection->stoploss_status.'</td><td>'.$protection->stoploss_type.'</td><td>'.$protection->stoploss_value.'</td><td>'.$protection->takeprofit_status.'</td><td>'.$protection->takeprofit_type.'</td><td>'.$protection->takeprofit_value.'</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);
	}

?>
                                                        

Set (add, update or remove) the Global StopLoss and/or TakeProfit to protect the account equity.

URL: https://www.trade-copier.com/webservice/protection/setGlobalProtection.php
request: array of Slave(s) GlobalProtection object

Response: JSON object list with success code 200

Field NameField TypeField Description
slave_id string Slave account_id
takeprofit_status string 0=disabled, 1=enabled
takeprofit_type string Protection type:
0: CloseOnly
1: SellOut
2: Frozen
takeprofit_value string Equity value above which it will trigger the GlobalProtection
stoploss_status string 0=disabled, 1=enabled
stoploss_type string Protection type:
0: CloseOnly
1: SellOut
2: Frozen
stoploss_value string Equity value below which it will trigger the GlobalProtection

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/protection/setGlobalProtection.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	// Slave(s) GlobalProtection list to be added, updated or removed
	$protections = [
	  ['slave_id' => '29517', 'stoploss_status' => '0', 'stoploss_type' => '0', 'stoploss_value' => '5000', 'takeprofit_status' => '1', 'takeprofit_type' => '3', 'takeprofit_value' => '3000'],
	  ['slave_id' => '29524', 'stoploss_status' => '0', 'stoploss_type' => '1', 'stoploss_value' => '6000', 'takeprofit_status' => '1', 'takeprofit_type' => '2', 'takeprofit_value' => '4000'],
	  ['slave_id' => '30649', 'stoploss_status' => '0', 'stoploss_type' => '2', 'stoploss_value' => '7000', 'takeprofit_status' => '1', 'takeprofit_type' => '1', 'takeprofit_value' => '5000'],
	];

	curl_setopt($ch, CURLOPT_POST, count($protections));
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($protections));
	
	// Execute request
	$json = json_decode(curl_exec($ch));

	// Close connection
	curl_close($ch);
	
	//If updated is successful, we use the getRiskFactors webservice to check the new value
	if(array_key_exists('success', $json))
	{
		echo $json->code."-".$json->success;
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}

?>
                                                        

7. Groups

Get a full list of your Groups of Risk Factor(s) existing in your trade copier cockpit

URL: https://www.trade-copier.com/webservice/group/getGroups.php

Response: JSON object list

Field NameField TypeField Description
group_id string Group id
name string Group name

PHP example


<?php

	$url="https://www.trade-copier.com/webservice/group/getGroups.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	// Execute request
	$json = json_decode(curl_exec($ch));

	// Close connection
	curl_close($ch);

	//We access the existing group(s) list
	if(array_key_exists('groups', $json))
	{
		echo "Groups list:<BR>";
		foreach($json->groups as $group)
		{
			echo $group->group_id." - ".$group->name."<BR>";
		}
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}

?>
                                                        

8. Positions

Get open positions filtered by "account_id", "from" and/or "to" date

URL: https://www.trade-copier.com/webservice/position/getOpenPositions.php
The request may specify an optional filter object containing the account_id, from and/or to date

Response: JSON object

Field NameField TypeField Description
account_id string Unique identifier of the "Slave" account
master_id string Unique identifier of the "Master" account
ticket string Trade identifier (is not globally unique, but it is unique per account_id)
ticketMaster string Master trade identifier. If equal to the ticket, it is a manual trade
openTime string Trade open time
side string Can be Buy, Sell, BuyLimit, SellLimit, BuyStop and SellStop
symbol string Instrument name
openPrice string  
stopPrice string  
limitPrice string  
stopLoss string  
takeProfit string  
amountLot string Amount expressed in lot, can vary from one broker/technology to another
quantityCcy string Quantity expressed in the account currency
swapCcy string Swap expressed in the account currency
ccy string Account currency

PHP example


<?php

	$url="https://www.trade-copier.com/webservice/position/getOpenPositions.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	
	$filter = ['account_id' => '42169', 'from' => '2017-06-09 09:48:58', 'to' => '2017-06-19 20:00:46'];
	//$filter = ['account_id' => '42169', 'from' => '2017-06-01 09:37:57'];
	//$filter = ['account_id' => '42169'];
	//$filter = [];

	curl_setopt($ch, CURLOPT_POST, count($filter));
	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 open position(s) list
	if(array_key_exists('positions', $json))
	{
		echo "Open Positions list:<BR>";
		foreach($json->positions as $position)
		{
			echo $position->account_id." ".$position->ticket." ".$position->openTime." ".$position->side." ".$position->amountLot." ".$position->symbol." ".$position->openPrice." ".$position->stopPrice." ".$position->limitPrice." ".$position->stopLoss." ".$position->takeProfit."<BR>";
		}
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}

?>
                                                        

Get closed positions filtered by "account_id", "from" and/or "to" date

URL: https://www.trade-copier.com/webservice/position/getClosedPositions.php
The request may specify an optional filter object containing the account_id, from and/or to date

Response: JSON object (a maximum of 1'000 positions can be retrieved per request)

Field NameField TypeField Description
account_id string Unique identifier of the "Slave" account
master_id string Unique identifier of the "Master" account
ticket string Trade identifier (is not globally unique, but it is unique per account_id)
ticketMaster string Master trade identifier. If equal to the ticket, it is a manual trade
openTime string Trade open time
side string Can be Buy, Sell, BuyLimit, SellLimit, BuyStop and SellStop
symbol string Instrument name
openPrice string  
stopPrice string  
limitPrice string  
stopLoss string  
takeProfit string  
closeTime string Trade close time
closePrice string  
amountLot string Amount expressed in lot, can vary from one broker/technology to another
quantityCcy string Quantity expressed in the account currency
profitCcy string Profit expressed in the account currency
swap string Swap expressed in the account currency
ccy string Account currency

PHP example


<?php

	$url="https://www.trade-copier.com/webservice/position/getClosedPositions.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);

	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	
	$filter = ['account_id' => '42169', 'from' => '2017-06-09 09:48:58', 'to' => '2017-06-19 20:00:46'];
	//$filter = ['account_id' => '42169', 'from' => '2017-06-10 09:37:57'];
	//$filter = ['account_id' => '42169'];
	//$filter = [];
	
	curl_setopt($ch, CURLOPT_POST, count($filter));
	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 closed position(s) list
	if(array_key_exists('positions', $json))
	{
		echo "Closed Positions list:<BR>";
		foreach($json->positions as $position)
		{
			echo $position->account_id." ".$position->ticket." ".$position->openTime." ".$position->side." ".$position->amountLot." ".$position->symbol." ".$position->openPrice." ".$position->stopPrice." ".$position->limitPrice." ".$position->stopLoss." ".$position->takeProfit." ".$position->closeTime." ".$position->closePrice." ".$position->profit_ccy." ".$position->ccy."<BR>";
		}
	}
	else
	{
		//This is an error message that can be access like this:
		//echo $json->code." ".$json->error;
		echo json_encode($json);
	}

?>
                                                        

9. Orders

Get orders filtered by "from" and/or "to" date

URL: https://www.trade-copier.com/webservice/position/getOrders.php
The request may specify an optional filter object containing master_id, account_id, error_only, from and/or to date. You can also limit the number of row in the result by adding a limit filter.

Response: JSON object (a maximum of 1'000 orders can be retrieved per request)

Field NameField TypeField Description
timestamp string Date/Time
master_id string Unique identifier of the "Master" account
ticketMaster string Master trade identifier.
account_id string Unique identifier of the "Slave" account
side string Can be Buy, Sell, BuyLimit, SellLimit, BuyStop and SellStop
action string Can be Open, Close, Close_Partial, Cancel and None
symbol string Instrument name
quantityOrder string Quantity requested for the order
stopLoss string StopLoss value of the initial order
takeProfit string TakeProfit value of the initial order
quantityExecuted string Quantity executed for the order
quantityExecutedEUR string Quantity executed expressed in EUR
quantityExecutedUSD string Quantity executed expressed in USD
priceExecuted string Price of the executed order
status_id string Status id code
statusName string Text of the status

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/order/getOrders.php";
	$headers =  array(
		'Content-Type: application/x-www-form-urlencoded',
		'Auth-Username: username',
		'Auth-Token: key',
	);
	
	// Open connection
	$ch = curl_init();

	// Setting the options
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POST, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	
    $filter = ['master_id' => '58989','account_id' => '72496', 'from' => '2019-03-26 09:48:58', 'to' => '2019-04-10 20:00:46'];
	//$filter = ['from' => '2019-03-26 09:48:58', 'to' => '2019-04-10 20:00:46'];
	//$filter = ['from' => '2019-03-26 09:48:58'];
	//$filter = ['to' => '2019-03-27 20:00:46'];
	//$filter = ['error_only' => '0', 'limit' => '10'];
	//$filter = [];
	
	curl_setopt($ch, CURLOPT_POST, count($filter));
	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 closed position(s) list
	if(array_key_exists('orders', $json))
	{
		echo '<table id="api_data">';
			
			echo '<th>timestamp</th><th>master_id</th><th>ticketMaster</th><th>account_id</th><th>side</th><th>action</th><th>symbol</th><th>quantityOrder</th><th>quantityExecuted</th><th>status_id</th><th>statusName</th>';
			
			foreach($json->orders as $order)
			{
				echo '<tr>';
					echo '<td>'.$order->timestamp.'</td><td>'.$order->master_id.'</td><td>'.$order->ticketMaster.'</td><td>'.$order->account_id.'</td><td>'.$order->side.'</td><td>'.$order->action.'</td><td>'.$order->symbol.'</td><td>'.$order->quantityOrder.'</td><td>'.$order->quantityExecuted.'</td><td>'.$order->status_id.'</td><td>'.$order->statusName.'</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);
	}

?>​