Skip to content

Commit 7fb9533

Browse files
committed
Added a test to compare the results of slow stoch rsi to the PECL functions.
1 parent 850f190 commit 7fb9533

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/LupeTraderTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ class LupeTraderTest extends TraderTest
1414
*/
1515
public function testSlowStochRsi()
1616
{
17-
$close = [4265.36, 4283.8, 3774.99, 3936.69, 3731.32, 3775, 4225.03, 4248, 3976, 4142.01, 4103.19, 3833.47, 3901.84, 3694.39, 3433.26, 3380.01, 3401, 3531.18, 3410.15, 3349.36, 3430.24, 3265, 3195.71, 3183, 3195];
18-
19-
$rsi_period = 3;
17+
$rsi_period = 14;
2018
$optInFastK_Period = 3;
21-
$optInSlowK_Period = 14;
22-
$optInSlowD_Period = 3;
19+
$optInSlowK_Period = 10;
20+
$optInSlowD_Period = 5;
2321
$optInSlowK_MAType = MovingAverageType::SMA;
2422
$optInSlowD_MAType = MovingAverageType::SMA;
25-
$Output = LupeTrader::slowstochrsi($close, $rsi_period, $optInFastK_Period, $optInSlowK_Period, $optInSlowK_MAType, $optInSlowD_Period, $optInSlowD_MAType);
26-
var_export($Output);
23+
$Output = LupeTrader::slowstochrsi($this->Close, $rsi_period, $optInFastK_Period, $optInSlowK_Period, $optInSlowK_MAType, $optInSlowD_Period, $optInSlowD_MAType);
24+
$traderRsi = \trader_rsi($this->Close, $rsi_period);
25+
list($traderSlowK, $traderSlowD) = \trader_stoch($traderRsi, $traderRsi, $traderRsi, $optInFastK_Period, $optInSlowK_Period, $optInSlowK_MAType, $optInSlowD_Period, $optInSlowD_MAType);
26+
$this->assertEquals($traderSlowK, $this->adjustForPECL($Output['SlowK']), '', 0.1);
27+
$this->assertEquals($traderSlowD, $this->adjustForPECL($Output['SlowD']), '', 0.1);
2728
}
2829
}

0 commit comments

Comments
 (0)