Skip to content

Commit 7548d4d

Browse files
committed
Added functions from TA-lib
* accbands * avgdev * imi
1 parent 29cccb4 commit 7548d4d

15 files changed

+3171
-2829
lines changed

source/LupeTrader.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ public static function acos(array $real): array
4343
*/
4444
public static function chaikinAccumulationDistributionLine(array $high, array $low, array $close, array $volume): array
4545
{
46-
$count = self::verifyArrayCounts([$high, $low, $close, $volume]);
47-
$result = new \SplFixedArray($count + 1);
46+
$count = self::verifyArrayCounts([$high, $low, $close, $volume]);
47+
$result = new \SplFixedArray($count + 1);
4848
$moneyFlowVolume = 0.0;
4949
for ($i = 0; $i <= $count; $i++) {
5050
$denominator = $high[$i] - $low[$i];
5151
if ($denominator > 0) {
5252
$moneyFlowMultiplier = (($close[$i] - $low[$i]) - ($high[$i] - $close[$i])) / $denominator;
53-
$moneyFlowVolume += ($moneyFlowMultiplier * $volume[$i]);
53+
$moneyFlowVolume += ($moneyFlowMultiplier * $volume[$i]);
5454
}
5555
$result[$i] = $moneyFlowVolume;
5656
}
@@ -101,19 +101,19 @@ public static function add(array $real0, array $real1): array
101101
*/
102102
public static function chaikinOscillator(array $high, array $low, array $close, array $volume, int $fastPeriod = 3, int $slowPeriod = 10): array
103103
{
104-
$count = self::verifyArrayCounts([$high, $low, $close, $volume]);
105-
$fastK = 2 / ($fastPeriod + 1);
106-
$slowK = 2 / ($slowPeriod + 1);
104+
$count = self::verifyArrayCounts([$high, $low, $close, $volume]);
105+
$fastK = 2 / ($fastPeriod + 1);
106+
$slowK = 2 / ($slowPeriod + 1);
107107
$oneMinusFastK = 1 - $fastK;
108108
$oneMinusSlowK = 1 - $slowK;
109109

110-
$ad = self::ad($high, $low, $close, $volume);
110+
$ad = self::ad($high, $low, $close, $volume);
111111
$fastEma = $slowEma = $ad[0];
112-
$output = [];
112+
$output = [];
113113

114114
for ($i = 1; $i <= $count; $i++) {
115-
$fastEma = ($fastK * $ad[$i]) + ($oneMinusFastK * $fastEma);
116-
$slowEma = ($slowK * $ad[$i]) + ($oneMinusSlowK * $slowEma);
115+
$fastEma = ($fastK * $ad[$i]) + ($oneMinusFastK * $fastEma);
116+
$slowEma = ($slowK * $ad[$i]) + ($oneMinusSlowK * $slowEma);
117117
$output[$i] = $fastEma - $slowEma;
118118
}
119119

@@ -149,10 +149,10 @@ public static function adosc(array $high, array $low, array $close, array $volum
149149
*/
150150
public static function averageDirectionalMovementIndex(array $high, array $low, array $close, int $timePeriod = 14): array
151151
{
152-
$count = self::verifyArrayCounts([$high, $low, $close]);
153-
$plus = self::plusDI($high, $low, $close, $timePeriod);
154-
$minus = self::minusDI($high, $low, $close, $timePeriod);
155-
$sum = self::add($plus, $minus);
152+
$count = self::verifyArrayCounts([$high, $low, $close]);
153+
$plus = self::plusDI($high, $low, $close, $timePeriod);
154+
$minus = self::minusDI($high, $low, $close, $timePeriod);
155+
$sum = self::add($plus, $minus);
156156
$result = new \SplFixedArray($count + 1);
157157
for ($i = 0; $i <= $count; $i++) {
158158
$result[$i] = $sum[$i] > 0 ? 100 * abs($plus[$i] - $minus[$i]) / $sum[$i] : 0;
@@ -216,12 +216,12 @@ public static function slowstochrsi(
216216
int $slowD_Period = 3,
217217
int $slowD_MAType = MovingAverageType::SMA
218218
): array {
219-
$real = \array_values($real);
219+
$real = \array_values($real);
220220
$endIdx = count($real) - 1;
221-
$rsi = [];
221+
$rsi = [];
222222
self::checkForError(self::getMomentumIndicators()::rsi(0, $endIdx, $real, $rsi_period, self::$outBegIdx, self::$outNBElement, $rsi));
223-
$rsi = array_values($rsi);
224-
$endIdx = self::verifyArrayCounts([&$rsi]);
223+
$rsi = array_values($rsi);
224+
$endIdx = self::verifyArrayCounts([&$rsi]);
225225
$outSlowK = [];
226226
$outSlowD = [];
227227
self::checkForError(

source/TALib/Classes/CandleSetting.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,25 @@ class CandleSetting
5959
public function __construct(int $settingType, int $rangeType = null, int $avgPeriod = null, float $factor = null)
6060
{
6161
$this->settingType = $settingType;
62-
$this->rangeType = $rangeType;
63-
$this->avgPeriod = $avgPeriod;
64-
$this->factor = $factor;
62+
$this->rangeType = $rangeType;
63+
$this->avgPeriod = $avgPeriod;
64+
$this->factor = $factor;
6565
}
6666

6767
public function CopyFrom(CandleSetting $source)
6868
{
6969
$this->settingType = $source->settingType;
70-
$this->rangeType = $source->rangeType;
71-
$this->avgPeriod = $source->avgPeriod;
72-
$this->factor = $source->factor;
70+
$this->rangeType = $source->rangeType;
71+
$this->avgPeriod = $source->avgPeriod;
72+
$this->factor = $source->factor;
7373
}
7474

7575
public function CandleSetting(CandleSetting $that)
7676
{
7777
$this->settingType = $that->settingType;
78-
$this->rangeType = $that->rangeType;
79-
$this->avgPeriod = $that->avgPeriod;
80-
$this->factor = $that->factor;
78+
$this->rangeType = $that->rangeType;
79+
$this->avgPeriod = $that->avgPeriod;
80+
$this->factor = $that->factor;
8181
}
8282

8383
}

0 commit comments

Comments
 (0)