PHPackages                             geoffroy-pradier/php-trader - 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. geoffroy-pradier/php-trader

ActiveLibrary

geoffroy-pradier/php-trader
===========================

PHP implementation of technical indicators for trading. Alternative to the Trader extension.

v1.0.0(7mo ago)06↓50%MITPHPPHP &gt;=8.2CI passing

Since Sep 30Pushed 7mo agoCompare

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

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

Trader
======

[](#trader)

A pure PHP implementation of technical indicators for trading, including the Relative Strength Index (RSI) and Stochastic Oscillator. No native extensions (e.g., Trader PECL) are required, making it portable across PHP environments.

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

[](#installation)

Install the package via Composer:

```
composer require geoffroy-pradier/php-trader
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2

Usage
-----

[](#usage)

### Relative Strength Index (RSI)

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

Calculate the RSI for a series of closing prices:

```
use GeoffroyPradier\Trader\Rsi;

$prices = [100, 102, 101, 105, 103, 107, 110, 108, 112, 115, 113, 118, 120, 122, 119];
$rsi = Rsi::calculate($prices, 14);
print_r($rsi); // Outputs array of RSI values
```

### Stochastic Oscillator (%K and %D)

[](#stochastic-oscillator-k-and-d)

Calculate the %K and %D lines for high, low, and closing prices:

```
use GeoffroyPradier\Trader\Stochastic;

$highs = [101, 103, 102, 106, 104, 108, 111, 109, 113, 116, 114, 119, 121, 123, 120, 126, 124];
$lows = [99, 101, 100, 104, 102, 106, 109, 107, 111, 114, 112, 117, 119, 121, 118, 124, 122];
$closes = [100, 102, 101, 105, 103, 107, 110, 108, 112, 115, 113, 118, 120, 122, 119, 125, 123];
$stoch = Stochastic::calculate($highs, $lows, $closes, 14, 3);
print_r($stoch['k']); // %K values
print_r($stoch['d']); // %D values
```

Testing
-------

[](#testing)

Run the PHPUnit tests to verify functionality:

```
composer test
```

Development
-----------

[](#development)

To contribute:

1. Fork the repository on GitHub.
2. Add your changes and include corresponding PHPUnit tests.
3. Submit a pull request.

License
-------

[](#license)

MIT

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance64

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

222d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c9e1c601db2b0124f4ff26458fe928dd060086f6877c483a84703ca5b318fdd?d=identicon)[geoffroy-pradier](/maintainers/geoffroy-pradier)

---

Top Contributors

[![geoffroy-pradier](https://avatars.githubusercontent.com/u/36533224?v=4)](https://github.com/geoffroy-pradier "geoffroy-pradier (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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