PHP code example of alexander-emelyanov / opteck-api-client

1. Go to this page and download the library: Download alexander-emelyanov/opteck-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alexander-emelyanov / opteck-api-client example snippets


$client = new \Opteck\ApiClient(<Affiliate ID>, <Partner ID>);

/** @var \Opteck\Requests\CreateLead $request */
$request = new \Opteck\Requests\CreateLead([
    'email'       => '[email protected]',
    'password'    => 'qwerty',
    'firstName'   => 'John',
    'lastName'    => 'Smith',
    'language'    => 'EN',
    'country'     => 'GB',
    'phone'       => '442088963321', // Pizza Hut Restaurant
    'campaign'    => 'test_campaign_1',
    'subCampaign' => 'test_sub_campaign_1',
]);

/** @var \Opteck\Responses\CreateLead $response */
$response = $apiClient->createLead($request);

echo "Lead created successfully with ID: " . $response->getLeadId() . PHP_EOL;

/** @var \Opteck\Responses\GetLeadDetails $leadDetails */
$leadDetails = $apiClient->getLeadDetails($email);

/** @var \Opteck\Responses\Auth $authResponse */
$authResponse = $apiClient->auth('[email protected]', 'qwerty');

echo "Lead authorized with token [" . $authResponse->getToken() . "] valid up to " . $authResponse->getExpiryTimestamp() . PHP_EOL;

/** @var \Opteck\Entities\Deposit[] $deposits */
$deposits = $apiClient->getDeposits(time() - 2600 * 24 * 7, time());

/** @var \Opteck\Entities\OptionType[] $optionTypes */
$optionTypes = $apiClient->getOptionTypes();

/** @var \Opteck\Entities\Market[] $markets */
$markets = $apiClient->getMarkets();

/** @var \Opteck\Entities\Asset[] $assets */
$assets = $apiClient->getAssets();

/** @var \Opteck\Responses\GetAssetRate $assetRate */
$assetRate = $apiClient->getAssetRate(<Asset ID>);

$apiClient->openPosition('<Email>', '<Password>', '<Symbol>', <Direction>, <Amount>);

/** \Opteck\Entities\TradeAction[] $tradeActions */
$tradeActions = $apiClient->getTradeActions('<Email>');