Skip to content

Commit 8000be3

Browse files
committed
Updated the documentation and added the friendly version for slow stoch rsi
1 parent 7fb9533 commit 8000be3

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

source/LupeTrader.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ class LupeTrader extends Trader
99
{
1010

1111
/**
12-
* @param array $real
13-
* @param int $rsi_period
14-
* @param int $fastK_Period
15-
* @param int $slowK_Period
16-
* @param int $slowK_MAType
17-
* @param int $slowD_Period
18-
* @param int $slowD_MAType
12+
* Slow Stochastic Relative Strength Index
1913
*
20-
* @return array
14+
* @param array $real Array of real values.
15+
* @param int $rsi_period [OPTIONAL] [DEFAULT 14, SUGGESTED 4-200] Number of period. Valid range from 2 to 100000.
16+
* @param int $fastK_Period [OPTIONAL] [DEFAULT 5, SUGGESTED 1-200] Time period for building the Fast-K line. Valid range from 1 to 100000.
17+
* @param int $slowK_Period [OPTIONAL] [DEFAULT 3, SUGGESTED 1-200] Smoothing for making the Slow-K line. Valid range from 1 to 100000, usually set to 3.
18+
* @param int $slowK_MAType [OPTIONAL] [DEFAULT TRADER_MA_TYPE_SMA] Type of Moving Average for Slow-K. MovingAverageType::* series of constants should be used.
19+
* @param int $slowD_Period [OPTIONAL] [DEFAULT 3, SUGGESTED 1-200] Smoothing for making the Slow-D line. Valid range from 1 to 100000.
20+
* @param int $slowD_MAType [OPTIONAL] [DEFAULT TRADER_MA_TYPE_SMA] Type of Moving Average for Slow-D. MovingAverageType::* series of constants should be used.
21+
*
22+
* @return array Returns an array with calculated data. [SlowK => [...], SlowD => [...]]
2123
* @throws \Exception
2224
*/
2325
public static function slowstochrsi(array $real, int $rsi_period = 14, int $fastK_Period = 5, int $slowK_Period = 3, int $slowK_MAType = MovingAverageType::SMA, int $slowD_Period = 3, int $slowD_MAType = MovingAverageType::SMA): array

source/LupeTraderFriendly.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,27 @@
22

33
namespace LupeCode\phpTraderNative;
44

5+
use LupeCode\phpTraderNative\TALib\Enum\MovingAverageType;
6+
57
class LupeTraderFriendly extends TraderFriendly
68
{
79

10+
/**
11+
* Slow Stochastic Relative Strength Index
12+
*
13+
* @param array $real Array of real values.
14+
* @param int $rsi_period [OPTIONAL] [DEFAULT 14, SUGGESTED 4-200] Number of period. Valid range from 2 to 100000.
15+
* @param int $fastK_Period [OPTIONAL] [DEFAULT 5, SUGGESTED 1-200] Time period for building the Fast-K line. Valid range from 1 to 100000.
16+
* @param int $slowK_Period [OPTIONAL] [DEFAULT 3, SUGGESTED 1-200] Smoothing for making the Slow-K line. Valid range from 1 to 100000, usually set to 3.
17+
* @param int $slowK_MAType [OPTIONAL] [DEFAULT TRADER_MA_TYPE_SMA] Type of Moving Average for Slow-K. MovingAverageType::* series of constants should be used.
18+
* @param int $slowD_Period [OPTIONAL] [DEFAULT 3, SUGGESTED 1-200] Smoothing for making the Slow-D line. Valid range from 1 to 100000.
19+
* @param int $slowD_MAType [OPTIONAL] [DEFAULT TRADER_MA_TYPE_SMA] Type of Moving Average for Slow-D. MovingAverageType::* series of constants should be used.
20+
*
21+
* @return array Returns an array with calculated data. [SlowK => [...], SlowD => [...]]
22+
* @throws \Exception
23+
*/
24+
public static function slowStochasticRelativeStrengthIndex(array $real, int $rsi_period = 14, int $fastK_Period = 5, int $slowK_Period = 3, int $slowK_MAType = MovingAverageType::SMA, int $slowD_Period = 3, int $slowD_MAType = MovingAverageType::SMA)
25+
{
26+
return LupeTrader::slowstochrsi($real, $rsi_period, $fastK_Period, $slowK_Period, $slowK_MAType, $slowD_Period, $slowD_MAType);
27+
}
828
}

tests/LupeTraderFriendlyTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,27 @@
22

33
namespace LupeCode\phpTraderNativeTest;
44

5+
use LupeCode\phpTraderNative\LupeTraderFriendly;
6+
use LupeCode\phpTraderNative\TALib\Enum\MovingAverageType;
57
use LupeCode\phpTraderNativeTest\TraderFriendlyTest;
68

79
class LupeTraderFriendlyTest extends TraderFriendlyTest
810
{
9-
11+
/**
12+
* @throws \Exception
13+
*/
14+
public function testSlowStochasticRelativeStrengthIndex()
15+
{
16+
$rsi_period = 14;
17+
$optInFastK_Period = 3;
18+
$optInSlowK_Period = 10;
19+
$optInSlowD_Period = 5;
20+
$optInSlowK_MAType = MovingAverageType::SMA;
21+
$optInSlowD_MAType = MovingAverageType::SMA;
22+
$Output = LupeTraderFriendly::slowStochasticRelativeStrengthIndex($this->Close, $rsi_period, $optInFastK_Period, $optInSlowK_Period, $optInSlowK_MAType, $optInSlowD_Period, $optInSlowD_MAType);
23+
$traderRsi = \trader_rsi($this->Close, $rsi_period);
24+
list($traderSlowK, $traderSlowD) = \trader_stoch($traderRsi, $traderRsi, $traderRsi, $optInFastK_Period, $optInSlowK_Period, $optInSlowK_MAType, $optInSlowD_Period, $optInSlowD_MAType);
25+
$this->assertEquals($traderSlowK, $this->adjustForPECL($Output['SlowK']), '', 0.1);
26+
$this->assertEquals($traderSlowD, $this->adjustForPECL($Output['SlowD']), '', 0.1);
27+
}
1028
}

0 commit comments

Comments
 (0)