定制 geoffroy-pradier/php-trader 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

geoffroy-pradier/php-trader

最新稳定版本:v1.0.0

Composer 安装命令:

composer require geoffroy-pradier/php-trader

包简介

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

README 文档

README

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

Install the package via Composer:

composer require geoffroy-pradier/php-trader

Requirements

  • PHP >= 8.2

Usage

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)

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

Run the PHPUnit tests to verify functionality:

composer test

Development

To contribute:

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

License

MIT

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-30