PHPackages                             timirey/trader-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. timirey/trader-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

timirey/trader-php
==================

PHP wrapper for the trader extension, providing access to technical analysis indicators.

1.0.1(1y ago)7162[1 issues](https://github.com/timirey/trader-php/issues)MITPHPPHP ^8.3

Since Nov 24Pushed 1y ago3 watchersCompare

[ Source](https://github.com/timirey/trader-php)[ Packagist](https://packagist.org/packages/timirey/trader-php)[ RSS](/packages/timirey-trader-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

[![Trader PHP](https://raw.githubusercontent.com/timirey/trader-php/main/.github/logo-red.svg)](https://raw.githubusercontent.com/timirey/trader-php/main/.github/logo-red.svg)

[![Tests](https://github.com/timirey/trader-php/actions/workflows/tests.yml/badge.svg)](https://github.com/timirey/trader-php/actions)[![Latest Stable Version](https://camo.githubusercontent.com/3f9650646f5d0ac4c440e364490a0dad81cd137cde125d00d8a985110ae3ee4e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74696d697265792f7472616465722d706870)](https://packagist.org/packages/timirey/trader-php)[![Total Downloads](https://camo.githubusercontent.com/227b0385d29c68ddb60bb7e73210216f278ff527ae3b162b993f3c39ae7f7c34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74696d697265792f7472616465722d706870)](https://packagist.org/packages/timirey/trader-php)[![License](https://camo.githubusercontent.com/42d410d690abd9b6a797b86c697fcb3c021bb30714141fe633ad6c6fc0ee7ed4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74696d697265792f7472616465722d706870)](https://packagist.org/packages/timirey/trader-php)

Trader PHP
==========

[](#trader-php)

Trader PHP is a PHP library that serves as a user-friendly wrapper for the [Trader Extension](https://www.php.net/manual/en/book.trader.php). 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.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Basic Usage](#basic-usage)
    - [Simple Moving Average (SMA)](#example-1-simple-moving-average-sma)
    - [Relative Strength Index (RSI)](#example-2-relative-strength-index-rsi)
- [Available Indicators](#available-indicators)
- [Error Handling](#error-handling)
- [License](#license)
- [Reference](#reference)

Features
--------

[](#features)

- **Easy-to-use wrapper** around PHP’s [Trader Extension](https://www.php.net/manual/en/book.trader.php).
- 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**.

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

[](#installation)

You can easily install the library using [Composer](https://getcomposer.org/):

```
composer require timirey/trader-php
```

Make sure that the PHP Trader Extension is installed and enabled on your PHP setup.

Basic Usage
-----------

[](#basic-usage)

Once installed, you can quickly start using the indicators in your PHP application.

### Example 1: Simple Moving Average (SMA)

[](#example-1-simple-moving-average-sma)

```
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);
```

### Example 2: Relative Strength Index (RSI)

[](#example-2-relative-strength-index-rsi)

```
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);
```

Available Indicators
--------------------

[](#available-indicators)

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](https://www.php.net/manual/en/book.trader.php).

Error Handling
--------------

[](#error-handling)

To handle errors, you can catch `BadFunctionCallException` exceptions that occur when invalid data is passed to any indicator.

License
-------

[](#license)

This library is licensed under the MIT License. See the [LICENSE](https://github.com/timirey/trader-php/blob/main/LICENSE.md) file for more information.

Reference
---------

[](#reference)

For more detailed documentation, please refer to [official PHP Trader documentation](https://www.php.net/manual/en/book.trader.php).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~13 days

Total

3

Last Release

514d ago

Major Versions

0.1.0 → 1.0.02024-12-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/dafb7e130f8087f4eed9d8e588b2c6751b7cf20df058c58d11f0fce51032a977?d=identicon)[timirey](/maintainers/timirey)

---

Top Contributors

[![timirey](https://avatars.githubusercontent.com/u/15349915?v=4)](https://github.com/timirey "timirey (25 commits)")

---

Tags

phptradingindicators

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/timirey-trader-php/health.svg)

```
[![Health](https://phpackages.com/badges/timirey-trader-php/health.svg)](https://phpackages.com/packages/timirey-trader-php)
```

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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