Trader   D
last analyzed

Complexity

Total Complexity 165

Size/Duplication

Total Lines 3150
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 3150
ccs 678
cts 678
cp 1
rs 4.4102
c 0
b 0
f 0
wmc 165
lcom 1
cbo 0

164 Methods

Rating   Name   Duplication   Size   Complexity  
A acos() 0 8 1
A ad() 0 8 1
A add() 0 8 1
A adosc() 0 14 1
A adx() 0 8 1
A adxr() 0 8 1
A apo() 0 8 1
A aroon() 0 8 1
A aroonosc() 0 8 1
A asin() 0 8 1
A atan() 0 8 1
A atr() 0 8 1
A avgprice() 0 8 1
A bbands() 0 13 1
A beta() 0 8 1
A bop() 0 8 1
A cci() 0 8 1
A cdl2crows() 0 8 1
A cdl3blackcrows() 0 8 1
A cdl3inside() 0 8 1
A cdl3linestrike() 0 8 1
A cdl3outside() 0 8 1
A cdl3starsinsouth() 0 8 1
A cdl3whitesoldiers() 0 8 1
A cdlabandonedbaby() 0 13 1
A cdladvanceblock() 0 8 1
A cdlbelthold() 0 8 1
A cdlbreakaway() 0 8 1
A cdlclosingmarubozu() 0 8 1
A cdlconcealbabyswall() 0 8 1
A cdlcounterattack() 0 8 1
A cdldarkcloudcover() 0 13 1
A cdldoji() 0 8 1
A cdldojistar() 0 8 1
A cdldragonflydoji() 0 8 1
A cdlengulfing() 0 8 1
A cdleveningdojistar() 0 13 1
A cdleveningstar() 0 13 1
A cdlgapsidesidewhite() 0 8 1
A cdlgravestonedoji() 0 8 1
A cdlhammer() 0 8 1
A cdlhangingman() 0 8 1
A cdlharami() 0 8 1
A cdlharamicross() 0 8 1
A cdlhighwave() 0 8 1
A cdlhikkake() 0 8 1
A cdlhikkakemod() 0 8 1
A cdlhomingpigeon() 0 8 1
A cdlidentical3crows() 0 8 1
A cdlinneck() 0 8 1
A cdlinvertedhammer() 0 8 1
A cdlkicking() 0 8 1
A cdlkickingbylength() 0 8 1
A cdlladderbottom() 0 8 1
A cdllongleggeddoji() 0 8 1
A cdllongline() 0 8 1
A cdlmarubozu() 0 8 1
A cdlmatchinglow() 0 8 1
A cdlmathold() 0 13 1
A cdlmorningdojistar() 0 13 1
A cdlmorningstar() 0 13 1
A cdlonneck() 0 8 1
A cdlpiercing() 0 8 1
A cdlrickshawman() 0 8 1
A cdlrisefall3methods() 0 8 1
A cdlseparatinglines() 0 8 1
A cdlshootingstar() 0 8 1
A cdlshortline() 0 8 1
A cdlspinningtop() 0 8 1
A cdlstalledpattern() 0 8 1
A cdlsticksandwich() 0 8 1
A cdltakuri() 0 8 1
A cdltasukigap() 0 8 1
A cdlthrusting() 0 8 1
A cdltristar() 0 8 1
A cdlunique3river() 0 8 1
A cdlupsidegap2crows() 0 8 1
A cdlxsidegap3methods() 0 8 1
A ceil() 0 8 1
A cmo() 0 8 1
A correl() 0 8 1
A cos() 0 8 1
A cosh() 0 8 1
A dema() 0 8 1
A div() 0 8 1
A dx() 0 8 1
A ema() 0 8 1
A errno() 0 4 1
A exp() 0 8 1
A floor() 0 8 1
A get_compat() 0 4 1
A get_unstable_period() 0 4 1
A ht_dcperiod() 0 8 1
A ht_dcphase() 0 8 1
A ht_phasor() 0 8 1
A ht_sine() 0 8 1
A ht_trendline() 0 8 1
A ht_trendmode() 0 8 1
A kama() 0 8 1
A linearreg_angle() 0 8 1
A linearreg_intercept() 0 8 1
A linearreg_slope() 0 8 1
A linearreg() 0 8 1
A ln() 0 8 1
A log10() 0 8 1
A ma() 0 8 1
A macd() 0 12 1
A macdext() 0 14 1
A macdfix() 0 8 1
A mama() 0 8 1
A mavp() 0 13 1
A max() 0 8 1
A maxindex() 0 8 1
A medprice() 0 8 1
A mfi() 0 8 1
A midpoint() 0 8 1
A midprice() 0 8 1
A min() 0 8 1
A minindex() 0 8 1
A minmax() 0 8 1
A minmaxindex() 0 8 1
A minus_di() 0 8 1
A minus_dm() 0 8 1
A mom() 0 8 1
A mult() 0 8 1
A natr() 0 8 1
A obv() 0 8 1
A plus_di() 0 8 1
A plus_dm() 0 8 1
A ppo() 0 8 1
A roc() 0 8 1
A rocp() 0 8 1
A rocr100() 0 8 1
A rocr() 0 8 1
A rsi() 0 8 1
A sar() 0 8 1
B sarext() 0 29 1
A set_compat() 0 4 1
A set_unstable_period() 0 4 1
A sin() 0 8 1
A sinh() 0 8 1
A sma() 0 8 1
A sqrt() 0 8 1
A stddev() 0 8 1
B stoch() 0 25 1
A stochf() 0 21 1
A stochrsi() 0 19 1
A sub() 0 8 1
A sum() 0 8 1
A t3() 0 8 1
A tan() 0 8 1
A tanh() 0 8 1
A tema() 0 8 1
A trange() 0 8 1
A trima() 0 8 1
A trix() 0 8 1
A tsf() 0 8 1
A typprice() 0 8 1
A ultosc() 0 14 1
A var() 0 8 1
A wclprice() 0 8 1
A willr() 0 8 1
A wma() 0 8 1
A handleErrors() 0 7 2

How to fix   Complexity   

Complex Class

Complex classes like Trader often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Trader, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Laratrade\Trader;
4
5
use BadFunctionCallException;
6
use Laratrade\Trader\Contracts\Trader as TraderContract;
7
8
/**
9
 * Class Trader
10
 * @package Laratrade\Trader
11
 *
12
 * phpcs:disable Generic.Files.LineLength
13
 * phpcs:disable PSR1.Methods.CamelCapsMethodName
14
 */
