alexander-emelyanov/tradologic-api-client

v2.0.2 2016-04-12 11:19 UTC

README

Build Status StyleCI Code Climate

此存储库包含TradeSmarter平台的PHP客户端。

TradeSmarter是一个二元期权交易平台。

安装

使用Composer安装,这是毫无疑问的。

$ composer require alexander-emelyanov/tradologic-api-client

使用方法

首先,您需要创建一个客户端对象以连接到TradoLogic服务器。首先,您需要从经纪人那里获取您的应用的API用户名和API密码,然后将凭据传递给客户端对象进行登录。

$client = new \TradoLogic\ApiClient([
    'url' => 'https://b2b-api.tradologic.net',
]);

假设您的凭据有效,您就可以开始了!

获取国家列表

/** @var \TradoLogic\Entities\Country[] $countries */
$countries = $client->countries();

获取语言列表

/** @var \TradoLogic\Entities\Language[] $languages */
$languages = $client->languages();

创建用户

为了能够创建用户,您的IP应该被添加到白名单中。因此,此操作需要授权。您应该在\TradoLogic\ApiClient构造函数中提供用户名、密码和账户ID。它应该看起来像这样

$client = new \TradoLogic\ApiClient([
    'url' => 'https://b2b-api.tradologic.net',
    'username' => '<YOUR_USERNAME>',
    'password' => '<YOUR_PASSWORD>',
    'accountId' => <YOUR_ACCOUNT_ID>,
]);

然后您可以注册用户。

/** @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>',
]));

用户登录

为了将用户重定向到TradoLogic基本网站,您需要获取该用户的会话ID。

$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();

获取活跃的二元期权

为了进行交易集成,您必须获取活跃的二元期权列表。您可以通过以下方式轻松完成

/** @var \TradoLogic\Entities\Options\Binary[] $options */
$options = $client->getBinaryOptions();

交易

当检索到活跃的二元期权时,您可以为客户开设(二元期权)头寸。

$client->createBinaryOption(new \TradoLogic\Requests\BinaryOptionCreate(<User ID>, <Option ID>, <Volume>, <Is Call>));

交易记录

您可以检索指定用户的交易历史。

/**
 * @var \TradoLogic\Entities\Trades\Regular[]
 */
$trades = $client->getRegularUserTrades(new \TradoLogic\Requests\RegularUserTradesGet(<User ID>[, <Only open>]));