Skip to content

Commit 00acdd6

Browse files
committed
Converted to Trader 0.4.1
1 parent 359d0b2 commit 00acdd6

5 files changed

Lines changed: 16 additions & 34 deletions

File tree

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,9 @@ This project is just an interface to that extension, and does not work without i
1414

1515
Variable types are set on all function parameters.
1616

17-
## Note About Mis-documented Functions
17+
### Requires PECL Trader 0.4.1.
1818

19-
The php.net documentation for trader_ht_phasor and trader_ht_sine are incorrect. This was discovered through unit testing of this interface. Both functions require a second parameter, a by reference array that extra data will be written into.
20-
21-
This interface has the correct version of those functions.
22-
23-
### Bug in Trader 0.4.0
24-
25-
The PECL Trader package version 0.4.0 has a bug regarding the two functions above. Though the output parameters are required for the function to execute, they are not used. The returned array is a 2-Dimensional array with the return value and the output parameter combined.
19+
If you are using version 0.4.0, see the branch `trader-0.4.0` for that.
2620

2721
## How to use
2822

Tests/TraderTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -923,16 +923,12 @@ public function testInterfaceFunctions_ht_dcphase()
923923

924924
public function testInterfaceFunctions_ht_phasor()
925925
{
926-
$inPhase1 = [];
927-
$inPhase2 = [];
928-
$this->assertEquals(trader_ht_phasor($this->Close, $inPhase1), Trader::ht_phasor($this->Close, $inPhase2));
926+
$this->assertEquals(trader_ht_phasor($this->Close), Trader::ht_phasor($this->Close));
929927
}
930928

931929
public function testInterfaceFunctions_ht_sine()
932930
{
933-
$sine1 = [];
934-
$sine2 = [];
935-
$this->assertEquals(trader_ht_sine($this->Close, $sine1), Trader::ht_sine($this->Close, $sine2));
931+
$this->assertEquals(trader_ht_sine($this->Close), Trader::ht_sine($this->Close));
936932
}
937933

938934
public function testInterfaceFunctions_ht_trendline()
@@ -1721,16 +1717,12 @@ public function testFriendlyFunctions_ht_dcphase()
17211717

17221718
public function testFriendlyFunctions_ht_phasor()
17231719
{
1724-
$inPhase1 = [];
1725-
$inPhase2 = [];
1726-
$this->assertEquals(trader_ht_phasor($this->Close, $inPhase1), Trader::hilbertTransformPhasorComponents($this->Close, $inPhase2));
1720+
$this->assertEquals(trader_ht_phasor($this->Close), Trader::hilbertTransformPhasorComponents($this->Close));
17271721
}
17281722

17291723
public function testFriendlyFunctions_ht_sine()
17301724
{
1731-
$sine1 = [];
1732-
$sine2 = [];
1733-
$this->assertEquals(trader_ht_sine($this->Close, $sine1), Trader::hilbertTransformSineWave($this->Close, $sine2));
1725+
$this->assertEquals(trader_ht_sine($this->Close), Trader::hilbertTransformSineWave($this->Close));
17341726
}
17351727

17361728
public function testFriendlyFunctions_ht_trendline()

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
],
1515
"require": {
1616
"php": ">=7.0.0",
17-
"ext-trader": "*"
17+
"ext-trader": "0.4.1"
1818
},
1919
"require-dev": {
2020
"phpunit/phpunit": "~6.3.0",

source/Trader.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,28 +1597,26 @@ public static function hilbertTransformDominantCyclePhase(array $real): array
15971597
* Hilbert Transform - Phasor Components
15981598
*
15991599
* @param array $real Array of real values.
1600-
* @param array $inPhase Empty array, will be filled with in phase data.
16011600
*
16021601
* @return array Returns an array with calculated data or false on failure.
16031602
* @throws \Exception
16041603
*/
1605-
public static function hilbertTransformPhasorComponents(array $real, array &$inPhase): array
1604+
public static function hilbertTransformPhasorComponents(array $real): array
16061605
{
1607-
return static::ht_phasor($real, $inPhase);
1606+
return static::ht_phasor($real);
16081607
}
16091608

16101609
/**
16111610
* Hilbert Transform - SineWave
16121611
*
16131612
* @param array $real Array of real values.
1614-
* @param array $sine Empty array, will be filled with sine data.
16151613
*
16161614
* @return array Returns an array with calculated data or false on failure.
16171615
* @throws \Exception
16181616
*/
1619-
public static function hilbertTransformSineWave(array $real, array &$sine): array
1617+
public static function hilbertTransformSineWave(array $real): array
16201618
{
1621-
return static::ht_sine($real, $sine);
1619+
return static::ht_sine($real);
16221620
}
16231621

16241622
/**

source/TraderTrait.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,14 +1886,13 @@ public static function ht_dcphase(array $real): array
18861886
* Hilbert Transform - Phasor Components
18871887
*
18881888
* @param array $real Array of real values.
1889-
* @param array $inPhase Empty array, will be filled with in phase data.
18901889
*
18911890
* @return array Returns an array with calculated data or false on failure.
18921891
* @throws \Exception
18931892
*/
1894-
public static function ht_phasor(array $real, array &$inPhase): array
1893+
public static function ht_phasor(array $real): array
18951894
{
1896-
$return = trader_ht_phasor($real, $inPhase);
1895+
$return = trader_ht_phasor($real);
18971896
static::checkForError();
18981897

18991898
return $return;
@@ -1903,14 +1902,13 @@ public static function ht_phasor(array $real, array &$inPhase): array
19031902
* Hilbert Transform - SineWave
19041903
*
19051904
* @param array $real Array of real values.
1906-
* @param array $sine Empty array, will be filled with sine data.
19071905
*
19081906
* @return array Returns an array with calculated data or false on failure.
19091907
* @throws \Exception
19101908
*/
1911-
public static function ht_sine(array $real, array &$sine): array
1909+
public static function ht_sine(array $real): array
19121910
{
1913-
$return = trader_ht_sine($real, $sine);
1911+
$return = trader_ht_sine($real);
19141912
static::checkForError();
19151913

19161914
return $return;
@@ -3193,4 +3191,4 @@ public static function wma(array $real, int $timePeriod = null): array
31933191
return $return;
31943192
}
31953193

3196-
}
3194+
}

0 commit comments

Comments
 (0)