15
class Trader implements TraderContract
16
{
17
    /**
18
     * The error messages.
19
     *
20
     * @var array
21
     */
22
    protected static $errors = [
23
        self::ERR_LIB_NOT_INITIALIZE        => 'Library not initialized',
24
        self::ERR_BAD_PARAM                 => 'Bad parameter',
25
        self::ERR_ALLOC_ERR                 => 'Allocation error',
26
        self::ERR_GROUP_NOT_FOUND           => 'Group not found',
27
        self::ERR_FUNC_NOT_FOUND            => 'Function not found',
28
        self::ERR_INVALID_HANDLE            => 'Invalid handle',
29
        self::ERR_INVALID_PARAM_HOLDER      => 'Invalid parameter holder',
30
        self::ERR_INVALID_PARAM_HOLDER_TYPE => 'Invalid parameter holder type',
31
        self::ERR_INVALID_PARAM_FUNCTION    => 'Invalid parameter function',
32
        self::ERR_INPUT_NOT_ALL_INITIALIZE  => 'Input not all initialized',
33
        self::ERR_OUTPUT_NOT_ALL_INITIALIZE => 'Output not all initialized',
34
        self::ERR_OUT_OF_RANGE_START_INDEX  => 'Out of range on start index',
35
        self::ERR_OUT_OF_RANGE_END_INDEX    => 'Out of range on end index',
36
        self::ERR_INVALID_LIST_TYPE         => 'Invalid list type',
37
        self::ERR_BAD_OBJECT                => 'Bad object',
38
        self::ERR_NOT_SUPPORTED             => 'Not supported',
39
        self::ERR_INTERNAL_ERROR            => 'Internal error',
40
        self::ERR_UNKNOWN_ERROR             => 'Unknown error',
41
    ];
42
43
    /**
44
     * Vector Trigonometric ACos.
45
     *
46
     * Calculates the arc cosine for each value in real and returns the resulting array.
47
     *
48
     * @param array $real Array of real values.
49
     *
50
     * @return array Returns an array with calculated data.
51
     */
52 2
    public function acos(array $real): array
53
    {
54 2
        $result = trader_acos($real);
55
56 2
        $this->handleErrors();
57
58 2
        return $result;
59
    }
60
61
    /**
62
     * Chaikin A/D Line.
63
     *
64
     * @param array $high   High price, array of real values.
65
     * @param array $low    Low price, array of real values.
66
     * @param array $close  Closing price, array of real values.
67
     * @param array $volume Volume traded, array of real values.
68
     *
69
     * @return array Returns an array with calculated data.
70
     */
71 2
    public function ad(array $high, array $low, array $close, array $volume): array
72
    {
73 2
        $result = trader_ad($high, $low, $close, $volume);
74
75 2
        $this->handleErrors();
76
77 2
        return $result;
78
    }
79
80
    /**
81
     * Vector Arithmetic Add.
82
     *
83
     * Calculates the vector addition of real0 to real1 and returns the resulting vector.
84
     *
85
     * @param array $real0 Array of real values.
86
     * @param array $real1 Array of real values.
87
     *
88
     * @return array Returns an array with calculated data.
89
     */
90 2
    public function add(array $real0, array $real1): array
91
    {
92 2
        $result = trader_add($real0, $real1);
93
94 2
        $this->handleErrors();
95
96 2
        return $result;
97
    }
98
99
    /**
100
     * Chaikin A/D Oscillator.
101
     *
102
     * @param array $high       High price, array of real values.
103
     * @param array $low        Low price, array of real values.
104
     * @param array $close      Closing price, array of real values.
105
     * @param array $volume     Volume traded, array of real values.
106
     * @param int   $fastPeriod Number of period for the fast MA. Valid range from 2 to 100000.
107
     * @param int   $slowPeriod Number of period for the slow MA. Valid range from 2 to 100000.
108
     *
109
     * @return array Returns an array with calculated data.
110
     */
111 2
    public function adosc(
112
        array $high,
113
        array $low,
114
        array $close,
115
        array $volume,
116
        int $fastPeriod = 3,
117
        int $slowPeriod = 10
118
    ): array {
119 2
        $result = trader_adosc($high, $low, $close, $volume, $fastPeriod, $slowPeriod);
120
121 2
        $this->handleErrors();
122
123 2
        return $result;
124
    }
125
126
    /**
127
     * Average Directional Movement Index.
128
     *
129
     * @param array $high       High price, array of real values.
130
     * @param array $low        Low price, array of real values.
131
     * @param array $close      Closing price, array of real values.
132
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
133
     *
134
     * @return array Returns an array with calculated data.
135
     */
136 2
    public function adx(array $high, array $low, array $close, int $timePeriod = 14): array
137
    {
138 2
        $result = trader_adx($high, $low, $close, $timePeriod);
139
140 2
        $this->handleErrors();
141
142 2
        return $result;
143
    }
144
145
    /**
146
     * Average Directional Movement Index Rating.
147
     *
148
     * @param array $high       High price, array of real values.
149
     * @param array $low        Low price, array of real values.
150
     * @param array $close      Closing price, array of real values.
151
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
152
     *
153
     * @return array Returns an array with calculated data.
154
     */
155 2
    public function adxr(array $high, array $low, array $close, int $timePeriod = 14): array
156
    {
157 2
        $result = trader_adxr($high, $low, $close, $timePeriod);
158
159 2
        $this->handleErrors();
160
161 2
        return $result;
162
    }
163
164
    /**
165
     * Absolute Price Oscillator.
166
     *
167
     * @param array $real       Array of real values.
168
     * @param int   $fastPeriod Number of period for the fast MA. Valid range from 2 to 100000.
169
     * @param int   $slowPeriod Number of period for the slow MA. Valid range from 2 to 100000.
170
     * @param int   $mAType     Type of Moving Average. MA_TYPE_* series of constants should be used.
171
     *
172
     * @return array Returns an array with calculated data.
173
     */
174 2
    public function apo(array $real, int $fastPeriod = 12, int $slowPeriod = 26, int $mAType = 0): array
175
    {
176 2
        $result = trader_apo($real, $fastPeriod, $slowPeriod, $mAType);
177
178 2
        $this->handleErrors();
179
180 2
        return $result;
181
    }
182
183
    /**
184
     * Aroon.
185
     *
186
     * @param array $high       High price, array of real values.
187
     * @param array $low        Low price, array of real values.
188
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
189
     *
190
     * @return array Returns an array with calculated data.
191
     */
192 2
    public function aroon(array $high, array $low, int $timePeriod = 14): array
193
    {
194 2
        $result = trader_aroon($high, $low, $timePeriod);
195
196 2
        $this->handleErrors();
197
198 2
        return $result;
199
    }
200
201
    /**
202
     * Aroon Oscillator.
203
     *
204
     * @param array $high       High price, array of real values.
205
     * @param array $low        Low price, array of real values.
206
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
207
     *
208
     * @return array Returns an array with calculated data.
209
     */
210 2
    public function aroonosc(array $high, array $low, int $timePeriod = 14): array
211
    {
212 2
        $result = trader_aroonosc($high, $low, $timePeriod);
213
214 2
        $this->handleErrors();
215
216 2
        return $result;
217
    }
218
219
    /**
220
     * Vector Trigonometric ASin.
221
     *
222
     * @param array $real Array of real values.
223
     *
224
     * @return array Returns an array with calculated data.
225
     */
226 2
    public function asin(array $real): array
227
    {
228 2
        $result = trader_asin($real);
229
230 2
        $this->handleErrors();
231
232 2
        return $result;
233
    }
234
235
    /**
236
     * Vector Trigonometric ATan.
237
     *
238
     * @param array $real Array of real values.
239
     *
240
     * @return array Returns an array with calculated data.
241
     */
242 2
    public function atan(array $real): array
243
    {
244 2
        $result = trader_atan($real);
245
246 2
        $this->handleErrors();
247
248 2
        return $result;
249
    }
250
251
    /**
252
     * Average True Range.
253
     *
254
     * @param array $high       High price, array of real values.
255
     * @param array $low        Low price, array of real values.
256
     * @param array $close      Closing price, array of real values.
257
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
258
     *
259
     * @return array Returns an array with calculated data.
260
     */
261 2
    public function atr(array $high, array $low, array $close, int $timePeriod = 14): array
262
    {
263 2
        $result = trader_atr($high, $low, $close, $timePeriod);
264
265 2
        $this->handleErrors();
266
267 2
        return $result;
268
    }
269
270
    /**
271
     * Average Price.
272
     *
273
     * @param array $open  Opening price, array of real values.
274
     * @param array $high  High price, array of real values.
275
     * @param array $low   Low price, array of real values.
276
     * @param array $close Closing price, array of real values.
277
     *
278
     * @return array Returns an array with calculated data.
279
     */
280 2
    public function avgprice(array $open, array $high, array $low, array $close): array
281
    {
282 2
        $result = trader_avgprice($open, $high, $low, $close);
283
284 2
        $this->handleErrors();
285
286 2
        return $result;
287
    }
288
289
    /**
290
     * Bollinger Bands.
291
     *
292
     * @param array $real       Array of real values.
293
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
294
     * @param float $nbDevUp    Deviation multiplier for upper band. Valid range from REAL_MIN to REAL_MAX.
295
     * @param float $nbDevDn    Deviation multiplier for lower band. Valid range from REAL_MIN to REAL_MAX.
296
     * @param int   $mAType     Type of Moving Average. MA_TYPE_* series of constants should be used.
297
     *
298
     * @return array Returns an array with calculated data.
299
     */
300 2
    public function bbands(
301
        array $real,
302
        int $timePeriod = 5,
303
        float $nbDevUp = 2.0,
304
        float $nbDevDn = 2.0,
305
        int $mAType = 0
306
    ): array {
307 2
        $result = trader_bbands($real, $timePeriod, $nbDevUp, $nbDevDn, $mAType);
308
309 2
        $this->handleErrors();
310
311 2
        return $result;
312
    }
313
314
    /**
315
     * Beta.
316
     *
317
     * @param array $real0      Array of real values.
318
     * @param array $real1      Array of real values.
319
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
320
     *
321
     * @return array Returns an array with calculated data.
322
     */
323 2
    public function beta(array $real0, array $real1, int $timePeriod = 5): array
324
    {
325 2
        $result = trader_beta($real0, $real1, $timePeriod);
326
327 2
        $this->handleErrors();
328
329 2
        return $result;
330
    }
331
332
    /**
333
     * Balance Of Power.
334
     *
335
     * @param array $open  Opening price, array of real values.
336
     * @param array $high  High price, array of real values.
337
     * @param array $low   Low price, array of real values.
338
     * @param array $close Closing price, array of real values.
339
     *
340
     * @return array Returns an array with calculated data.
341
     */
342 2
    public function bop(array $open, array $high, array $low, array $close): array
343
    {
344 2
        $result = trader_bop($open, $high, $low, $close);
345
346 2
        $this->handleErrors();
347
348 2
        return $result;
349
    }
350
351
    /**
352
     * Commodity Channel Index.
353
     *
354
     * @param array $high       High price, array of real values.
355
     * @param array $low        Low price, array of real values.
356
     * @param array $close      Closing price, array of real values.
357
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
358
     *
359
     * @return array Returns an array with calculated data.
360
     */
361 2
    public function cci(array $high, array $low, array $close, int $timePeriod = null): array
362
    {
363 2
        $result = trader_cci($high, $low, $close, $timePeriod);
364
365 2
        $this->handleErrors();
366
367 2
        return $result;
368
    }
369
370
    /**
371
     * Two Crows.
372
     *
373
     * @param array $open  Opening price, array of real values.
374
     * @param array $high  High price, array of real values.
375
     * @param array $low   Low price, array of real values.
376
     * @param array $close Closing price, array of real values.
377
     *
378
     * @return array Returns an array with calculated data.
379
     */
380 2
    public function cdl2crows(array $open, array $high, array $low, array $close): array
381
    {
382 2
        $result = trader_cdl2crows($open, $high, $low, $close);
383
384 2
        $this->handleErrors();
385
386 2
        return $result;
387
    }
388
389
    /**
390
     * Three Black Crows.
391
     *
392
     * @param array $open  Opening price, array of real values.
393
     * @param array $high  High price, array of real values.
394
     * @param array $low   Low price, array of real values.
395
     * @param array $close Closing price, array of real values.
396
     *
397
     * @return array Returns an array with calculated data.
398
     */
399 2
    public function cdl3blackcrows(array $open, array $high, array $low, array $close): array
400
    {
401 2
        $result = trader_cdl3blackcrows($open, $high, $low, $close);
402
403 2
        $this->handleErrors();
404
405 2
        return $result;
406
    }
407
408
    /**
409
     * Three Inside Up/Down.
410
     *
411
     * @param array $open  Opening price, array of real values.
412
     * @param array $high  High price, array of real values.
413
     * @param array $low   Low price, array of real values.
414
     * @param array $close Closing price, array of real values.
415
     *
416
     * @return array Returns an array with calculated data.
417
     */
418 2
    public function cdl3inside(array $open, array $high, array $low, array $close): array
419
    {
420 2
        $result = trader_cdl3inside($open, $high, $low, $close);
421
422 2
        $this->handleErrors();
423
424 2
        return $result;
425
    }
426
427
    /**
428
     * Three-Line Strike
429
     *
430
     * @param array $open  Opening price, array of real values.
431
     * @param array $high  High price, array of real values.
432
     * @param array $low   Low price, array of real values.
433
     * @param array $close Closing price, array of real values.
434
     *
435
     * @return array Returns an array with calculated data.
436
     */
437 2
    public function cdl3linestrike(array $open, array $high, array $low, array $close): array
438
    {
439 2
        $result = trader_cdl3linestrike($open, $high, $low, $close);
440
441 2
        $this->handleErrors();
442
443 2
        return $result;
444
    }
445
446
    /**
447
     * Three Outside Up/Down.
448
     *
449
     * @param array $open  Opening price, array of real values.
450
     * @param array $high  High price, array of real values.
451
     * @param array $low   Low price, array of real values.
452
     * @param array $close Closing price, array of real values.
453
     *
454
     * @return array Returns an array with calculated data.
455
     */
456 2
    public function cdl3outside(array $open, array $high, array $low, array $close): array
457
    {
458 2
        $result = trader_cdl3outside($open, $high, $low, $close);
459
460 2
        $this->handleErrors();
461
462 2
        return $result;
463
    }
464
465
    /**
466
     * Three Stars In The South.
467
     *
468
     * @param array $open  Opening price, array of real values.
469
     * @param array $high  High price, array of real values.
470
     * @param array $low   Low price, array of real values.
471
     * @param array $close Closing price, array of real values.
472
     *
473
     * @return array Returns an array with calculated data.
474
     */
475 2
    public function cdl3starsinsouth(array $open, array $high, array $low, array $close): array
476
    {
477 2
        $result = trader_cdl3starsinsouth($open, $high, $low, $close);
478
479 2
        $this->handleErrors();
480
481 2
        return $result;
482
    }
483
484
    /**
485
     * Three Advancing White Soldiers.
486
     *
487
     * @param array $open  Opening price, array of real values.
488
     * @param array $high  High price, array of real values.
489
     * @param array $low   Low price, array of real values.
490
     * @param array $close Closing price, array of real values.
491
     *
492
     * @return array Returns an array with calculated data.
493
     */
494 2
    public function cdl3whitesoldiers(array $open, array $high, array $low, array $close): array
495
    {
496 2
        $result = trader_cdl3whitesoldiers($open, $high, $low, $close);
497
498 2
        $this->handleErrors();
499
500 2
        return $result;
501
    }
502
503
    /**
504
     * Abandoned Baby.
505
     *
506
     * @param array $open        Opening price, array of real values.
507
     * @param array $high        High price, array of real values.
508
     * @param array $low         Low price, array of real values.
509
     * @param array $close       Closing price, array of real values.
510
     * @param float $penetration Percentage of penetration of a candle within another candle.
511
     *
512
     * @return array Returns an array with calculated data.
513
     */
514 2
    public function cdlabandonedbaby(
515
        array $open,
516
        array $high,
517
        array $low,
518
        array $close,
519
        float $penetration = 0.3
520
    ): array {
521 2
        $result = trader_cdlabandonedbaby($open, $high, $low, $close, $penetration);
522
523 2
        $this->handleErrors();
524
525 2
        return $result;
526
    }
527
528
    /**
529
     * Advance Block.
530
     *
531
     * @param array $open  Opening price, array of real values.
532
     * @param array $high  High price, array of real values.
533
     * @param array $low   Low price, array of real values.
534
     * @param array $close Closing price, array of real values.
535
     *
536
     * @return array Returns an array with calculated data.
537
     */
538 2
    public function cdladvanceblock(array $open, array $high, array $low, array $close): array
539
    {
540 2
        $result = trader_cdladvanceblock($open, $high, $low, $close);
541
542 2
        $this->handleErrors();
543
544 2
        return $result;
545
    }
546
547
    /**
548
     * Belt-hold.
549
     *
550
     * @param array $open  Opening price, array of real values.
551
     * @param array $high  High price, array of real values.
552
     * @param array $low   Low price, array of real values.
553
     * @param array $close Closing price, array of real values.
554
     *
555
     * @return array Returns an array with calculated data.
556
     */
557 2
    public function cdlbelthold(array $open, array $high, array $low, array $close): array
558
    {
559 2
        $result = trader_cdlbelthold($open, $high, $low, $close);
560
561 2
        $this->handleErrors();
562
563 2
        return $result;
564
    }
565
566
    /**
567
     * Breakaway.
568
     *
569
     * @param array $open  Opening price, array of real values.
570
     * @param array $high  High price, array of real values.
571
     * @param array $low   Low price, array of real values.
572
     * @param array $close Closing price, array of real values.
573
     *
574
     * @return array Returns an array with calculated data.
575
     */
576 2
    public function cdlbreakaway(array $open, array $high, array $low, array $close): array
577
    {
578 2
        $result = trader_cdlbreakaway($open, $high, $low, $close);
579
580 2
        $this->handleErrors();
581
582 2
        return $result;
583
    }
584
585
    /**
586
     * Closing Marubozu.
587
     *
588
     * @param array $open  Opening price, array of real values.
589
     * @param array $high  High price, array of real values.
590
     * @param array $low   Low price, array of real values.
591
     * @param array $close Closing price, array of real values.
592
     *
593
     * @return array Returns an array with calculated data.
594
     */
595 2
    public function cdlclosingmarubozu(array $open, array $high, array $low, array $close): array
596
    {
597 2
        $result = trader_cdlclosingmarubozu($open, $high, $low, $close);
598
599 2
        $this->handleErrors();
600
601 2
        return $result;
602
    }
603
604
    /**
605
     * Concealing Baby Swallow.
606
     *
607
     * @param array $open  Opening price, array of real values.
608
     * @param array $high  High price, array of real values.
609
     * @param array $low   Low price, array of real values.
610
     * @param array $close Closing price, array of real values.
611
     *
612
     * @return array Returns an array with calculated data.
613
     */
614 2
    public function cdlconcealbabyswall(array $open, array $high, array $low, array $close): array
615
    {
616 2
        $result = trader_cdlconcealbabyswall($open, $high, $low, $close);
617
618 2
        $this->handleErrors();
619
620 2
        return $result;
621
    }
622
623
    /**
624
     * Counterattack.
625
     *
626
     * @param array $open  Opening price, array of real values.
627
     * @param array $high  High price, array of real values.
628
     * @param array $low   Low price, array of real values.
629
     * @param array $close Closing price, array of real values.
630
     *
631
     * @return array Returns an array with calculated data.
632
     */
633 2
    public function cdlcounterattack(array $open, array $high, array $low, array $close): array
634
    {
635 2
        $result = trader_cdlcounterattack($open, $high, $low, $close);
636
637 2
        $this->handleErrors();
638
639 2
        return $result;
640
    }
641
642
    /**
643
     * Dark Cloud Cover.
644
     *
645
     * @param array $open        Opening price, array of real values.
646
     * @param array $high        High price, array of real values.
647
     * @param array $low         Low price, array of real values.
648
     * @param array $close       Closing price, array of real values.
649
     * @param float $penetration Percentage of penetration of a candle within another candle.
650
     *
651
     * @return array Returns an array with calculated data.
652
     */
653 2
    public function cdldarkcloudcover(
654
        array $open,
655
        array $high,
656
        array $low,
657
        array $close,
658
        float $penetration = 0.5
659
    ): array {
660 2
        $result = trader_cdldarkcloudcover($open, $high, $low, $close, $penetration);
661
662 2
        $this->handleErrors();
663
664 2
        return $result;
665
    }
666
667
    /**
668
     * Doji.
669
     *
670
     * @param array $open  Opening price, array of real values.
671
     * @param array $high  High price, array of real values.
672
     * @param array $low   Low price, array of real values.
673
     * @param array $close Closing price, array of real values.
674
     *
675
     * @return array Returns an array with calculated data.
676
     */
677 2
    public function cdldoji(array $open, array $high, array $low, array $close): array
678
    {
679 2
        $result = trader_cdldoji($open, $high, $low, $close);
680
681 2
        $this->handleErrors();
682
683 2
        return $result;
684
    }
685
686
    /**
687
     * Doji Star.
688
     *
689
     * @param array $open  Opening price, array of real values.
690
     * @param array $high  High price, array of real values.
691
     * @param array $low   Low price, array of real values.
692
     * @param array $close Closing price, array of real values.
693
     *
694
     * @return array Returns an array with calculated data.
695
     */
696 2
    public function cdldojistar(array $open, array $high, array $low, array $close): array
697
    {
698 2
        $result = trader_cdldojistar($open, $high, $low, $close);
699
700 2
        $this->handleErrors();
701
702 2
        return $result;
703
    }
704
705
    /**
706
     * Dragonfly Doji.
707
     *
708
     * @param array $open  Opening price, array of real values.
709
     * @param array $high  High price, array of real values.
710
     * @param array $low   Low price, array of real values.
711
     * @param array $close Closing price, array of real values.
712
     *
713
     * @return array Returns an array with calculated data.
714
     */
715 2
    public function cdldragonflydoji(array $open, array $high, array $low, array $close): array
716
    {
717 2
        $result = trader_cdldragonflydoji($open, $high, $low, $close);
718
719 2
        $this->handleErrors();
720
721 2
        return $result;
722
    }
723
724
    /**
725
     * Engulfing Pattern.
726
     *
727
     * @param array $open  Opening price, array of real values.
728
     * @param array $high  High price, array of real values.
729
     * @param array $low   Low price, array of real values.
730
     * @param array $close Closing price, array of real values.
731
     *
732
     * @return array Returns an array with calculated data.
733
     */
734 2
    public function cdlengulfing(array $open, array $high, array $low, array $close): array
735
    {
736 2
        $result = trader_cdlengulfing($open, $high, $low, $close);
737
738 2
        $this->handleErrors();
739
740 2
        return $result;
741
    }
742
743
    /**
744
     * Evening Doji Star.
745
     *
746
     * @param array $open        Opening price, array of real values.
747
     * @param array $high        High price, array of real values.
748
     * @param array $low         Low price, array of real values.
749
     * @param array $close       Closing price, array of real values.
750
     * @param float $penetration Percentage of penetration of a candle within another candle.
751
     *
752
     * @return array Returns an array with calculated data.
753
     */
754 2
    public function cdleveningdojistar(
755
        array $open,
756
        array $high,
757
        array $low,
758
        array $close,
759
        float $penetration = 0.3
760
    ): array {
761 2
        $result = trader_cdleveningdojistar($open, $high, $low, $close, $penetration);
762
763 2
        $this->handleErrors();
764
765 2
        return $result;
766
    }
767
768
    /**
769
     * Evening Star.
770
     *
771
     * @param array $open        Opening price, array of real values.
772
     * @param array $high        High price, array of real values.
773
     * @param array $low         Low price, array of real values.
774
     * @param array $close       Closing price, array of real values.
775
     * @param float $penetration [OPTIONAL] [DEFAULT 0.3] Percentage of penetration of a candle within another candle.
776
     *
777
     * @return array Returns an array with calculated data.
778
     */
779 2
    public function cdleveningstar(
780
        array $open,
781
        array $high,
782
        array $low,
783
        array $close,
784
        float $penetration = 0.3
785
    ): array {
786 2
        $result = trader_cdleveningstar($open, $high, $low, $close, $penetration);
787
788 2
        $this->handleErrors();
789
790 2
        return $result;
791
    }
792
793
    /**
794
     * Up/Down-gap side-by-side white lines.
795
     *
796
     * @param array $open  Opening price, array of real values.
797
     * @param array $high  High price, array of real values.
798
     * @param array $low   Low price, array of real values.
799
     * @param array $close Closing price, array of real values.
800
     *
801
     * @return array Returns an array with calculated data.
802
     */
803 2
    public function cdlgapsidesidewhite(array $open, array $high, array $low, array $close): array
804
    {
805 2
        $result = trader_cdlgapsidesidewhite($open, $high, $low, $close);
806
807 2
        $this->handleErrors();
808
809 2
        return $result;
810
    }
811
812
    /**
813
     * Gravestone Doji.
814
     *
815
     * @param array $open  Opening price, array of real values.
816
     * @param array $high  High price, array of real values.
817
     * @param array $low   Low price, array of real values.
818
     * @param array $close Closing price, array of real values.
819
     *
820
     * @return array Returns an array with calculated data.
821
     */
822 2
    public function cdlgravestonedoji(array $open, array $high, array $low, array $close): array
823
    {
824 2
        $result = trader_cdlgravestonedoji($open, $high, $low, $close);
825
826 2
        $this->handleErrors();
827
828 2
        return $result;
829
    }
830
831
    /**
832
     * Hammer.
833
     *
834
     * @param array $open  Opening price, array of real values.
835
     * @param array $high  High price, array of real values.
836
     * @param array $low   Low price, array of real values.
837
     * @param array $close Closing price, array of real values.
838
     *
839
     * @return array Returns an array with calculated data.
840
     */
841 2
    public function cdlhammer(array $open, array $high, array $low, array $close): array
842
    {
843 2
        $result = trader_cdlhammer($open, $high, $low, $close);
844
845 2
        $this->handleErrors();
846
847 2
        return $result;
848
    }
849
850
    /**
851
     * Hanging Man.
852
     *
853
     * @param array $open  Opening price, array of real values.
854
     * @param array $high  High price, array of real values.
855
     * @param array $low   Low price, array of real values.
856
     * @param array $close Closing price, array of real values.
857
     *
858
     * @return array Returns an array with calculated data.
859
     */
860 2
    public function cdlhangingman(array $open, array $high, array $low, array $close): array
861
    {
862 2
        $result = trader_cdlhangingman($open, $high, $low, $close);
863
864 2
        $this->handleErrors();
865
866 2
        return $result;
867
    }
868
869
    /**
870
     * Harami Pattern.
871
     *
872
     * @param array $open  Opening price, array of real values.
873
     * @param array $high  High price, array of real values.
874
     * @param array $low   Low price, array of real values.
875
     * @param array $close Closing price, array of real values.
876
     *
877
     * @return array Returns an array with calculated data.
878
     */
879 2
    public function cdlharami(array $open, array $high, array $low, array $close): array
880
    {
881 2
        $result = trader_cdlharami($open, $high, $low, $close);
882
883 2
        $this->handleErrors();
884
885 2
        return $result;
886
    }
887
888
    /**
889
     * Harami Cross Pattern.
890
     *
891
     * @param array $open  Opening price, array of real values.
892
     * @param array $high  High price, array of real values.
893
     * @param array $low   Low price, array of real values.
894
     * @param array $close Closing price, array of real values.
895
     *
896
     * @return array Returns an array with calculated data.
897
     */
898 2
    public function cdlharamicross(array $open, array $high, array $low, array $close): array
899
    {
900 2
        $result = trader_cdlharamicross($open, $high, $low, $close);
901
902 2
        $this->handleErrors();
903
904 2
        return $result;
905
    }
906
907
    /**
908
     * High-Wave Candle.
909
     *
910
     * @param array $open  Opening price, array of real values.
911
     * @param array $high  High price, array of real values.
912
     * @param array $low   Low price, array of real values.
913
     * @param array $close Closing price, array of real values.
914
     *
915
     * @return array Returns an array with calculated data.
916
     */
917 2
    public function cdlhighwave(array $open, array $high, array $low, array $close): array
918
    {
919 2
        $result = trader_cdlhighwave($open, $high, $low, $close);
920
921 2
        $this->handleErrors();
922
923 2
        return $result;
924
    }
925
926
    /**
927
     * Hikkake Pattern.
928
     *
929
     * @param array $open  Opening price, array of real values.
930
     * @param array $high  High price, array of real values.
931
     * @param array $low   Low price, array of real values.
932
     * @param array $close Closing price, array of real values.
933
     *
934
     * @return array Returns an array with calculated data.
935
     */
936 2
    public function cdlhikkake(array $open, array $high, array $low, array $close): array
937
    {
938 2
        $result = trader_cdlhikkake($open, $high, $low, $close);
939
940 2
        $this->handleErrors();
941
942 2
        return $result;
943
    }
944
945
    /**
946
     * Modified Hikkake Pattern.
947
     *
948
     * @param array $open  Opening price, array of real values.
949
     * @param array $high  High price, array of real values.
950
     * @param array $low   Low price, array of real values.
951
     * @param array $close Closing price, array of real values.
952
     *
953
     * @return array Returns an array with calculated data.
954
     */
955 2
    public function cdlhikkakemod(array $open, array $high, array $low, array $close): array
956
    {
957 2
        $result = trader_cdlhikkakemod($open, $high, $low, $close);
958
959 2
        $this->handleErrors();
960
961 2
        return $result;
962
    }
963
964
    /**
965
     * Homing Pigeon.
966
     *
967
     * @param array $open  Opening price, array of real values.
968
     * @param array $high  High price, array of real values.
969
     * @param array $low   Low price, array of real values.
970
     * @param array $close Closing price, array of real values.
971
     *
972
     * @return array Returns an array with calculated data.
973
     */
974 2
    public function cdlhomingpigeon(array $open, array $high, array $low, array $close): array
975
    {
976 2
        $result = trader_cdlhomingpigeon($open, $high, $low, $close);
977
978 2
        $this->handleErrors();
979
980 2
        return $result;
981
    }
982
983
    /**
984
     * Identical Three Crows.
985
     *
986
     * @param array $open  Opening price, array of real values.
987
     * @param array $high  High price, array of real values.
988
     * @param array $low   Low price, array of real values.
989
     * @param array $close Closing price, array of real values.
990
     *
991
     * @return array Returns an array with calculated data.
992
     */
993 2
    public function cdlidentical3crows(array $open, array $high, array $low, array $close): array
994
    {
995 2
        $result = trader_cdlidentical3crows($open, $high, $low, $close);
996
997 2
        $this->handleErrors();
998
999 2
        return $result;
1000
    }
1001
1002
    /**
1003
     * In-Neck Pattern.
1004
     *
1005
     * @param array $open  Opening price, array of real values.
1006
     * @param array $high  High price, array of real values.
1007
     * @param array $low   Low price, array of real values.
1008
     * @param array $close Closing price, array of real values.
1009
     *
1010
     * @return array Returns an array with calculated data.
1011
     */
1012 2
    public function cdlinneck(array $open, array $high, array $low, array $close): array
1013
    {
1014 2
        $result = trader_cdlinneck($open, $high, $low, $close);
1015
1016 2
        $this->handleErrors();
1017
1018 2
        return $result;
1019
    }
1020
1021
    /**
1022
     * Inverted Hammer.
1023
     *
1024
     * @param array $open  Opening price, array of real values.
1025
     * @param array $high  High price, array of real values.
1026
     * @param array $low   Low price, array of real values.
1027
     * @param array $close Closing price, array of real values.
1028
     *
1029
     * @return array Returns an array with calculated data.
1030
     */
1031 2
    public function cdlinvertedhammer(array $open, array $high, array $low, array $close): array
1032
    {
1033 2
        $result = trader_cdlinvertedhammer($open, $high, $low, $close);
1034
1035 2
        $this->handleErrors();
1036
1037 2
        return $result;
1038
    }
1039
1040
    /**
1041
     * Kicking.
1042
     *
1043
     * @param array $open  Opening price, array of real values.
1044
     * @param array $high  High price, array of real values.
1045
     * @param array $low   Low price, array of real values.
1046
     * @param array $close Closing price, array of real values.
1047
     *
1048
     * @return array Returns an array with calculated data.
1049
     */
1050 2
    public function cdlkicking(array $open, array $high, array $low, array $close): array
1051
    {
1052 2
        $result = trader_cdlkicking($open, $high, $low, $close);
1053
1054 2
        $this->handleErrors();
1055
1056 2
        return $result;
1057
    }
1058
1059
    /**
1060
     * Kicking - bull/bear determined by the longer marubozu.
1061
     *
1062
     * @param array $open  Opening price, array of real values.
1063
     * @param array $high  High price, array of real values.
1064
     * @param array $low   Low price, array of real values.
1065
     * @param array $close Closing price, array of real values.
1066
     *
1067
     * @return array Returns an array with calculated data.
1068
     */
1069 2
    public function cdlkickingbylength(array $open, array $high, array $low, array $close): array
1070
    {
1071 2
        $result = trader_cdlkickingbylength($open, $high, $low, $close);
1072
1073 2
        $this->handleErrors();
1074
1075 2
        return $result;
1076
    }
1077
1078
    /**
1079
     * Ladder Bottom.
1080
     *
1081
     * @param array $open  Opening price, array of real values.
1082
     * @param array $high  High price, array of real values.
1083
     * @param array $low   Low price, array of real values.
1084
     * @param array $close Closing price, array of real values.
1085
     *
1086
     * @return array Returns an array with calculated data.
1087
     */
1088 2
    public function cdlladderbottom(array $open, array $high, array $low, array $close): array
1089
    {
1090 2
        $result = trader_cdlladderbottom($open, $high, $low, $close);
1091
1092 2
        $this->handleErrors();
1093
1094 2
        return $result;
1095
    }
1096
1097
    /**
1098
     * Long Legged Doji.
1099
     *
1100
     * @param array $open  Opening price, array of real values.
1101
     * @param array $high  High price, array of real values.
1102
     * @param array $low   Low price, array of real values.
1103
     * @param array $close Closing price, array of real values.
1104
     *
1105
     * @return array Returns an array with calculated data.
1106
     */
1107 2
    public function cdllongleggeddoji(array $open, array $high, array $low, array $close): array
1108
    {
1109 2
        $result = trader_cdllongleggeddoji($open, $high, $low, $close);
1110
1111 2
        $this->handleErrors();
1112
1113 2
        return $result;
1114
    }
1115
1116
    /**
1117
     * Long Line Candle.
1118
     *
1119
     * @param array $open  Opening price, array of real values.
1120
     * @param array $high  High price, array of real values.
1121
     * @param array $low   Low price, array of real values.
1122
     * @param array $close Closing price, array of real values.
1123
     *
1124
     * @return array Returns an array with calculated data.
1125
     */
1126 2
    public function cdllongline(array $open, array $high, array $low, array $close): array
1127
    {
1128 2
        $result = trader_cdllongline($open, $high, $low, $close);
1129
1130 2
        $this->handleErrors();
1131
1132 2
        return $result;
1133
    }
1134
1135
    /**
1136
     * Marubozu.
1137
     *
1138
     * @param array $open  Opening price, array of real values.
1139
     * @param array $high  High price, array of real values.
1140
     * @param array $low   Low price, array of real values.
1141
     * @param array $close Closing price, array of real values.
1142
     *
1143
     * @return array Returns an array with calculated data.
1144
     */
1145 2
    public function cdlmarubozu(array $open, array $high, array $low, array $close): array
1146
    {
1147 2
        $result = trader_cdlmarubozu($open, $high, $low, $close);
1148
1149 2
        $this->handleErrors();
1150
1151 2
        return $result;
1152
    }
1153
1154
    /**
1155
     * Matching Low.
1156
     *
1157
     * @param array $open  Opening price, array of real values.
1158
     * @param array $high  High price, array of real values.
1159
     * @param array $low   Low price, array of real values.
1160
     * @param array $close Closing price, array of real values.
1161
     *
1162
     * @return array Returns an array with calculated data.
1163
     */
1164 2
    public function cdlmatchinglow(array $open, array $high, array $low, array $close): array
1165
    {
1166 2
        $result = trader_cdlmatchinglow($open, $high, $low, $close);
1167
1168 2
        $this->handleErrors();
1169
1170 2
        return $result;
1171
    }
1172
1173
    /**
1174
     * Mat Hold.
1175
     *
1176
     * @param array $open        Opening price, array of real values.
1177
     * @param array $high        High price, array of real values.
1178
     * @param array $low         Low price, array of real values.
1179
     * @param array $close       Closing price, array of real values.
1180
     * @param float $penetration Percentage of penetration of a candle within another candle.
1181
     *
1182
     * @return array Returns an array with calculated data.
1183
     */
1184 2
    public function cdlmathold(
1185
        array $open,
1186
        array $high,
1187
        array $low,
1188
        array $close,
1189
        float $penetration = 0.5
1190
    ): array {
1191 2
        $result = trader_cdlmathold($open, $high, $low, $close, $penetration);
1192
1193 2
        $this->handleErrors();
1194
1195 2
        return $result;
1196
    }
1197
1198
    /**
1199
     * Morning Doji Star.
1200
     *
1201
     * @param array $open        Opening price, array of real values.
1202
     * @param array $high        High price, array of real values.
1203
     * @param array $low         Low price, array of real values.
1204
     * @param array $close       Closing price, array of real values.
1205
     * @param float $penetration [OPTIONAL] [DEFAULT 0.3] Percentage of penetration of a candle within another candle.
1206
     *
1207
     * @return array Returns an array with calculated data.
1208
     */
1209 2
    public function cdlmorningdojistar(
1210
        array $open,
1211
        array $high,
1212
        array $low,
1213
        array $close,
1214
        float $penetration = 0.3
1215
    ): array {
1216 2
        $result = trader_cdlmorningdojistar($open, $high, $low, $close, $penetration);
1217
1218 2
        $this->handleErrors();
1219
1220 2
        return $result;
1221
    }
1222
1223
    /**
1224
     * Morning Star.
1225
     *
1226
     * @param array $open        Opening price, array of real values.
1227
     * @param array $high        High price, array of real values.
1228
     * @param array $low         Low price, array of real values.
1229
     * @param array $close       Closing price, array of real values.
1230
     * @param float $penetration Percentage of penetration of a candle within another candle.
1231
     *
1232
     * @return array Returns an array with calculated data.
1233
     */
1234 2
    public function cdlmorningstar(
1235
        array $open,
1236
        array $high,
1237
        array $low,
1238
        array $close,
1239
        float $penetration = 0.3
1240
    ): array {
1241 2
        $result = trader_cdlmorningstar($open, $high, $low, $close, $penetration);
1242
1243 2
        $this->handleErrors();
1244
1245 2
        return $result;
1246
    }
1247
1248
    /**
1249
     * On-Neck Pattern.
1250
     *
1251
     * @param array $open  Opening price, array of real values.
1252
     * @param array $high  High price, array of real values.
1253
     * @param array $low   Low price, array of real values.
1254
     * @param array $close Closing price, array of real values.
1255
     *
1256
     * @return array Returns an array with calculated data.
1257
     */
1258 2
    public function cdlonneck(array $open, array $high, array $low, array $close): array
1259
    {
1260 2
        $result = trader_cdlonneck($open, $high, $low, $close);
1261
1262 2
        $this->handleErrors();
1263
1264 2
        return $result;
1265
    }
1266
1267
    /**
1268
     * Piercing Pattern.
1269
     *
1270
     * @param array $open  Opening price, array of real values.
1271
     * @param array $high  High price, array of real values.
1272
     * @param array $low   Low price, array of real values.
1273
     * @param array $close Closing price, array of real values.
1274
     *
1275
     * @return array Returns an array with calculated data.
1276
     */
1277 2
    public function cdlpiercing(array $open, array $high, array $low, array $close): array
1278
    {
1279 2
        $result = trader_cdlpiercing($open, $high, $low, $close);
1280
1281 2
        $this->handleErrors();
1282
1283 2
        return $result;
1284
    }
1285
1286
    /**
1287
     * Rickshaw Man.
1288
     *
1289
     * @param array $open  Opening price, array of real values.
1290
     * @param array $high  High price, array of real values.
1291
     * @param array $low   Low price, array of real values.
1292
     * @param array $close Closing price, array of real values.
1293
     *
1294
     * @return array Returns an array with calculated data.
1295
     */
1296 2
    public function cdlrickshawman(array $open, array $high, array $low, array $close): array
1297
    {
1298 2
        $result = trader_cdlrickshawman($open, $high, $low, $close);
1299
1300 2
        $this->handleErrors();
1301
1302 2
        return $result;
1303
    }
1304
1305
    /**
1306
     * Rising/Falling Three Methods.
1307
     *
1308
     * @param array $open  Opening price, array of real values.
1309
     * @param array $high  High price, array of real values.
1310
     * @param array $low   Low price, array of real values.
1311
     * @param array $close Closing price, array of real values.
1312
     *
1313
     * @return array Returns an array with calculated data.
1314
     */
1315 2
    public function cdlrisefall3methods(array $open, array $high, array $low, array $close): array
1316
    {
1317 2
        $result = trader_cdlrisefall3methods($open, $high, $low, $close);
1318
1319 2
        $this->handleErrors();
1320
1321 2
        return $result;
1322
    }
1323
1324
    /**
1325
     * Separating Lines.
1326
     *
1327
     * @param array $open  Opening price, array of real values.
1328
     * @param array $high  High price, array of real values.
1329
     * @param array $low   Low price, array of real values.
1330
     * @param array $close Closing price, array of real values.
1331
     *
1332
     * @return array Returns an array with calculated data.
1333
     */
1334 2
    public function cdlseparatinglines(array $open, array $high, array $low, array $close): array
1335
    {
1336 2
        $result = trader_cdlseparatinglines($open, $high, $low, $close);
1337
1338 2
        $this->handleErrors();
1339
1340 2
        return $result;
1341
    }
1342
1343
    /**
1344
     * Shooting Star.
1345
     *
1346
     * @param array $open  Opening price, array of real values.
1347
     * @param array $high  High price, array of real values.
1348
     * @param array $low   Low price, array of real values.
1349
     * @param array $close Closing price, array of real values.
1350
     *
1351
     * @return array Returns an array with calculated data.
1352
     */
1353 2
    public function cdlshootingstar(array $open, array $high, array $low, array $close): array
1354
    {
1355 2
        $result = trader_cdlshootingstar($open, $high, $low, $close);
1356
1357 2
        $this->handleErrors();
1358
1359 2
        return $result;
1360
    }
1361
1362
    /**
1363
     * Short Line Candle.
1364
     *
1365
     * @param array $open  Opening price, array of real values.
1366
     * @param array $high  High price, array of real values.
1367
     * @param array $low   Low price, array of real values.
1368
     * @param array $close Closing price, array of real values.
1369
     *
1370
     * @return array Returns an array with calculated data.
1371
     */
1372 2
    public function cdlshortline(array $open, array $high, array $low, array $close): array
1373
    {
1374 2
        $result = trader_cdlshortline($open, $high, $low, $close);
1375
1376 2
        $this->handleErrors();
1377
1378 2
        return $result;
1379
    }
1380
1381
    /**
1382
     * Spinning Top.
1383
     *
1384
     * @param array $open  Opening price, array of real values.
1385
     * @param array $high  High price, array of real values.
1386
     * @param array $low   Low price, array of real values.
1387
     * @param array $close Closing price, array of real values.
1388
     *
1389
     * @return array Returns an array with calculated data.
1390
     */
1391 2
    public function cdlspinningtop(array $open, array $high, array $low, array $close): array
1392
    {
1393 2
        $result = trader_cdlspinningtop($open, $high, $low, $close);
1394
1395 2
        $this->handleErrors();
1396
1397 2
        return $result;
1398
    }
1399
1400
    /**
1401
     * Stalled Pattern.
1402
     *
1403
     * @param array $open  Opening price, array of real values.
1404
     * @param array $high  High price, array of real values.
1405
     * @param array $low   Low price, array of real values.
1406
     * @param array $close Closing price, array of real values.
1407
     *
1408
     * @return array Returns an array with calculated data.
1409
     */
1410 2
    public function cdlstalledpattern(array $open, array $high, array $low, array $close): array
1411
    {
1412 2
        $result = trader_cdlstalledpattern($open, $high, $low, $close);
1413
1414 2
        $this->handleErrors();
1415
1416 2
        return $result;
1417
    }
1418
1419
    /**
1420
     * Stick Sandwich.
1421
     *
1422
     * @param array $open  Opening price, array of real values.
1423
     * @param array $high  High price, array of real values.
1424
     * @param array $low   Low price, array of real values.
1425
     * @param array $close Closing price, array of real values.
1426
     *
1427
     * @return array Returns an array with calculated data.
1428
     */
1429 2
    public function cdlsticksandwich(array $open, array $high, array $low, array $close): array
1430
    {
1431 2
        $result = trader_cdlsticksandwich($open, $high, $low, $close);
1432
1433 2
        $this->handleErrors();
1434
1435 2
        return $result;
1436
    }
1437
1438
    /**
1439
     * Takuri (Dragonfly Doji with very long lower shadow).
1440
     *
1441
     * @param array $open  Opening price, array of real values.
1442
     * @param array $high  High price, array of real values.
1443
     * @param array $low   Low price, array of real values.
1444
     * @param array $close Closing price, array of real values.
1445
     *
1446
     * @return array Returns an array with calculated data.
1447
     */
1448 2
    public function cdltakuri(array $open, array $high, array $low, array $close): array
1449
    {
1450 2
        $result = trader_cdltakuri($open, $high, $low, $close);
1451
1452 2
        $this->handleErrors();
1453
1454 2
        return $result;
1455
    }
1456
1457
    /**
1458
     * Tasuki Gap.
1459
     *
1460
     * @param array $open  Opening price, array of real values.
1461
     * @param array $high  High price, array of real values.
1462
     * @param array $low   Low price, array of real values.
1463
     * @param array $close Closing price, array of real values.
1464
     *
1465
     * @return array Returns an array with calculated data.
1466
     */
1467 2
    public function cdltasukigap(array $open, array $high, array $low, array $close): array
1468
    {
1469 2
        $result = trader_cdltasukigap($open, $high, $low, $close);
1470
1471 2
        $this->handleErrors();
1472
1473 2
        return $result;
1474
    }
1475
1476
    /**
1477
     * Thrusting Pattern.
1478
     *
1479
     * @param array $open  Opening price, array of real values.
1480
     * @param array $high  High price, array of real values.
1481
     * @param array $low   Low price, array of real values.
1482
     * @param array $close Closing price, array of real values.
1483
     *
1484
     * @return array Returns an array with calculated data.
1485
     */
1486 2
    public function cdlthrusting(array $open, array $high, array $low, array $close): array
1487
    {
1488 2
        $result = trader_cdlthrusting($open, $high, $low, $close);
1489
1490 2
        $this->handleErrors();
1491
1492 2
        return $result;
1493
    }
1494
1495
    /**
1496
     * Tristar Pattern.
1497
     *
1498
     * @param array $open  Opening price, array of real values.
1499
     * @param array $high  High price, array of real values.
1500
     * @param array $low   Low price, array of real values.
1501
     * @param array $close Closing price, array of real values.
1502
     *
1503
     * @return array Returns an array with calculated data.
1504
     */
1505 2
    public function cdltristar(array $open, array $high, array $low, array $close): array
1506
    {
1507 2
        $result = trader_cdltristar($open, $high, $low, $close);
1508
1509 2
        $this->handleErrors();
1510
1511 2
        return $result;
1512
    }
1513
1514
    /**
1515
     * Unique 3 River.
1516
     *
1517
     * @param array $open  Opening price, array of real values.
1518
     * @param array $high  High price, array of real values.
1519
     * @param array $low   Low price, array of real values.
1520
     * @param array $close Closing price, array of real values.
1521
     *
1522
     * @return array Returns an array with calculated data.
1523
     */
1524 2
    public function cdlunique3river(array $open, array $high, array $low, array $close): array
1525
    {
1526 2
        $result = trader_cdlunique3river($open, $high, $low, $close);
1527
1528 2
        $this->handleErrors();
1529
1530 2
        return $result;
1531
    }
1532
1533
    /**
1534
     * Upside Gap Two Crows.
1535
     *
1536
     * @param array $open  Opening price, array of real values.
1537
     * @param array $high  High price, array of real values.
1538
     * @param array $low   Low price, array of real values.
1539
     * @param array $close Closing price, array of real values.
1540
     *
1541
     * @return array Returns an array with calculated data.
1542
     */
1543 2
    public function cdlupsidegap2crows(array $open, array $high, array $low, array $close): array
1544
    {
1545 2
        $result = trader_cdlupsidegap2crows($open, $high, $low, $close);
1546
1547 2
        $this->handleErrors();
1548
1549 2
        return $result;
1550
    }
1551
1552
    /**
1553
     * Upside/Downside Gap Three Methods.
1554
     *
1555
     * @param array $open  Opening price, array of real values.
1556
     * @param array $high  High price, array of real values.
1557
     * @param array $low   Low price, array of real values.
1558
     * @param array $close Closing price, array of real values.
1559
     *
1560
     * @return array Returns an array with calculated data.
1561
     */
1562 2
    public function cdlxsidegap3methods(array $open, array $high, array $low, array $close): array
1563
    {
1564 2
        $result = trader_cdlxsidegap3methods($open, $high, $low, $close);
1565
1566 2
        $this->handleErrors();
1567
1568 2
        return $result;
1569
    }
1570
1571
    /**
1572
     * Vector Ceil.
1573
     *
1574
     * Calculates the next highest integer for each value in real and returns the resulting array.
1575
     *
1576
     * @param array $real Array of real values.
1577
     *
1578
     * @return array Returns an array with calculated data.
1579
     */
1580 2
    public function ceil(array $real): array
1581
    {
1582 2
        $result = trader_ceil($real);
1583
1584 2
        $this->handleErrors();
1585
1586 2
        return $result;
1587
    }
1588
1589
    /**
1590
     * Chande Momentum Oscillator.
1591
     *
1592
     * @param array $real       Array of real values.
1593
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1594
     *
1595
     * @return array Returns an array with calculated data.
1596
     */
1597 2
    public function cmo(array $real, int $timePeriod = 14): array
1598
    {
1599 2
        $result = trader_cmo($real, $timePeriod);
1600
1601 2
        $this->handleErrors();
1602
1603 2
        return $result;
1604
    }
1605
1606
    /**
1607
     * Pearson's Correlation Coefficient (r).
1608
     *
1609
     * @param array $real0      Array of real values.
1610
     * @param array $real1      Array of real values.
1611
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1612
     *
1613
     * @return array Returns an array with calculated data.
1614
     */
1615 2
    public function correl(array $real0, array $real1, int $timePeriod = 30): array
1616
    {
1617 2
        $result = trader_correl($real0, $real1, $timePeriod);
1618
1619 2
        $this->handleErrors();
1620
1621 2
        return $result;
1622
    }
1623
1624
    /**
1625
     * Vector Trigonometric Cos.
1626
     *
1627
     * Calculates the cosine for each value in real and returns the resulting array.
1628
     *
1629
     * @param array $real Array of real values.
1630
     *
1631
     * @return array Returns an array with calculated data.
1632
     */
1633 2
    public function cos(array $real): array
1634
    {
1635 2
        $result = trader_cos($real);
1636
1637 2
        $this->handleErrors();
1638
1639 2
        return $result;
1640
    }
1641
1642
    /**
1643
     * Vector Trigonometric Cosh.
1644
     *
1645
     * Calculates the hyperbolic cosine for each value in real and returns the resulting array.
1646
     *
1647
     * @param array $real Array of real values.
1648
     *
1649
     * @return array Returns an array with calculated data.
1650
     */
1651 2
    public function cosh(array $real): array
1652
    {
1653 2
        $result = trader_cosh($real);
1654
1655 2
        $this->handleErrors();
1656
1657 2
        return $result;
1658
    }
1659
1660
    /**
1661
     * Double Exponential Moving Average.
1662
     *
1663
     * @param array $real       Array of real values.
1664
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1665
     *
1666
     * @return array Returns an array with calculated data.
1667
     */
1668 2
    public function dema(array $real, int $timePeriod = 30): array
1669
    {
1670 2
        $result = trader_dema($real, $timePeriod);
1671
1672 2
        $this->handleErrors();
1673
1674 2
        return $result;
1675
    }
1676
1677
    /**
1678
     * Vector Arithmetic Div.
1679
     *
1680
     * Divides each value from real0 by the corresponding value from real1 and returns the resulting array.
1681
     *
1682
     * @param array $real0 Array of real values.
1683
     * @param array $real1 Array of real values.
1684
     *
1685
     * @return array Returns an array with calculated data.
1686
     */
1687 2
    public function div(array $real0, array $real1): array
1688
    {
1689 2
        $result = trader_div($real0, $real1);
1690
1691 2
        $this->handleErrors();
1692
1693 2
        return $result;
1694
    }
1695
1696
    /**
1697
     * Directional Movement Index.
1698
     *
1699
     * @param array $high       High price, array of real values.
1700
     * @param array $low        Low price, array of real values.
1701
     * @param array $close      Closing price, array of real values.
1702
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1703
     *
1704
     * @return array  Returns an array with calculated data.
1705
     */
1706 2
    public function dx(array $high, array $low, array $close, int $timePeriod = 14): array
1707
    {
1708 2
        $result = trader_dx($high, $low, $close, $timePeriod);
1709
1710 2
        $this->handleErrors();
1711
1712 2
        return $result;
1713
    }
1714
1715
    /**
1716
     * Exponential Moving Average.
1717
     *
1718
     * @param array $real       Array of real values.
1719
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1720
     *
1721
     * @return array Returns an array with calculated data.
1722
     */
1723 2
    public function ema(array $real, int $timePeriod = 30): array
1724
    {
1725 2
        $result = trader_ema($real, $timePeriod);
1726
1727 2
        $this->handleErrors();
1728
1729 2
        return $result;
1730
    }
1731
1732
    /**
1733
     * Get error code.
1734
     *
1735
     * Get error code of the last operation.
1736
     *
1737
     * @return int Returns the error code identified by one of the ERR_* constants.
1738
     */
1739 2
    public function errno(): int
1740
    {
1741 2
        return trader_errno();
1742
    }
1743
1744
    /**
1745
     * Vector Arithmetic Exp.
1746
     *
1747
     * Calculates e raised to the power of each value in real. Returns an array with the calculated data.
1748
     *
1749
     * @param array $real Array of real values.
1750
     *
1751
     * @return array Returns an array with calculated data.
1752
     */
1753 2
    public function exp(array $real): array
1754
    {
1755 2
        $result = trader_exp($real);
1756
1757 2
        $this->handleErrors();
1758
1759 2
        return $result;
1760
    }
1761
1762
    /**
1763
     * Vector Floor.
1764
     *
1765
     * Calculates the next lowest integer for each value in real and returns the resulting array.
1766
     *
1767
     * @param array $real Array of real values.
1768
     *
1769
     * @return array Returns an array with calculated data.
1770
     */
1771 2
    public function floor(array $real): array
1772
    {
1773 2
        $result = trader_floor($real);
1774
1775 2
        $this->handleErrors();
1776
1777 2
        return $result;
1778
    }
1779
1780
    /**
1781
     * Get compatibility mode.
1782
     *
1783
     * Get compatibility mode which affects the way calculations are done by all the extension functions.
1784
     *
1785
     * @return int Returns the compatibility mode id which can be identified by COMPATIBILITY_* series of constants.
1786
     */
1787 2
    public function get_compat(): int
1788
    {
1789 2
        return trader_get_compat();
1790
    }
1791
1792
    /**
1793
     * Get unstable period.
1794
     *
1795
     * Get unstable period factor for a particular function.
1796
     *
1797
     * @param int $functionId Function ID the factor to be read for. FUNC_UNST_* series of constants should be used.
1798
     *
1799
     * @return int Returns the unstable period factor for the corresponding function.
1800
     */
1801 2
    public function get_unstable_period(int $functionId): int
1802
    {
1803 2
        return trader_get_unstable_period($functionId);
1804
    }
1805
1806
    /**
1807
     * Hilbert Transform - Dominant Cycle Period.
1808
     *
1809
     * @param array $real Array of real values.
1810
     *
1811
     * @return array Returns an array with calculated data.
1812
     */
1813 2
    public function ht_dcperiod(array $real): array
1814
    {
1815 2
        $result = trader_ht_dcperiod($real);
1816
1817 2
        $this->handleErrors();
1818
1819 2
        return $result;
1820
    }
1821
1822
    /**
1823
     * Hilbert Transform - Dominant Cycle Phase.
1824
     *
1825
     * @param array $real Array of real values.
1826
     *
1827
     * @return array Returns an array with calculated data.
1828
     */
1829 2
    public function ht_dcphase(array $real): array
1830
    {
1831 2
        $result = trader_ht_dcphase($real);
1832
1833 2
        $this->handleErrors();
1834
1835 2
        return $result;
1836
    }
1837
1838
    /**
1839
     * Hilbert Transform - Phasor Components.
1840
     *
1841
     * @param array $open  Opening price, array of real values.
1842
     * @param array $close Closing price, array of real values.
1843
     *
1844
     * @return array Returns an array with calculated data.
1845
     */
1846 2
    public function ht_phasor(array $open, array $close): array
1847
    {
1848 2
        $result = trader_ht_phasor($open, $close);
1849
1850 2
        $this->handleErrors();
1851
1852 2
        return $result;
1853
    }
1854
1855
    /**
1856
     * Hilbert Transform - Phasor Components.
1857
     *
1858
     * @param array $open  Opening price, array of real values.
1859
     * @param array $close Closing price, array of real values.
1860
     *
1861
     * @return array Returns an array with calculated data.
1862
     */
1863 2
    public function ht_sine(array $open, array $close): array
1864
    {
1865 2
        $result = trader_ht_sine($open, $close);
1866
1867 2
        $this->handleErrors();
1868
1869 2
        return $result;
1870
    }
1871
1872
    /**
1873
     * Hilbert Transform - Instantaneous Trendline.
1874
     *
1875
     * @param array $real Array of real values.
1876
     *
1877
     * @return array Returns an array with calculated data.
1878
     */
1879 2
    public function ht_trendline(array $real): array
1880
    {
1881 2
        $result = trader_ht_trendline($real);
1882
1883 2
        $this->handleErrors();
1884
1885 2
        return $result;
1886
    }
1887
1888
    /**
1889
     * Hilbert Transform - Trend vs Cycle Mode.
1890
     *
1891
     * @param array $real Array of real values.
1892
     *
1893
     * @return array Returns an array with calculated data.
1894
     */
1895 2
    public function ht_trendmode(array $real): array
1896
    {
1897 2
        $result = trader_ht_trendmode($real);
1898
1899 2
        $this->handleErrors();
1900
1901 2
        return $result;
1902
    }
1903
1904
    /**
1905
     * Kaufman Adaptive Moving Average.
1906
     *
1907
     * @param array $real       Array of real values.
1908
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1909
     *
1910
     * @return array Returns an array with calculated data.
1911
     */
1912 2
    public function kama(array $real, int $timePeriod = 30): array
1913
    {
1914 2
        $result = trader_kama($real, $timePeriod);
1915
1916 2
        $this->handleErrors();
1917
1918 2
        return $result;
1919
    }
1920
1921
    /**
1922
     * Linear Regression Angle.
1923
     *
1924
     * @param array $real       Array of real values.
1925
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1926
     *
1927
     * @return array Returns an array with calculated data.
1928
     */
1929 2
    public function linearreg_angle(array $real, int $timePeriod = 14): array
1930
    {
1931 2
        $result = trader_linearreg_angle($real, $timePeriod);
1932
1933 2
        $this->handleErrors();
1934
1935 2
        return $result;
1936
    }
1937
1938
    /**
1939
     * Linear Regression Angle.
1940
     *
1941
     * @param array $real       Array of real values.
1942
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1943
     *
1944
     * @return array Returns an array with calculated data.
1945
     */
1946 2
    public function linearreg_intercept(array $real, int $timePeriod = 14): array
1947
    {
1948 2
        $result = trader_linearreg_intercept($real, $timePeriod);
1949
1950 2
        $this->handleErrors();
1951
1952 2
        return $result;
1953
    }
1954
1955
    /**
1956
     * Linear Regression Slope.
1957
     *
1958
     * @param array $real       Array of real values.
1959
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1960
     *
1961
     * @return array Returns an array with calculated data.
1962
     */
1963 2
    public function linearreg_slope(array $real, int $timePeriod = 14): array
1964
    {
1965 2
        $result = trader_linearreg_slope($real, $timePeriod);
1966
1967 2
        $this->handleErrors();
1968
1969 2
        return $result;
1970
    }
1971
1972
    /**
1973
     * Linear Regression.
1974
     *
1975
     * @param array $real       Array of real values.
1976
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
1977
     *
1978
     * @return array Returns an array with calculated data.
1979
     */
1980 2
    public function linearreg(array $real, int $timePeriod = 14): array
1981
    {
1982 2
        $result = trader_linearreg($real, $timePeriod);
1983
1984 2
        $this->handleErrors();
1985
1986 2
        return $result;
1987
    }
1988
1989
    /**
1990
     * Vector Log Natural.
1991
     *
1992
     * Calculates the natural logarithm for each value in real and returns the resulting array.
1993
     *
1994
     * @param array $real Array of real values.
1995
     *
1996
     * @return array Returns an array with calculated data.
1997
     */
1998 2
    public function ln(array $real): array
1999
    {
2000 2
        $result = trader_ln($real);
2001
2002 2
        $this->handleErrors();
2003
2004 2
        return $result;
2005
    }
2006
2007
    /**
2008
     * Vector Log10.
2009
     *
2010
     * Calculates the base-10 logarithm for each value in real and returns the resulting array.
2011
     *
2012
     * @param array $real Array of real values.
2013
     *
2014
     * @return array Returns an array with calculated data.
2015
     */
2016 2
    public function log10(array $real): array
2017
    {
2018 2
        $result = trader_log10($real);
2019
2020 2
        $this->handleErrors();
2021
2022 2
        return $result;
2023
    }
2024
2025
    /**
2026
     * Moving average.
2027
     *
2028
     * @param array $real       Array of real values.
2029
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2030
     * @param int   $mAType     Type of Moving Average. MA_TYPE_* series of constants should be used.
2031
     *
2032
     * @return array Returns an array with calculated data.
2033
     */
2034 2
    public function ma(array $real, int $timePeriod = 30, int $mAType = 0): array
2035
    {
2036 2
        $result = trader_ma($real, $timePeriod, $mAType);
2037
2038 2
        $this->handleErrors();
2039
2040 2
        return $result;
2041
    }
2042
2043
    /**
2044
     * Moving Average Convergence/Divergence.
2045
     *
2046
     * @param array $real         Array of real values.
2047
     * @param int   $fastPeriod   Number of period for the fast MA. Valid range from 2 to 100000.
2048
     * @param int   $slowPeriod   Number of period for the slow MA. Valid range from 2 to 100000.
2049
     * @param int   $signalPeriod Smoothing for the signal line (nb of period). Valid range from 1 to 100000.
2050
     *
2051
     * @return array Returns an array with calculated data.
2052
     */
2053 2
    public function macd(
2054
        array $real,
2055
        int $fastPeriod = 12,
2056
        int $slowPeriod = 26,
2057
        int $signalPeriod = 9
2058
    ): array {
2059 2
        $result = trader_macd($real, $fastPeriod, $slowPeriod, $signalPeriod);
2060
2061 2
        $this->handleErrors();
2062
2063 2
        return $result;
2064
    }
2065
2066
    /**
2067
     * Moving Average Convergence/Divergence with controllable Moving Average type.
2068
     *
2069
     * @param array $real         Array of real values.
2070
     * @param int   $fastPeriod   Number of period for the fast MA. Valid range from 2 to 100000.
2071
     * @param int   $fastMAType   Type of Moving Average for fast MA. MA_TYPE_* series of constants should be used.
2072
     * @param int   $slowPeriod   Number of period for the slow MA. Valid range from 2 to 100000.
2073
     * @param int   $slowMAType   Type of Moving Average for fast MA. MA_TYPE_* series of constants should be used.
2074
     * @param int   $signalPeriod Smoothing for the signal line (nb of period). Valid range from 1 to 100000.
2075
     *
2076
     * @return array Returns an array with calculated data.
2077
     */
2078 2
    public function macdext(
2079
        array $real,
2080
        int $fastPeriod = 12,
2081
        int $fastMAType = 0,
2082
        int $slowPeriod = 26,
2083
        int $slowMAType = 0,
2084
        int $signalPeriod = 9
2085
    ): array {
2086 2
        $result = trader_macdext($real, $fastPeriod, $fastMAType, $slowPeriod, $slowMAType, $signalPeriod);
2087
2088 2
        $this->handleErrors();
2089
2090 2
        return $result;
2091
    }
2092
2093
    /**
2094
     * Moving Average Convergence/Divergence Fix 12/26.
2095
     *
2096
     * @param array $real         Array of real values.
2097
     * @param int   $signalPeriod Smoothing for the signal line (nb of period). Valid range from 1 to 100000.
2098
     *
2099
     * @return array Returns an array with calculated data.
2100
     */
2101 2
    public function macdfix(array $real, int $signalPeriod = 9): array
2102
    {
2103 2
        $result = trader_macdfix($real, $signalPeriod);
2104
2105 2
        $this->handleErrors();
2106
2107 2
        return $result;
2108
    }
2109
2110
    /**
2111
     * MESA Adaptive Moving Average.
2112
     *
2113
     * @param array $real      Array of real values.
2114
     * @param float $fastLimit Upper limit use in the adaptive algorithm. Valid range from 0.01 to 0.99.
2115
     * @param float $slowLimit Lower limit use in the adaptive algorithm. Valid range from 0.01 to 0.99.
2116
     *
2117
     * @return array Returns an array with calculated data.
2118
     */
2119 2
    public function mama(array $real, float $fastLimit = 0.5, float $slowLimit = 0.05): array
2120
    {
2121 2
        $result = trader_mama($real, $fastLimit, $slowLimit);
2122
2123 2
        $this->handleErrors();
2124
2125 2
        return $result;
2126
    }
2127
2128
    /**
2129
     * Moving average with variable period
2130
     *
2131
     * @param array $real      Array of real values.
2132
     * @param array $periods   Array of real values.
2133
     * @param int   $minPeriod Value less than minimum will be changed to Minimum period. Valid range from 2 to 100000
2134
     * @param int   $maxPeriod Value higher than maximum will be changed to Maximum period. Valid range from 2 to 100000
2135
     * @param int   $mAType    Type of Moving Average. MA_TYPE_* series of constants should be used.
2136
     *
2137
     * @return array Returns an array with calculated data.
2138
     */
2139 2
    public function mavp(
2140
        array $real,
2141
        array $periods,
2142
        int $minPeriod = 2,
2143
        int $maxPeriod = 30,
2144
        int $mAType = 0
2145
    ): array {
2146 2
        $result = trader_mavp($real, $periods, $minPeriod, $maxPeriod, $mAType);
2147
2148 2
        $this->handleErrors();
2149
2150 2
        return $result;
2151
    }
2152
2153
    /**
2154
     * Highest value over a specified period.
2155
     *
2156
     * @param array $real       Array of real values.
2157
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2158
     *
2159
     * @return array Returns an array with calculated data.
2160
     */
2161 2
    public function max(array $real, int $timePeriod = 30): array
2162
    {
2163 2
        $result = trader_max($real, $timePeriod);
2164
2165 2
        $this->handleErrors();
2166
2167 2
        return $result;
2168
    }
2169
2170
    /**
2171
     * Index of highest value over a specified period
2172
     *
2173
     * @param array $real       Array of real values.
2174
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2175
     *
2176
     * @return array Returns an array with calculated data.
2177
     */
2178 2
    public function maxindex(array $real, int $timePeriod = 30): array
2179
    {
2180 2
        $result = trader_maxindex($real, $timePeriod);
2181
2182 2
        $this->handleErrors();
2183
2184 2
        return $result;
2185
    }
2186
2187
    /**
2188
     * Median Price.
2189
     *
2190
     * @param array $high High price, array of real values.
2191
     * @param array $low  Low price, array of real values.
2192
     *
2193
     * @return array Returns an array with calculated data.
2194
     */
2195 2
    public function medprice(array $high, array $low): array
2196
    {
2197 2
        $result = trader_medprice($high, $low);
2198
2199 2
        $this->handleErrors();
2200
2201 2
        return $result;
2202
    }
2203
2204
    /**
2205
     * Money Flow Index.
2206
     *
2207
     * @param array $high       High price, array of real values.
2208
     * @param array $low        Low price, array of real values.
2209
     * @param array $close      Closing price, array of real values.
2210
     * @param array $volume     Volume traded, array of real values.
2211
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2212
     *
2213
     * @return array Returns an array with calculated data.
2214
     */
2215 2
    public function mfi(array $high, array $low, array $close, array $volume, int $timePeriod = 14): array
2216
    {
2217 2
        $result = trader_mfi($high, $low, $close, $volume, $timePeriod);
2218
2219 2
        $this->handleErrors();
2220
2221 2
        return $result;
2222
    }
2223
2224
    /**
2225
     * MidPoint over period.
2226
     *
2227
     * @param array $real       Array of real values.
2228
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2229
     *
2230
     * @return array Returns an array with calculated data.
2231
     */
2232 2
    public function midpoint(array $real, int $timePeriod = 14): array
2233
    {
2234 2
        $result = trader_midpoint($real, $timePeriod);
2235
2236 2
        $this->handleErrors();
2237
2238 2
        return $result;
2239
    }
2240
2241
    /**
2242
     * Midpoint Price over period.
2243
     *
2244
     * @param array $high       High price, array of real values.
2245
     * @param array $low        Low price, array of real values.
2246
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2247
     *
2248
     * @return array Returns an array with calculated data.
2249
     */
2250 2
    public function midprice(array $high, array $low, int $timePeriod = 14): array
2251
    {
2252 2
        $result = trader_midprice($high, $low, $timePeriod);
2253
2254 2
        $this->handleErrors();
2255
2256 2
        return $result;
2257
    }
2258
2259
    /**
2260
     * Lowest value over a specified period.
2261
     *
2262
     * @param array $real       Array of real values.
2263
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2264
     *
2265
     * @return array Returns an array with calculated data.
2266
     */
2267 2
    public function min(array $real, int $timePeriod = 30): array
2268
    {
2269 2
        $result = trader_min($real, $timePeriod);
2270
2271 2
        $this->handleErrors();
2272
2273 2
        return $result;
2274
    }
2275
2276
    /**
2277
     * Index of lowest value over a specified period.
2278
     *
2279
     * @param array $real       Array of real values.
2280
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2281
     *
2282
     * @return array Returns an array with calculated data.
2283
     */
2284 2
    public function minindex(array $real, int $timePeriod = 30): array
2285
    {
2286 2
        $result = trader_minindex($real, $timePeriod);
2287
2288 2
        $this->handleErrors();
2289
2290 2
        return $result;
2291
    }
2292
2293
    /**
2294
     * Lowest and highest values over a specified period.
2295
     *
2296
     * @param array $real       Array of real values.
2297
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2298
     *
2299
     * @return array Returns an array with calculated data.
2300
     */
2301 2
    public function minmax(array $real, int $timePeriod = 30): array
2302
    {
2303 2
        $result = trader_minmax($real, $timePeriod);
2304
2305 2
        $this->handleErrors();
2306
2307 2
        return $result;
2308
    }
2309
2310
    /**
2311
     * Indexes of lowest and highest values over a specified period.
2312
     *
2313
     * @param array $real       Array of real values.
2314
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2315
     *
2316
     * @return array Returns an array with calculated data.
2317
     */
2318 2
    public function minmaxindex(array $real, int $timePeriod = 30): array
2319
    {
2320 2
        $result = trader_minmaxindex($real, $timePeriod);
2321
2322 2
        $this->handleErrors();
2323
2324 2
        return $result;
2325
    }
2326
2327
    /**
2328
     * Minus Directional Indicator.
2329
     *
2330
     * @param array $high       High price, array of real values.
2331
     * @param array $low        Low price, array of real values.
2332
     * @param array $close      Closing price, array of real values.
2333
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2334
     *
2335
     * @return array Returns an array with calculated data.
2336
     */
2337 2
    public function minus_di(array $high, array $low, array $close, int $timePeriod = 14): array
2338
    {
2339 2
        $result = trader_minus_di($high, $low, $close, $timePeriod);
2340
2341 2
        $this->handleErrors();
2342
2343 2
        return $result;
2344
    }
2345
2346
    /**
2347
     * Minus Directional Movement.
2348
     *
2349
     * @param array $high       High price, array of real values.
2350
     * @param array $low        Low price, array of real values.
2351
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2352
     *
2353
     * @return array Returns an array with calculated data.
2354
     */
2355 2
    public function minus_dm(array $high, array $low, int $timePeriod = 14): array
2356
    {
2357 2
        $result = trader_minus_dm($high, $low, $timePeriod);
2358
2359 2
        $this->handleErrors();
2360
2361 2
        return $result;
2362
    }
2363
2364
    /**
2365
     * Momentum.
2366
     *
2367
     * @param array $real       Array of real values.
2368
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2369
     *
2370
     * @return array Returns an array with calculated data.
2371
     */
2372 2
    public function mom(array $real, int $timePeriod = 10): array
2373
    {
2374 2
        $result = trader_mom($real, $timePeriod);
2375
2376 2
        $this->handleErrors();
2377
2378 2
        return $result;
2379
    }
2380
2381
    /**
2382
     * Vector Arithmetic Mult.
2383
     *
2384
     * Calculates the vector dot product of real0 with real1 and returns the resulting vector.
2385
     *
2386
     * @param array $real0 Array of real values.
2387
     * @param array $real1 Array of real values.
2388
     *
2389
     * @return array Returns an array with calculated data.
2390
     */
2391 2
    public function mult(array $real0, array $real1): array
2392
    {
2393 2
        $result = trader_mult($real0, $real1);
2394
2395 2
        $this->handleErrors();
2396
2397 2
        return $result;
2398
    }
2399
2400
    /**
2401
     * Normalized Average True Range.
2402
     *
2403
     * @param array $high       High price, array of real values.
2404
     * @param array $low        Low price, array of real values.
2405
     * @param array $close      Closing price, array of real values.
2406
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2407
     *
2408
     * @return array Returns an array with calculated data.
2409
     */
2410 2
    public function natr(array $high, array $low, array $close, int $timePeriod = 14): array
2411
    {
2412 2
        $result = trader_natr($high, $low, $close, $timePeriod);
2413
2414 2
        $this->handleErrors();
2415
2416 2
        return $result;
2417
    }
2418
2419
    /**
2420
     * On Balance Volume.
2421
     *
2422
     * @param array $real   Array of real values.
2423
     * @param array $volume Volume traded, array of real values.
2424
     *
2425
     * @return array Returns an array with calculated data.
2426
     */
2427 2
    public function obv(array $real, array $volume): array
2428
    {
2429 2
        $result = trader_obv($real, $volume);
2430
2431 2
        $this->handleErrors();
2432
2433 2
        return $result;
2434
    }
2435
2436
    /**
2437
     * Plus Directional Indicator.
2438
     *
2439
     * @param array $high       High price, array of real values.
2440
     * @param array $low        Low price, array of real values.
2441
     * @param array $close      Closing price, array of real values.
2442
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2443
     *
2444
     * @return array Returns an array with calculated data.
2445
     */
2446 2
    public function plus_di(array $high, array $low, array $close, int $timePeriod = 14): array
2447
    {
2448 2
        $result = trader_plus_di($high, $low, $close, $timePeriod);
2449
2450 2
        $this->handleErrors();
2451
2452 2
        return $result;
2453
    }
2454
2455
    /**
2456
     * Plus Directional Movement.
2457
     *
2458
     * @param array $high       High price, array of real values.
2459
     * @param array $low        Low price, array of real values.
2460
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2461
     *
2462
     * @return array Returns an array with calculated data.
2463
     */
2464 2
    public function plus_dm(array $high, array $low, int $timePeriod = 14): array
2465
    {
2466 2
        $result = trader_plus_dm($high, $low, $timePeriod);
2467
2468 2
        $this->handleErrors();
2469
2470 2
        return $result;
2471
    }
2472
2473
    /**
2474
     * Percentage Price Oscillator.
2475
     *
2476
     * @param array $real       Array of real values.
2477
     * @param int   $fastPeriod Number of period for the fast MA. Valid range from 2 to 100000.
2478
     * @param int   $slowPeriod Number of period for the slow MA. Valid range from 2 to 100000.
2479
     * @param int   $mAType     Type of Moving Average. MA_TYPE_* series of constants should be used.
2480
     *
2481
     * @return array Returns an array with calculated data.
2482
     */
2483 2
    public function ppo(array $real, int $fastPeriod = 12, int $slowPeriod = 26, int $mAType = 0): array
2484
    {
2485 2
        $result = trader_ppo($real, $fastPeriod, $slowPeriod, $mAType);
2486
2487 2
        $this->handleErrors();
2488
2489 2
        return $result;
2490
    }
2491
2492
    /**
2493
     * Rate of change : ((price/prevPrice)-1)*100.
2494
     *
2495
     * @param array $real       Array of real values.
2496
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2497
     *
2498
     * @return array Returns an array with calculated data.
2499
     */
2500 2
    public function roc(array $real, int $timePeriod = 10): array
2501
    {
2502 2
        $result = trader_roc($real, $timePeriod);
2503
2504 2
        $this->handleErrors();
2505
2506 2
        return $result;
2507
    }
2508
2509
    /**
2510
     * Rate of change Percentage: (price-prevPrice)/prevPrice.
2511
     *
2512
     * @param array $real       Array of real values.
2513
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2514
     *
2515
     * @return array Returns an array with calculated data.
2516
     */
2517 2
    public function rocp(array $real, int $timePeriod = 10): array
2518
    {
2519 2
        $result = trader_rocp($real, $timePeriod);
2520
2521 2
        $this->handleErrors();
2522
2523 2
        return $result;
2524
    }
2525
2526
    /**
2527
     * Rate of change ratio 100 scale: (price/prevPrice)*100.
2528
     *
2529
     * @param array $real       Array of real values.
2530
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2531
     *
2532
     * @return array Returns an array with calculated data.
2533
     */
2534 2
    public function rocr100(array $real, int $timePeriod = 10): array
2535
    {
2536 2
        $result = trader_rocr100($real, $timePeriod);
2537
2538 2
        $this->handleErrors();
2539
2540 2
        return $result;
2541
    }
2542
2543
    /**
2544
     * Rate of change ratio: (price/prevPrice).
2545
     *
2546
     * @param array $real       Array of real values.
2547
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2548
     *
2549
     * @return array Returns an array with calculated data.
2550
     */
2551 2
    public function rocr(array $real, int $timePeriod = 10): array
2552
    {
2553 2
        $result = trader_rocr($real, $timePeriod);
2554
2555 2
        $this->handleErrors();
2556
2557 2
        return $result;
2558
    }
2559
2560
    /**
2561
     * Relative Strength Index.
2562
     *
2563
     * @param array $real       Array of real values.
2564
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2565
     *
2566
     * @return array Returns an array with calculated data.
2567
     */
2568 2
    public function rsi(array $real, int $timePeriod = 14): array
2569
    {
2570 2
        $result = trader_rsi($real, $timePeriod);
2571
2572 2
        $this->handleErrors();
2573
2574 2
        return $result;
2575
    }
2576
2577
    /**
2578
     * Parabolic SAR.
2579
     *
2580
     * @param array $high         High price, array of real values.
2581
     * @param array $low          Low price, array of real values.
2582
     * @param float $acceleration Acceleration Factor used up to the Maximum value. Valid range from 0 to REAL_MAX.
2583
     * @param float $maximum      Acceleration Factor Maximum value. Valid range from 0 to REAL_MAX.
2584
     *
2585
     * @return array Returns an array with calculated data.
2586
     */
2587 2
    public function sar(array $high, array $low, float $acceleration = 0.02, float $maximum = 0.2): array
2588
    {
2589 2
        $result = trader_sar($high, $low, $acceleration, $maximum);
2590
2591 2
        $this->handleErrors();
2592
2593 2
        return $result;
2594
    }
2595
2596
    /**
2597
     * Parabolic SAR - Extended.
2598
     *
2599
     * @param array $high                  High price, array of real values.
2600
     * @param array $low                   Low price, array of real values.
2601
     * @param float $startValue            Start value and direction. 0 for Auto, >0 for Long, <0 for Short. Valid range from REAL_MIN to REAL_MAX.
2602
     * @param float $offsetOnReverse       Percent offset added/removed to initial stop on short/long reversal. Valid range from 0 to REAL_MAX.
2603
     * @param float $accelerationInitLong  Acceleration Factor initial value for the Long direction. Valid range from 0 to REAL_MAX.
2604
     * @param float $accelerationLong      Acceleration Factor for the Long direction. Valid range from 0 to REAL_MAX.
2605
     * @param float $accelerationMaxLong   Acceleration Factor maximum value for the Long direction. Valid range from 0 to REAL_MAX.
2606
     * @param float $accelerationInitShort Acceleration Factor initial value for the Short direction. Valid range from 0 to REAL_MAX.
2607
     * @param float $accelerationShort     Acceleration Factor for the Short direction. Valid range from 0 to REAL_MAX.
2608
     * @param float $accelerationMaxShort  Acceleration Factor maximum value for the Short direction. Valid range from 0 to REAL_MAX.
2609
     *
2610
     * @return array Returns an array with calculated data.
2611
     */
2612 2
    public function sarext(
2613
        array $high,
2614
        array $low,
2615
        float $startValue = 0.0,
2616
        float $offsetOnReverse = 0.0,
2617
        float $accelerationInitLong = 0.02,
2618
        float $accelerationLong = 0.02,
2619
        float $accelerationMaxLong = 0.2,
2620
        float $accelerationInitShort = 0.02,
2621
        float $accelerationShort = 0.02,
2622
        float $accelerationMaxShort = 0.2
2623
    ): array {
2624 2
        $result = trader_sarext(
2625 2
            $high,
2626 2
            $low,
2627 2
            $startValue,
2628 2
            $offsetOnReverse,
2629 2
            $accelerationInitLong,
2630 2
            $accelerationLong,
2631 2
            $accelerationMaxLong,
2632 2
            $accelerationInitShort,
2633 2
            $accelerationShort,
2634 2
            $accelerationMaxShort
2635
        );
2636
2637 2
        $this->handleErrors();
2638
2639 2
        return $result;
2640
    }
2641
2642
    /**
2643
     * Set compatibility mode.
2644
     *
2645
     * Set compatibility mode which will affect the way calculations are done by all the extension functions.
2646
     *
2647
     * @param int $compatId Compatibility Id. COMPATIBILITY_* series of constants should be used.
2648
     */
2649 2
    public function set_compat(int $compatId)
2650
    {
2651 2
        trader_set_compat($compatId);
2652 2
    }
2653
2654
    /**
2655
     * Set unstable period.
2656
     *
2657
     * Influences unstable period factor for functions, which are sensible to it. More information about unstable periods can be found on the » TA-Lib API documentation page.
2658
     *
2659
     * @param int $functionId Function ID the factor should be set for. FUNC_UNST_* constant series can be used to affect the corresponding function.
2660
     * @param int $timePeriod Unstable period value.
2661
     */
2662 2
    public function set_unstable_period(int $functionId, int $timePeriod)
2663
    {
2664 2
        trader_set_unstable_period($functionId, $timePeriod);
2665 2
    }
2666
2667
    /**
2668
     * Vector Trigonometric Sin.
2669
     *
2670
     * Calculates the sine for each value in real and returns the resulting array.
2671
     *
2672
     * @param array $real Array of real values.
2673
     *
2674
     * @return array Returns an array with calculated data.
2675
     */
2676 2
    public function sin(array $real): array
2677
    {
2678 2
        $result = trader_sin($real);
2679
2680 2
        $this->handleErrors();
2681
2682 2
        return $result;
2683
    }
2684
2685
    /**
2686
     * Vector Trigonometric Sinh.
2687
     *
2688
     * Calculates the hyperbolic sine for each value in real and returns the resulting array.
2689
     *
2690
     * @param array $real Array of real values.
2691
     *
2692
     * @return array Returns an array with calculated data.
2693
     */
2694 2
    public function sinh(array $real): array
2695
    {
2696 2
        $result = trader_sinh($real);
2697
2698 2
        $this->handleErrors();
2699
2700 2
        return $result;
2701
    }
2702
2703
    /**
2704
     * Simple Moving Average.
2705
     *
2706
     * @param array $real       Array of real values.
2707
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2708
     *
2709
     * @return array Returns an array with calculated data.
2710
     */
2711 2
    public function sma(array $real, int $timePeriod = 30): array
2712
    {
2713 2
        $result = trader_sma($real, $timePeriod);
2714
2715 2
        $this->handleErrors();
2716
2717 2
        return $result;
2718
    }
2719
2720
    /**
2721
     * Vector Square Root.
2722
     *
2723
     * Calculates the square root of each value in real and returns the resulting array.
2724
     *
2725
     * @param array $real Array of real values.
2726
     *
2727
     * @return array Returns an array with calculated data.
2728
     */
2729 2
    public function sqrt(array $real): array
2730
    {
2731 2
        $result = trader_sqrt($real);
2732
2733 2
        $this->handleErrors();
2734
2735 2
        return $result;
2736
    }
2737
2738
    /**
2739
     * Standard Deviation.
2740
     *
2741
     * @param array $real       Array of real values.
2742
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2743
     * @param float $nbDev      Number of deviations
2744
     *
2745
     * @return array Returns an array with calculated data.
2746
     */
2747 2
    public function stddev(array $real, int $timePeriod = 5, float $nbDev = 1.0): array
2748
    {
2749 2
        $result = trader_stddev($real, $timePeriod, $nbDev);
2750
2751 2
        $this->handleErrors();
2752
2753 2
        return $result;
2754
    }
2755
2756
    /**
2757
     * Stochastic.
2758
     *
2759
     * @param array $high         High price, array of real values.
2760
     * @param array $low          Low price, array of real values.
2761
     * @param array $close        Time period for building the Fast-K line. Valid range from 1 to 100000.
2762
     * @param int   $fastK_Period Time period for building the Fast-K line. Valid range from 1 to 100000.
2763
     * @param int   $slowK_Period Smoothing for making the Slow-K line. Valid range from 1 to 100000, usually set to 3.
2764
     * @param int   $slowK_MAType Type of Moving Average for Slow-K. MA_TYPE_* series of constants should be used.
2765
     * @param int   $slowD_Period Smoothing for making the Slow-D line. Valid range from 1 to 100000.
2766
     * @param int   $slowD_MAType Type of Moving Average for Slow-D. MA_TYPE_* series of constants should be used.
2767
     *
2768
     * @return array Returns an array with calculated data.
2769
     */
2770 2
    public function stoch(
2771
        array $high,
2772
        array $low,
2773
        array $close,
2774
        int $fastK_Period = 5,
2775
        int $slowK_Period = 3,
2776
        int $slowK_MAType = 0,
2777
        int $slowD_Period = 3,
2778
        int $slowD_MAType = 0
2779
    ): array {
2780 2
        $result = trader_stoch(
2781 2
            $high,
2782 2
            $low,
2783 2
            $close,
2784 2
            $fastK_Period,
2785 2
            $slowK_Period,
2786 2
            $slowK_MAType,
2787 2
            $slowD_Period,
2788 2
            $slowD_MAType
2789
        );
2790
2791 2
        $this->handleErrors();
2792
2793 2
        return $result;
2794
    }
2795
2796
    /**
2797
     * Stochastic Fast.
2798
     *
2799
     * @param array $high         High price, array of real values.
2800
     * @param array $low          Low price, array of real values.
2801
     * @param array $close        Time period for building the Fast-K line. Valid range from 1 to 100000.
2802
     * @param int   $fastK_Period Time period for building the Fast-K line. Valid range from 1 to 100000.
2803
     * @param int   $fastD_Period Smoothing for making the Fast-D line. Valid range from 1 to 100000, usually set to 3.
2804
     * @param int   $fastD_MAType Type of Moving Average for Fast-D. MA_TYPE_* series of constants should be used.
2805
     *
2806
     * @return array Returns an array with calculated data.
2807
     */
2808 2
    public function stochf(
2809
        array $high,
2810
        array $low,
2811
        array $close,
2812
        int $fastK_Period = 5,
2813
        int $fastD_Period = 3,
2814
        int $fastD_MAType = 0
2815
    ): array {
2816 2
        $result = trader_stochf(
2817 2
            $high,
2818 2
            $low,
2819 2
            $close,
2820 2
            $fastK_Period,
2821 2
            $fastD_Period,
2822 2
            $fastD_MAType
2823
        );
2824
2825 2
        $this->handleErrors();
2826
2827 2
        return $result;
2828
    }
2829
2830
    /**
2831
     * Stochastic Relative Strength Index.
2832
     *
2833
     * @param array $real         Array of real values.
2834
     * @param int   $timePeriod   Number of period. Valid range from 2 to 100000.
2835
     * @param int   $fastK_Period Time period for building the Fast-K line. Valid range from 1 to 100000.
2836
     * @param int   $fastD_Period Smoothing for making the Fast-D line. Valid range from 1 to 100000, usually set to 3.
2837
     * @param int   $fastD_MAType Type of Moving Average for Fast-D. MA_TYPE_* series of constants should be used.
2838
     *
2839
     * @return array Returns an array with calculated data.
2840
     */
2841 2
    public function stochrsi(
2842
        array $real,
2843
        int $timePeriod = 14,
2844
        int $fastK_Period = 5,
2845
        int $fastD_Period = 3,
2846
        int $fastD_MAType = 0
2847
    ): array {
2848 2
        $result = trader_stochrsi(
2849 2
            $real,
2850 2
            $timePeriod,
2851 2
            $fastK_Period,
2852 2
            $fastD_Period,
2853 2
            $fastD_MAType
2854
        );
2855
2856 2
        $this->handleErrors();
2857
2858 2
        return $result;
2859
    }
2860
2861
    /**
2862
     * Vector Arithmetic Subtraction.
2863
     *
2864
     * Calculates the vector subtraction of real1 from real0 and returns the resulting vector.
2865
     *
2866
     * @param array $real0 Array of real values.
2867
     * @param array $real1 Array of real values.
2868
     *
2869
     * @return array Returns an array with calculated data.
2870
     */
2871 2
    public function sub(array $real0, array $real1): array
2872
    {
2873 2
        $result = trader_sub($real0, $real1);
2874
2875 2
        $this->handleErrors();
2876
2877 2
        return $result;
2878
    }
2879
2880
    /**
2881
     * Summation.
2882
     *
2883
     * @param array $real       Array of real values.
2884
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2885
     *
2886
     * @return array Returns an array with calculated data.
2887
     */
2888 2
    public function sum(array $real, int $timePeriod = 30): array
2889
    {
2890 2
        $result = trader_sum($real, $timePeriod);
2891
2892 2
        $this->handleErrors();
2893
2894 2
        return $result;
2895
    }
2896
2897
    /**
2898
     * Triple Exponential Moving Average (T3).
2899
     *
2900
     * @param array $real       Array of real values.
2901
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2902
     * @param float $vFactor    Volume Factor. Valid range from 1 to 0.
2903
     *
2904
     * @return array Returns an array with calculated data.
2905
     */
2906 2
    public function t3(array $real, int $timePeriod = 5, float $vFactor = 0.7): array
2907
    {
2908 2
        $result = trader_t3($real, $timePeriod, $vFactor);
2909
2910 2
        $this->handleErrors();
2911
2912 2
        return $result;
2913
    }
2914
2915
    /**
2916
     * Vector Trigonometric Tan.
2917
     *
2918
     * Calculates the tangent for each value in real and returns the resulting array.
2919
     *
2920
     * @param array $real Array of real values.
2921
     *
2922
     * @return array Returns an array with calculated data.
2923
     */
2924 2
    public function tan(array $real): array
2925
    {
2926 2
        $result = trader_tan($real);
2927
2928 2
        $this->handleErrors();
2929
2930 2
        return $result;
2931
    }
2932
2933
    /**
2934
     * Vector Trigonometric Tanh.
2935
     *
2936
     * Calculates the hyperbolic tangent for each value in real and returns the resulting array.
2937
     *
2938
     * @param array $real Array of real values.
2939
     *
2940
     * @return array Returns an array with calculated data.
2941
     */
2942 2
    public function tanh(array $real): array
2943
    {
2944 2
        $result = trader_tanh($real);
2945
2946 2
        $this->handleErrors();
2947
2948 2
        return $result;
2949
    }
2950
2951
    /**
2952
     * Triple Exponential Moving Average.
2953
     *
2954
     * @param array $real       Array of real values.
2955
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2956
     *
2957
     * @return array Returns an array with calculated data.
2958
     */
2959 2
    public function tema(array $real, int $timePeriod = 30): array
2960
    {
2961 2
        $result = trader_tema($real, $timePeriod);
2962
2963 2
        $this->handleErrors();
2964
2965 2
        return $result;
2966
    }
2967
2968
    /**
2969
     * True Range.
2970
     *
2971
     * @param array $high  High price, array of real values.
2972
     * @param array $low   Low price, array of real values.
2973
     * @param array $close Closing price, array of real values.
2974
     *
2975
     * @return array Returns an array with calculated data.
2976
     */
2977 2
    public function trange(array $high, array $low, array $close): array
2978
    {
2979 2
        $result = trader_trange($high, $low, $close);
2980
2981 2
        $this->handleErrors();
2982
2983 2
        return $result;
2984
    }
2985
2986
    /**
2987
     * Triangular Moving Average.
2988
     *
2989
     * @param array $real       Array of real values.
2990
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
2991
     *
2992
     * @return array Returns an array with calculated data.
2993
     */
2994 2
    public function trima(array $real, int $timePeriod = 30): array
2995
    {
2996 2
        $result = trader_trima($real, $timePeriod);
2997
2998 2
        $this->handleErrors();
2999
3000 2
        return $result;
3001
    }
3002
3003
    /**
3004
     * 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA.
3005
     *
3006
     * @param array $real       Array of real values.
3007
     * @param int   $timePeriod [OPTIONAL] [DEFAULT 30] Number of period. Valid range from 2 to 100000.
3008
     *
3009
     * @return array Returns an array with calculated data.
3010
     */
3011 2
    public function trix(array $real, int $timePeriod = 30): array
3012
    {
3013 2
        $result = trader_trix($real, $timePeriod);
3014
3015 2
        $this->handleErrors();
3016
3017 2
        return $result;
3018
    }
3019
3020
    /**
3021
     * Time Series Forecast.
3022
     *
3023
     * @param array $real       Array of real values.
3024
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
3025
     *
3026
     * @return array Returns an array with calculated data.
3027
     */
3028 2
    public function tsf(array $real, int $timePeriod = 14): array
3029
    {
3030 2
        $result = trader_tsf($real, $timePeriod);
3031
3032 2
        $this->handleErrors();
3033
3034 2
        return $result;
3035
    }
3036
3037
    /**
3038
     * Typical Price.
3039
     *
3040
     * @param array $high  High price, array of real values.
3041
     * @param array $low   Low price, array of real values.
3042
     * @param array $close Closing price, array of real values.
3043
     *
3044
     * @return array Returns an array with calculated data.
3045
     */
3046 2
    public function typprice(array $high, array $low, array $close): array
3047
    {
3048 2
        $result = trader_typprice($high, $low, $close);
3049
3050 2
        $this->handleErrors();
3051
3052 2
        return $result;
3053
    }
3054
3055
    /**
3056
     * Ultimate Oscillator.
3057
     *
3058
     * @param array $high        High price, array of real values.
3059
     * @param array $low         Low price, array of real values.
3060
     * @param array $close       Closing price, array of real values.
3061
     * @param int   $timePeriod1 Number of bars for 1st period. Valid range from 1 to 100000.
3062
     * @param int   $timePeriod2 Number of bars for 2nd period. Valid range from 1 to 100000.
3063
     * @param int   $timePeriod3 Number of bars for 3rd period. Valid range from 1 to 100000.
3064
     *
3065
     * @return array Returns an array with calculated data.
3066
     */
3067 2
    public function ultosc(
3068
        array $high,
3069
        array $low,
3070
        array $close,
3071
        int $timePeriod1 = 7,
3072
        int $timePeriod2 = 14,
3073
        int $timePeriod3 = 28
3074
    ): array {
3075 2
        $result = trader_ultosc($high, $low, $close, $timePeriod1, $timePeriod2, $timePeriod3);
3076
3077 2
        $this->handleErrors();
3078
3079 2
        return $result;
3080
    }
3081
3082
    /**
3083
     * Variance.
3084
     *
3085
     * @param array $real       Array of real values.
3086
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
3087
     * @param float $nbDev      Number of deviations
3088
     *
3089
     * @return array Returns an array with calculated data.
3090
     */
3091 2
    public function var(array $real, int $timePeriod = 5, float $nbDev = 1.0): array
3092
    {
3093 2
        $result = trader_var($real, $timePeriod, $nbDev);
3094
3095 2
        $this->handleErrors();
3096
3097 2
        return $result;
3098
    }
3099
3100
    /**
3101
     * Weighted Close Price.
3102
     *
3103
     * @param array $high  High price, array of real values.
3104
     * @param array $low   Low price, array of real values.
3105
     * @param array $close Closing price, array of real values.
3106
     *
3107
     * @return array Returns an array with calculated data.
3108
     */
3109 2
    public function wclprice(array $high, array $low, array $close): array
3110
    {
3111 2
        $result = trader_wclprice($high, $low, $close);
3112
3113 2
        $this->handleErrors();
3114
3115 2
        return $result;
3116
    }
3117
3118
    /**
3119
     * Williams' %R.
3120
     *
3121
     * @param array $high       High price, array of real values.
3122
     * @param array $low        Low price, array of real values.
3123
     * @param array $close      Closing price, array of real values.
3124
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
3125
     *
3126
     * @return array Returns an array with calculated data.
3127
     */
3128 2
    public function willr(array $high, array $low, array $close, int $timePeriod = 14): array
3129
    {
3130 2
        $result = trader_willr($high, $low, $close, $timePeriod);
3131
3132 2
        $this->handleErrors();
3133
3134 2
        return $result;
3135
    }
3136
3137
    /**
3138
     * Weighted Moving Average.
3139
     *
3140
     * @param array $real       Array of real values.
3141
     * @param int   $timePeriod Number of period. Valid range from 2 to 100000.
3142
     *
3143
     * @return array Returns an array with calculated data.
3144
     */
3145 4
    public function wma(array $real, int $timePeriod = 30): array
3146
    {
3147 4
        $result = trader_wma($real, $timePeriod);
3148
3149 4
        $this->handleErrors();
3150
3151 2
        return $result;
3152
    }
3153
3154
    /**
3155
     * Handle errors.
3156
     */
3157 318
    protected function handleErrors()
3158
    {
3159 318
        $errorCode = trader_errno();
3160 318
        if (isset(static::$errors[$errorCode])) {
3161 2
            throw new BadFunctionCallException(static::$errors[$errorCode], $errorCode);
3162
        }
3163 316
    }
3164
}
3165