PHPackages                             alexstewartja/dxtrade-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. alexstewartja/dxtrade-php-sdk

ActiveLibrary[API Development](/categories/api)

alexstewartja/dxtrade-php-sdk
=============================

PHP SDK for DXtrade's Administrative and Trading REST API endpoints

1.0.0(1y ago)10[3 PRs](https://github.com/alexstewartja/dxtrade-php-sdk/pulls)MITPHPPHP ^8.1 || ^8.2 || ^8.3 || ^8.4CI passing

Since May 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/alexstewartja/dxtrade-php-sdk)[ Packagist](https://packagist.org/packages/alexstewartja/dxtrade-php-sdk)[ Docs](https://github.com/alexstewartja/dxtrade-php-sdk)[ Fund](https://www.buymeacoffee.com/alexstewartja)[ GitHub Sponsors](https://github.com/alexstewartja)[ RSS](/packages/alexstewartja-dxtrade-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (6)Used By (0)

[![DXtrade PHP SDK](https://camo.githubusercontent.com/70806f6b10b707c126cbb8d8df74c2b793c6c0bbc2ca462cde85cbacbb1c9594/68747470733a2f2f692e6962622e636f2f6d437051673157702f647874726164652d7068702d73646b2d636f7665722e706e67)](https://camo.githubusercontent.com/70806f6b10b707c126cbb8d8df74c2b793c6c0bbc2ca462cde85cbacbb1c9594/68747470733a2f2f692e6962622e636f2f6d437051673157702f647874726164652d7068702d73646b2d636f7665722e706e67)

DXtrade PHP SDK
===============

[](#dxtrade-php-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/cc1349bd1d2cbef02ed5844b87ec3a1a8b4778eec4c3f87769b061beb3a3fa9c/687474703a2f2f706f7365722e707567782e6f72672f616c6578737465776172746a612f647874726164652d7068702d73646b2f76)](https://packagist.org/packages/alexstewartja/dxtrade-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/fc45709e46f7ad7be534b663ac2b92bf143ded133e4cb48d425900aca0e01280/687474703a2f2f706f7365722e707567782e6f72672f616c6578737465776172746a612f647874726164652d7068702d73646b2f646f776e6c6f616473)](https://packagist.org/packages/alexstewartja/dxtrade-php-sdk)[![License](https://camo.githubusercontent.com/06a84faa59c5cb7c81fcb65d73c4d4919959990bf652495a793de1cae4d8724e/687474703a2f2f706f7365722e707567782e6f72672f616c6578737465776172746a612f647874726164652d7068702d73646b2f6c6963656e7365)](https://packagist.org/packages/alexstewartja/dxtrade-php-sdk)

[![Tests Status](https://camo.githubusercontent.com/40af6da845ee0fdd1567c094689205e3de1ae48983aa4447721d3dcbe0848e38/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c6578737465776172746a612f647874726164652d7068702d73646b2f72756e2d74657374732e796d6c3f6c6162656c3d7465737473)](https://camo.githubusercontent.com/40af6da845ee0fdd1567c094689205e3de1ae48983aa4447721d3dcbe0848e38/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c6578737465776172746a612f647874726164652d7068702d73646b2f72756e2d74657374732e796d6c3f6c6162656c3d7465737473)[![Static Analysis](https://camo.githubusercontent.com/b59d9b4353ae603ccb029651bc47fccefbe2ca323a8c0dc0f2d24a045f2b613d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c6578737465776172746a612f647874726164652d7068702d73646b2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6c6162656c3d636f64652532307374796c65)](https://camo.githubusercontent.com/b59d9b4353ae603ccb029651bc47fccefbe2ca323a8c0dc0f2d24a045f2b613d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c6578737465776172746a612f647874726164652d7068702d73646b2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6c6162656c3d636f64652532307374796c65)

[![PHP Version Required](https://camo.githubusercontent.com/4b3b183ffe17506e7e14c4ec3d554bbd1219096dfa71ed7976cd891c3f298f71/687474703a2f2f706f7365722e707567782e6f72672f616c6578737465776172746a612f647874726164652d7068702d73646b2f726571756972652f706870)](https://packagist.org/packages/alexstewartja/dxtrade-php-sdk)

[![Buy Me A Coffee](https://camo.githubusercontent.com/3ce5cc1c728bf8e0be5bbd132e9d5413d3a922cecfc3381decdcc82c5f66da9b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275795f4d652d415f436f666665652d6f72616e67653f6c6f676f3d6275792d6d652d612d636f66666565)](https://buymeacoffee.com/alexstewartja)

PHP SDK for DXtrade's Administrative and Trading REST API endpoints.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require alexstewartja/dxtrade-php-sdk
```

Usage Examples
--------------

[](#usage-examples)

### Client Setup

[](#client-setup)

First, initialize the DXtrade client:

```
// Create a client in the demo environment
$client = new DXtradeClient(Env::BASE_URL_DEMO);
// Or in a custom/production environment
$prodBaseUrl = 'https://your-production-url.com';
$client = new DXtradeClient($prodBaseUrl);

// With custom Guzzle options
$client = new DXtradeClient(
    $prodBaseUrl,
    null,
    [
        'timeout' => 30,
        'verify' => false,
    ]
);

// If you already have a session token
$client = new DXtradeClient(
    $prodBaseUrl,
    'your-session-token'
);
```

### Administrative API

[](#administrative-api)

The Administrative API provides access to account management, user management, and other administrative functions.

```
// Authentication
$loginRequest = (new LoginRequest())
    ->setUsername('alex')
    ->setDomain('uptrendprop')
    ->setPassword('password123!');
$loginResult = $client->administrative()->authentication()->login($loginRequest);
$sessionToken = $loginResult->getSessionToken(); // Get the session token
// Store the session token for future clients/requests
// OR
// Set the session token on this client
$client->setSessionToken($sessionToken);

// Accounts
$accounts = $client->administrative()->accounts()->getAccounts(); // Get all accounts
$account = $client->administrative()->accounts()->getAccount('clearing_code', 'account_code'); // Get a specific account

// Users
$users = $client->administrative()->users()->getUsers();

// Single Sign-On (SSO)
$ssoToken = $client
    ->administrative()
    ->sso()
    ->generateTokenForm('alex', 'uptrendprop'); // Generate SSO token for a user via HTTP POST

// Brokers
$brokers = $client->administrative()->brokers()->getBrokers();

// Cash Transfers
$adjustment = (new Adjustment())
    ->setAmount(-50.0)
    ->setCurrency('USD')
    ->setDescription('Test debit adjustment');
$transfer = $client->administrative()->cashTransfers()->createAdjustment(
    'clearing_code',
    'account_code',
    uniqid('adj-'),
    $adjustment
);

// Categories
$categories = $client->administrative()->categories()->getCategories();
```

### Trading API

[](#trading-api)

The Trading API provides access to trading operations, market data, and order management.

```
// Authentication
$loginRequest = (new LoginRequest())
    ->setUsername('alex')
    ->setDomain('uptrendprop')
    ->setPassword('password123!');
$loginResponse = $client->trading()->authentication()->login($loginRequest);

// Accounts
$accounts = $client->trading()->accounts()->getAccounts(); // Get all accounts
$eodMetrics = $client
    ->trading()
    ->accounts()
    ->getEodMetricsQuery('2025-04-21', 'uptrendprop:alex,uptrendprop:staff'); // Get End-Of-Day metrics
$portfolios = $client
    ->trading()
    ->accounts()
    ->getAccountPortfolios('uptrendprop:alex', 'account-etag-123'); // Get account portfolios

// Instruments
$instruments = $client->trading()->instruments()->getByType(InstrumentType::CFD_FUTURES); // Get all instruments by type
$instrument = $client->trading()->instruments()->getBySymbol('EUR/USD'); // Get instrument(s) by symbol

// Market Data
$marketEventType = (new MarketEventRequestType())
    ->setType(MarketEventType::CANDLE->value)
    ->setCandleType(CandleType::H4->value)
    ->setFromTime((new DXtradeDateTime('-3 months')))
    ->setToTime((new DXtradeDateTime('now')));
$marketDataRequest = (new MarketDataRequest())
    ->setAccount('uptrendprop:alex')
    ->setSymbols(['EUR/USD'])
    ->setEventTypes([$marketEventType]);
// Get last 3 months of 4-hour candles for EUR/USD
$candles = $client->trading()->marketData()->getMarketData($marketDataRequest);

// Orders
$openOrders = $client->trading()->orders()->getOpenOrders('uptrendprop:alex'); // Get all open orders for an account
// Place limit-short (sell) order of 100 units on EUR/USD if it drops to the $1.08 USD price-point
$orderCode = uniqid('ord-');
$orderRequest = (new SingleOrderRequest())
    ->setOrderCode(uniqid('ord-'))
    ->setType(OrderType::LIMIT->value)
    ->setInstrument('EUR/USD')
    ->setQuantity(100.00)
    ->setSide(OrderSide::SELL->value)
    ->setLimitPrice(1.08);
$limitOrderResponse = $client->trading()->orders()->createOrder('uptrendprop:alex', $orderRequest);
// Cancel an order
$cancelledOrderResponse = $client->trading()->orders()->cancelOrder('uptrendprop:alex', $orderCode);
$orderIsCancelled = ($cancelledOrderResponse->getOrderId() === $limitOrderResponse->getOrderId());

// Conversions
$conversionRate = $client->trading()->conversion()->getConversionRate('USD', 'EUR');
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

A [Lando](https://lando.dev/) file is included in the repo to get up and running quickly:

```
lando start
```

Please see [CONTRIBUTING](CONTRIBUTING.md) for more details.

Security
--------

[](#security)

If you discover any security-related issues, please email [dxtrade@alexstewartja.com](mailto:dxtrade@alexstewartja.com?Subject=DXtrade%20PHP%20SDK) instead of using the issue tracker.

Credits
-------

[](#credits)

- [Alex Stewart](https://github.com/alexstewartja)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance78

Regular maintenance activity

Popularity2

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

369d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/082480752bcdbb416813f3ac88ee08dd199e7b05f535f033128e81a33c651be8?d=identicon)[alexstewartja](/maintainers/alexstewartja)

---

Top Contributors

[![alexstewartja](https://avatars.githubusercontent.com/u/6935309?v=4)](https://github.com/alexstewartja "alexstewartja (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

cfdcryptodxtradeforexfuturestradetradingcryptotradingforextradefuturescfddxtrade

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/alexstewartja-dxtrade-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/alexstewartja-dxtrade-php-sdk/health.svg)](https://phpackages.com/packages/alexstewartja-dxtrade-php-sdk)
```

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

41.5k328.9k1](/packages/ccxt-ccxt)[coinpaymentsnet/coinpayments-php

A PHP wrapper for the CoinPayments.net v1 API.

55126.2k](/packages/coinpaymentsnet-coinpayments-php)[vittominacori/coinmarketcap-php

A PHP wrapper for CoinMarketCap API

2233.1k](/packages/vittominacori-coinmarketcap-php)[kornrunner/ccxt

A PHP cryptocurrency trading library with support for more than 90 bitcoin/altcoin exchanges

371.6k](/packages/kornrunner-ccxt)[jeffreyhyer/alpaca-trade-api-php

PHP SDK for the Alpaca trade API

285.0k](/packages/jeffreyhyer-alpaca-trade-api-php)[klev-o/crypto-pay-api

Simple and convenient implementation of the Crypto Pay payment system (@CryptoBot)

205.1k](/packages/klev-o-crypto-pay-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
