Trader PHP is a PHP library that serves as a user-friendly wrapper for the Trader Extension. It provides developers with easy access to a wide range of technical analysis indicators and functions, enabling seamless integration of financial analytics into trading and finance applications.
With support for commonly used indicators like Moving Averages (SMA, EMA), Relative Strength Index (RSI), MACD, and more, this library simplifies the process of building financial tools, algorithmic trading systems, and real-time data analysis platforms.
- Easy-to-use wrapper around PHP’s Trader Extension.
- Support for over 30 technical analysis indicators such as SMA, EMA, RSI, MACD, and more.
- Real-time trading workflows with built-in error handling.
- Ideal for building financial applications, trading bots, and analytics tools.
You can easily install the library using Composer:
composer require timirey/trader-php
Make sure that the PHP Trader Extension is installed and enabled on your PHP setup.
Once installed, you can quickly start using the indicators in your PHP application.
use Trader\TraderService;
require 'vendor/autoload.php';
// Initialize TraderService
$trader = new TraderService();
// Sample close prices (could be from a stock price feed)
$closePrices = [120.5, 121.0, 121.5, 122.0, 122.5]; // closing prices
// Calculate the Simple Moving Average (SMA) with a period of 3
$sma = $trader->sma($closePrices, 3);
// Display the result
echo "Simple Moving Average (SMA): " . implode(", ", $sma);
use Trader\TraderService;
require 'vendor/autoload.php';
// Initialize TraderInterface
$trader = new TraderService();
// Sample close prices
$closePrices = [120.5, 121.0, 121.5, 122.0, 122.5];
// Calculate RSI with a period of 14
$rsi = $trader->rsi($closePrices, 14);
// Display the result
echo "Relative Strength Index (RSI): " . implode(", ", $rsi);
The library provides access to a wide variety of technical analysis functions supported by the PHP Trader extension. Some of the most commonly used indicators include:
- SMA - Simple Moving Average
- EMA - Exponential Moving Average
- RSI - Relative Strength Index
- MACD - Moving Average Convergence Divergence
- ADX - Average Directional Index
- ATR - Average True Range
- Bollinger Bands
- CCI - Commodity Channel Index
- MFI - Money Flow Index
- OBV - On-Balance Volume
- Stochastic Oscillator
For a full list of available functions, refer to the official PHP Trader documentation.
To handle errors, you can catch BadFunctionCallException
exceptions that occur when invalid data is passed to any indicator.
This library is licensed under the MIT License. See the LICENSE file for more information.
For more detailed documentation, please refer to official PHP Trader documentation.