PHP code example of csba92 / revx-php

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

    

csba92 / revx-php example snippets


use Revx\Client;

$client = new Client();

$ticker = $client->market()->ticker('BTC-USD');
$book = $client->market()->orderBook('BTC-USD');

use Revx\Client;

$client = new Client(
    apiKey: $config['revx_api_key'],
    privateKeyPem: $config['revx_private_key'],
);

$balances = $client->account()->balances();
$orders = $client->account()->activeOrders(symbols: ['BTC-USD']);

$client = \Revx\Client::fromEnvironment();

$market = $client->market();

$currencies = $market->currencies(region: 'EEA');
$pairs = $market->pairs(region: 'EEA');

$ticker = $market->ticker('BTC-USD');
$tickers = $market->tickers(['BTC-USD', 'ETH-USD']);

// Interval is expressed in minutes.
$candles = $market->candles('BTC-USD', interval: 60, since: 1735689600000);

// Public order book, with 1–192 levels per side.
$orderBook = $market->orderBook('BTC-USD', limit: 50, region: 'EEA');

$account = $client->account();

$balances = $account->balances();

$active = $account->activeOrders(
    symbols: ['BTC-USD'],
    states: ['new', 'partially_filled'],
    types: ['limit'],
    side: 'buy',
    limit: 100,
);

$history = $account->historicalOrders(
    symbols: ['BTC-USD'],
    states: ['filled', 'cancelled'],
    since: 1735689600000,
    until: 1735776000000,
);

$order = $account->order('venue-order-id');

$trades = $client->trades();

// Public trade history can cover one pair or every pair when symbol is omitted.
$public = $trades->publicHistory(
    symbol: 'BTC-USD',
    since: 1735689600000,
    until: 1735776000000,
    limit: 100,
    region: 'EEA',
);

// Account trade history (your fills) is scoped to a single pair.
$private = $trades->privateHistory('BTC-USD', limit: 100);

// Fills belonging to an individual venue order.
$fills = $trades->fills('7a52e92e-8639-4fe1-abaa-68d3a2d5234b');

$trading = $client->trading();

// Place a limit order.
$placed = $trading->place(
    clientOrderId: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
    symbol: 'BTC-USD',
    side: 'buy',
    configuration: [
        'limit' => [
            'base_size' => '0.001',
            'price' => '95000',
            'execution_instructions' => ['post_only'],
        ],
    ],
);

// A market order uses a market configuration instead.
$marketOrder = $trading->place(
    clientOrderId: '9a0ea5d1-74a5-4cb6-9a5b-d0254ec2c6b1',
    symbol: 'BTC-USD',
    side: 'sell',
    configuration: ['market' => ['base_size' => '0.001']],
);

// Replace only the fields that change. Revolut X assigns the replacement a new venue ID.
$replaced = $trading->replace(
    venueOrderId: '7a52e92e-8639-4fe1-abaa-68d3a2d5234b',
    clientOrderId: 'b7193799-86e5-4062-8d0d-3ed4b980239a',
    changes: ['price' => '96000'],
);

$trading->cancel('7a52e92e-8639-4fe1-abaa-68d3a2d5234b');
$trading->cancelAll();

use Revx\Exception\ApiException;

try {
    $balances = $client->account()->balances();
} catch (ApiException $e) {
    if ($e->status === 429) {
        // Retry only after $e->retryAfter milliseconds when it is supplied.
    }

    throw $e;
}
bash
composer 
bash
composer