PHP code example of geoffroy-pradier / php-trader

1. Go to this page and download the library: Download geoffroy-pradier/php-trader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

geoffroy-pradier / php-trader example snippets


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

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
bash
composer