PHP code example of vdbelt / ftx-php

1. Go to this page and download the library: Download vdbelt/ftx-php 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/ */

    

vdbelt / ftx-php example snippets


use FTX\FTX;

// Unauthenticated
$ftx = FTX::create();

// Authenticated
$ftx = FTX::create('key', 'secret');

$markets = $ftx->markets()->all();
$btcPerp = $ftx->markets()->get('BTC-PERP');

$orders = $ftx->onSubaccount('foo')->orders()->open();

$ftx->subaccounts()->all()
$ftx->subaccounts()->create('nickname')
$ftx->subaccounts()->rename('old', 'new')
$ftx->subaccounts()->delete('nickname')
$ftx->subaccounts()->balances('nickname') // Get balances for a specific subaccount
$ftx->subaccounts()->transfer('BTC', 1, 'main', 'nickname') // Transfer funds between subaccounts

$ftx->markets()->all()
$ftx->markets()->get('BTC-PERP')
$ftx->markets()->orderbook('BTC-PERP', 100)
$ftx->markets()->trades('BTC-PERP', 100, new \DateTime('2020-03-01'), new \DateTime('2020-03-01 06:00:00'))
$ftx->markets()->candles('BTC-PERP', 15, 100)

$ftx->futures()->all()
$ftx->futures()->get('BTC-0626')
$ftx->futures()->stats('BTC-0626')
$ftx->futures()->fundingRates()

$ftx->account()->get()
$ftx->account()->positions()
$ftx->account()->changeAccountLeverage(101)

$ftx->wallet()->coins()
$ftx->wallet()->balances()
$ftx->wallet()->allBalances() // Balances accross all subaccounts
$ftx->wallet()->depositAddress('BTC')
$ftx->wallet()->depositAddress('USDT', 'erc20')
$ftx->wallet()->deposits()
$ftx->wallet()->withdrawals()
$ftx->wallet()->createWithdrawalRequest('BTC', 1, 'address')->withdraw()
$ftx->wallet()->createWithdrawalRequest('BTC', 1, 'address')->fees()
$ftx->wallet()->createWithdrawalRequest('BTC', 1, 'address')->withPassword()->withCode()->withTag()->withdraw()

$ftx->orders()->open();
$ftx->orders()->open('BTC-PERP');

// history
$ftx->orders()->history();
$ftx->orders()->history('BTC-PERP')

// Placing orders
// You can either pass the properties of your order directly:
$ftx->orders()->create(['market' => 'BTC-PERP', 'type' => 'market', 'size' => 1])->place();

// or use the fluent api to build up an order:
$ftx->orders()->create()->buy('BTC-PERP')->limit(1, 4000)->place();

// order status
$ftx->orders()->status(123456);

// cancel order
$ftx->orders()->cancel(123456);

// cancel all orders, including conditional orders
$ftx->orders()->cancelAll();
$ftx->orders()->cancelAll('BTC-PERP', $conditionalOrdersOnly = false, $limitOrdersOnly = true)


$ftx->conditionalOrders()->open();
$ftx->conditionalOrders()->open('BTC-PERP', 'take_profit');

//history
$ftx->conditionalOrders()->history();
$ftx->conditionalOrders()->history('BTC-PERP', null, null, 'buy', 'stop', 'market', 10);

// Placing orders
// You can either pass the properties of your order directly:
$ftx->conditionalOrders()->create(['market' => 'BTC-PERP', 'type' => 'takeProfit', 'triggerPrice' => 7000.99, 'size' => 1, 'side' => 'buy', 'reduceOnly' => true])->place();

// or use the fluent api to build up an order:
$ftx->conditionalOrders()->create()->stop($size = 1, $triggerPrice = 7000.99)->buy('BTC-PERP')->reduceOnly()->place();

// order status
$ftx->conditionalOrders()->status(123456);

// cancel order
$ftx->conditionalOrders()->cancel(123456);

// cancel all orders conditional orders
$ftx->conditionalOrders()->cancelAll();
$ftx->conditionalOrders()->cancelAll('BTC-PERP', $conditionalOrdersOnly = true, $limitOrdersOnly = true)

$ftx->fills()->all()

$ftx->fundingPayments()->all()

$ftx->leveragedTokens()->all()
$ftx->leveragedTokens()->info('foo')
$ftx->leveragedTokens()->balances()
$ftx->leveragedTokens()->creationRequests()
$ftx->leveragedTokens()->redemptions()
$ftx->leveragedTokens()->requestCreation('foo', 10)
$ftx->leveragedTokens()->requestRedemption('foo', 10)

$ftx->options()->requests()
$ftx->options()->myRequests()
$ftx->options()->cancelRequest('id')
$ftx->options()->quotesForRequest('id')
$ftx->options()->createQuote('id', 100)
$ftx->options()->myQuotes()
$ftx->options()->cancelQuote('id')
$ftx->options()->acceptQuote('id')
$ftx->options()->accountInfo()
$ftx->options()->positions()
$ftx->options()->trades()
$ftx->options()->fills()
bash
composer 
bash
composer