This repository contains PHP Client for TradeSmarter platform.
TradeSmarter is a trading platform for binary options.
Install using Composer, doubtless.
$ composer require alexander-emelyanov/tradologic-api-client
First, you need to create a client object to connect to the TradoLogic servers. You will need to acquire an API username and API password for your app first from broker, then pass the credentials to the client object for logging in.
$client = new \TradoLogic\ApiClient([
'url' => 'https://b2b-api.tradologic.net',
]);
Assuming your credentials is valid, you are good to go!
/** @var \TradoLogic\Entities\Country[] $countries */
$countries = $client->countries();
/** @var \TradoLogic\Entities\Language[] $languages */
$languages = $client->languages();
For ability to create user your IP should be added to whitelist. So, this operation requires authorization. You should provide username, password and account ID to \TradoLogic\ApiClient constructor. It should seems like this:
$client = new \TradoLogic\ApiClient([
'url' => 'https://b2b-api.tradologic.net',
'username' => '<YOUR_USERNAME>',
'password' => '<YOUR_PASSWORD>',
'accountId' => <YOUR_ACCOUNT_ID>,
]);
Then you can register user.
/** @var \TradoLogic\Responses\UserCreate $response */
$response = $client->createUser(new \TradoLogic\Requests\UserCreate([
'userPassword' => '<USER_PASSWORD>',
'userFirstName' => '<USER_FIRST_NAME>',
'userLastName' => '<USER_LAST_NAME>',
'phone' => '<USER_PHONE>',
'email' => '<USER_EMAIL>',
]));
For redirect user to TradoLogic base website you should get Session ID for this user.
$request = new \TradoLogic\Requests\UserLogin([
'email' => 'alex.emelianov@gmail.com',
'password' => 'portal',
'userIpAddress' => '94.74.194.219',
]);
/** @var $response \TradoLogic\Responses\UserLogin */
$response = $client->loginUser($request);
if ($response->isSuccess()) {
echo ("User logged successfully with Session ID: " . $response->getSessionId() . PHP_EOL);
}
/** @var $response \TradoLogic\Entities\Deposit[] */
$response = $client->deposits();
For trading integration you must get list of active binary options. You can do it really easy:
/** @var \TradoLogic\Entities\Options\Binary[] $options */
$options = $client->getBinaryOptions();
When active binary options are retrieved you can open positions (binary options) for your customers.
$client->createBinaryOption(new \TradoLogic\Requests\BinaryOptionCreate(<User ID>, <Option ID>, <Volume>, <Is Call>));
You can retrieve trades history for specified users.
/**
* @var \TradoLogic\Entities\Trades\Regular[]
*/
$trades = $client->getRegularUserTrades(new \TradoLogic\Requests\RegularUserTradesGet(<User ID>[, <Only open>]));