forked from oransel/node-talib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
1979 lines (1808 loc) · 73.8 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @packageDocumentation
* @module default
*/
// tslint:disable-next-line:no-var-requires
const talib_module = require("bindings")("node-ta-lib.node");
/**
* Returns the version of ta-lib compiled
*/
export function version(): string {
return talib_module.version();
}
export interface IExplanationField {
name: string;
type: string;
"0": string;
flags: any;
}
export interface IExplanationOption {
"name": string;
"displayName": string;
"defaultValue": number;
"hint": string;
"type": string;
}
/**
* function usage explanation
*/
export interface IExplainResult {
/** name of the function */
name: string;
/** function group, i.e. Math Operators Functions, Momentum Indicators Functions etc' */
group: string;
/** function description */
hint: string;
/** inputs for the function */
inputs: IExplanationField[];
/** optional inputs for the function */
optInputs: IExplanationOption[];
/** outputs for the function execution */
outputs: IExplanationField[];
}
/**
* explain function usage
* @param function_name function name to explain
*/
export function explain(function_name: string):IExplainResult{
return talib_module.explain(function_name);
}
/**
* List all functions
*/
export function functions(): IExplainResult[]{
return talib_module.functions();
}
export interface IExecute {
name: string;
startIdx: number;
endIdx: number;
[params: string]: number[] | number | string;
}
export interface IExecutionResult<TResult> {
begIndex: number;
nbElement: number;
result: TResult;
}
/**
* Execute ta-lib function
* @param execute_params execution parameters
* @param results_callback execution results callback
*/
export function execute(execute_params: IExecute, results_callback: (err: any, results: IExecutionResult<{ [param: string]: number[]; }>) => void): void{
talib_module.execute(execute_params, results_callback);
}
export async function execute_async(execute_params: IExecute): Promise<IExecutionResult<{ [param: string]: number[]; }>> {
return new Promise<IExecutionResult<{ outReal: number[] }>>((resolve, reject) => {
execute(execute_params, (err, results) => {
if (err) {
reject(err);
return;
}
resolve(results as any);
});
});
}
/**
* Moving Average Type
*/
export enum MAType {
/** Simple */
Sma = 0,
/** Exponential */
Ema = 1,
/** Weighted */
Wma = 2,
/** Double Exponential */
Dema = 3,
/** Triple Exponential */
Tema = 4,
/** Triangular */
Trima = 5,
/** Kaufman Adaptive */
Kama = 6,
/** Mesa Adaptive */
Mama = 7,
/** Triple Exponential T3 */
T3 = 8
}
/**
* ADD - Vector Arithmetic Add
* @category Math Operators
* @param {number[]} inReal0
* @param {number[]} inReal1
* @returns number[]
*/
export async function ADD(inReal0: number[], inReal1: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ADD", startIdx: 0, endIdx: inReal0.length - 1, inReal0, inReal1}) as any;
}
/**
* DIV - Vector Arithmetic Div
* @category Math Operators
* @param {number[]} inReal0
* @param {number[]} inReal1
* @returns number[]
*/
export async function DIV(inReal0: number[], inReal1: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "DIV", startIdx: 0, endIdx: inReal0.length - 1, inReal0, inReal1}) as any;
}
/**
* MAX - Highest value over a specified period
* @category Math Operators
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function MAX(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MAX", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* MAXINDEX - Index of highest value over a specified period
* @category Math Operators
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function MAXINDEX(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outInteger: number[]}>> {
return await execute_async({ name: "MAXINDEX", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* MIN - Lowest value over a specified period
* @category Math Operators
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function MIN(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MIN", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* MININDEX - Index of lowest value over a specified period
* @category Math Operators
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function MININDEX(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outInteger: number[]}>> {
return await execute_async({ name: "MININDEX", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* MINMAX - Lowest and highest values over a specified period
* @category Math Operators
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function MINMAX(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outMin: number[], outMax: number[]}>> {
return await execute_async({ name: "MINMAX", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* MINMAXINDEX - Indexes of lowest and highest values over a specified period
* @category Math Operators
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function MINMAXINDEX(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outMinIdx: number[], outMaxIdx: number[]}>> {
return await execute_async({ name: "MINMAXINDEX", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* MULT - Vector Arithmetic Mult
* @category Math Operators
* @param inReal0
* @param inReal1
*/
export async function MULT(inReal0: number[], inReal1: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MULT", startIdx: 0, endIdx: inReal0.length - 1, inReal0, inReal1}) as any;
}
/**
* SUB - Vector Arithmetic Subtraction
* @category Math Operators
* @param inReal0
* @param inReal1
*/
export async function SUB(inReal0: number[], inReal1: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "SUB", startIdx: 0, endIdx: inReal0.length - 1, inReal0, inReal1}) as any;
}
/**
* SUM - Summation
* @category Math Operators
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function SUM(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "SUM", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* ACOS - Vector Trigonometric ACos
* @category Math Transform
* @param inReal
*/
export async function ACOS(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ACOS", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* ASIN - Vector Trigonometric ASin
* @category Math Transform
* @param inReal
*/
export async function ASIN(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ASIN", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* ATAN - Vector Trigonometric ATan
* @category Math Transform
* @param inReal
*/
export async function ATAN(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ATAN", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* CEIL - Vector Ceil
* @category Math Transform
* @param inReal
*/
export async function CEIL(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "CEIL", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* COS - Vector Trigonometric Cos
* @category Math Transform
* @param inReal
*/
export async function COS(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "COS", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* COSH - Vector Trigonometric Cosh
* @category Math Transform
*/
export async function COSH(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "COSH", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* EXP - Vector Arithmetic Exp
* @category Math Transform
* @param inReal
*/
export async function EXP(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "EXP", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* FLOOR - Vector Floor
* @category Math Transform
*
* @param inReal
*/
export async function FLOOR(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "FLOOR", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* LN - Vector Log Natural
* @category Math Transform
*
* @param inReal
*/
export async function LN(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "LN", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* LOG10 - Vector Log10
* @category Math Transform
*
* @param inReal
*/
export async function LOG10(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "LOG10", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* SIN - Vector Trigonometric Sin
* @category Math Transform
*
* @param inReal
*/
export async function SIN(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "SIN", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* SINH - Vector Trigonometric Sinh
* @category Math Transform
*
* @param inReal
*/
export async function SINH(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "SINH", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* SQRT - Vector Square Root
* @category Math Transform
*
* @param inReal
*/
export async function SQRT(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "SQRT", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* TAN - Vector Trigonometric Tan
* @category Math Transform
*
* @param inReal
*/
export async function TAN(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "TAN", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* TANH - Vector Trigonometric Tanh
* @category Math Transform
*
* @param inReal
*/
export async function TANH(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "TANH", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* BBANDS - Bollinger Bands
* @category Overlap Studies
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 5
* @param optInNbDevUp Deviations up - Deviation multiplier for upper band = 2
* @param optInNbDevDn Deviations down - Deviation multiplier for lower band = 2
* @param optInMAType MA Type - Type of Moving Average = 0
*/
export async function BBANDS(inReal: number[], optInTimePeriod: number = 5, optInNbDevUp: number = 2, optInNbDevDn: number = 2, optInMAType: MAType = 0): Promise<IExecutionResult<{ outRealUpperBand: number[], outRealMiddleBand: number[], outRealLowerBand: number[]}>> {
return await execute_async({ name: "BBANDS", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod, optInNbDevUp, optInNbDevDn, optInMAType}) as any;
}
/**
* DEMA - Double Exponential Moving Average
* @category Overlap Studies
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function DEMA(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "DEMA", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* EMA - Exponential Moving Average
* @category Overlap Studies
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function EMA(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "EMA", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* HT_TRENDLINE - Hilbert Transform - Instantaneous Trendline
* @category Overlap Studies
*
* @param inReal
*/
export async function HT_TRENDLINE(inReal: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "HT_TRENDLINE", startIdx: 0, endIdx: inReal.length - 1, inReal}) as any;
}
/**
* KAMA - Kaufman Adaptive Moving Average
* @category Overlap Studies
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function KAMA(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "KAMA", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* MA - Moving average
* @category Overlap Studies
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
* @param optInMAType MA Type - Type of Moving Average = 0
*/
export async function MA(inReal: number[], optInTimePeriod: number = 30, optInMAType: MAType = 0): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MA", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod, optInMAType}) as any;
}
/**
* MAMA - MESA Adaptive Moving Average
* @category Overlap Studies
*
* @param inReal
* @param optInFastLimit Fast Limit - Upper limit use in the adaptive algorithm = 0.5
* @param optInSlowLimit Slow Limit - Lower limit use in the adaptive algorithm = 0.05
*/
export async function MAMA(inReal: number[], optInFastLimit: number = 0.5, optInSlowLimit: number = 0.05): Promise<IExecutionResult<{ outMAMA: number[], outFAMA: number[]}>> {
return await execute_async({ name: "MAMA", startIdx: 0, endIdx: inReal.length - 1, inReal, optInFastLimit, optInSlowLimit}) as any;
}
/**
* MAVP - Moving average with variable period
* @category Overlap Studies
*
* @param inReal
* @param inPeriods
* @param optInMinPeriod Minimum Period - Value less than minimum will be changed to Minimum period = 2
* @param optInMaxPeriod Maximum Period - Value higher than maximum will be changed to Maximum period = 30
* @param optInMAType MA Type - Type of Moving Average = 0
*/
export async function MAVP(inReal: number[], inPeriods: number[], optInMinPeriod: number = 2, optInMaxPeriod: number = 30, optInMAType: MAType = 0): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MAVP", startIdx: 0, endIdx: inReal.length - 1, inReal, inPeriods, optInMinPeriod, optInMaxPeriod, optInMAType}) as any;
}
/**
* MIDPOINT - MidPoint over period
* @category Overlap Studies
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function MIDPOINT(inReal: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MIDPOINT", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* MIDPRICE - Midpoint Price over period
* @category Overlap Studies
*
* @param high
* @param low
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function MIDPRICE(high: number[], low: number[], optInTimePeriod: number = 14 ): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MIDPRICE", startIdx: 0, endIdx: high.length - 1, high, low, optInTimePeriod}) as any;
}
/**
* SAR - Parabolic SAR
* @category Overlap Studies
*
* @param high
* @param low
* @param optInAcceleration Acceleration Factor - Acceleration Factor used up to the Maximum value = 0.02
* @param optInMaximum AF Maximum - Acceleration Factor Maximum value = 0.2
*/
export async function SAR(high: number[], low: number[], optInAcceleration: number = 0.02, optInMaximum: number = 0.2): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "SAR", startIdx: 0, endIdx: high.length - 1, high, low, optInAcceleration, optInMaximum}) as any;
}
/**
* SAREXT - Parabolic SAR - Extended
* @category Overlap Studies
* @param high
* @param low
* @param optInStartValue Start Value - Start value and direction. 0 for Auto, >0 for Long, <0 for Short = 0
* @param optInOffsetOnReverse Offset on Reverse - Percent offset added/removed to initial stop on short/long reversal = 0
* @param optInAccelerationInitLong AF Init Long - Acceleration Factor initial value for the Long direction = 0.02
* @param optInAccelerationLong AF Long - Acceleration Factor for the Long direction = 0.02
* @param optInAccelerationMaxLong AF Max Long - Acceleration Factor maximum value for the Long direction = 0.2
* @param optInAccelerationInitShort AF Init Short - Acceleration Factor initial value for the Short direction = 0.02
* @param optInAccelerationShort AF Short - Acceleration Factor for the Short direction = 0.02
* @param optInAccelerationMaxShort AF Max Short - Acceleration Factor maximum value for the Short direction = 0.2
*/
export async function SAREXT(high: number[], low: number[], optInStartValue: number = 0, optInOffsetOnReverse: number = 0, optInAccelerationInitLong: number = 0.02, optInAccelerationLong: number = 0.02, optInAccelerationMaxLong: number = 0.2, optInAccelerationInitShort: number = 0.02, optInAccelerationShort: number = 0.02, optInAccelerationMaxShort: number = 0.2): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "SAREXT", startIdx: 0, endIdx: high.length - 1, high, low, optInStartValue, optInOffsetOnReverse, optInAccelerationInitLong, optInAccelerationLong, optInAccelerationMaxLong, optInAccelerationInitShort, optInAccelerationShort, optInAccelerationMaxShort}) as any;
}
/**
* SMA - Simple Moving Average
* @category Overlap Studies
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function SMA(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "SMA", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* T3 - Triple Exponential Moving Average
* @category Overlap Studies
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 5
* @param optInVFactor Volume Factor - Volume Factor = 0.7
*/
export async function T3(inReal: number[], optInTimePeriod: number = 5, optInVFactor: number = 0.7): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "T3", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod, optInVFactor}) as any;
}
/**
* TEMA - Triple Exponential Moving Average
* @category Overlap Studies
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function TEMA(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "TEMA", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* TRIMA - Triangular Moving Average
* @category Overlap Studies
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function TRIMA(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "TRIMA", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* WMA - Weighted Moving Average
* @category Overlap Studies
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function WMA(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "WMA", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* ATR - Average True Range
* @category Volatility Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function ATR(high: number[], low: number[], close: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ATR", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod}) as any;
}
/**
* NATR - Normalized Average True Range
* @category Volatility Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function NATR(high: number[], low: number[], close: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "NATR", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod}) as any;
}
/**
* TRANGE - True Range
* @category Volatility Indicators
*
* @param high
* @param low
* @param close
*/
export async function TRANGE(high: number[], low: number[], close: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "TRANGE", startIdx: 0, endIdx: high.length - 1, high, low, close}) as any;
}
/**
* ADX - Average Directional Movement Index
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function ADX(high: number[], low: number[], close: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ADX", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod}) as any;
}
/**
* ADXR - Average Directional Movement Index Rating
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function ADXR(high: number[], low: number[], close: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ADXR", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod}) as any;
}
/**
* APO - Absolute Price Oscillator
* @category Momentum Indicators
*
* @param inReal
* @param optInFastPeriod Fast Period - Number of period for the fast MA = 12
* @param optInSlowPeriod Slow Period - Number of period for the slow MA = 26
* @param optInMAType MA Type - Type of Moving Average = 0
*/
export async function APO(inReal: number[], optInFastPeriod: number = 12, optInSlowPeriod: number = 26, optInMAType: MAType = 0): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "APO", startIdx: 0, endIdx: inReal.length - 1, inReal, optInFastPeriod, optInSlowPeriod, optInMAType}) as any;
}
/**
* AROON - Aroon
* @category Momentum Indicators
*
* @param high
* @param low
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function AROON(high: number[], low: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outAroonDown: number[], outAroonUp: number[]}>> {
return await execute_async({ name: "AROON", startIdx: 0, endIdx: high.length - 1, high, low, optInTimePeriod}) as any;
}
/**
* AROONOSC - Aroon Oscillator
* @category Momentum Indicators
*
* @param high
* @param low
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function AROONOSC(high: number[], low: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "AROONOSC", startIdx: 0, endIdx: high.length - 1, high, low, optInTimePeriod}) as any;
}
/**
* BOP - Balance Of Power
* @category Momentum Indicators
*
* @param open
* @param high
* @param low
* @param close
*/
export async function BOP(open: number[], high: number[], low: number[], close: number[]): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "BOP", startIdx: 0, endIdx: open.length - 1, open, high, low, close}) as any;
}
/**
* CCI - Commodity Channel Index
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function CCI(high: number[], low: number[], close: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "CCI", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod}) as any;
}
/**
* CMO - Chande Momentum Oscillator
* @category Momentum Indicators
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function CMO(inReal: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "CMO", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* DX - Directional Movement Index
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function DX(high: number[], low: number[], close: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "DX", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod}) as any;
}
/**
* MACD - Moving Average Convergence/Divergence
* @category Momentum Indicators
*
* @param inReal
* @param optInFastPeriod Fast Period - Number of period for the fast MA = 12
* @param optInSlowPeriod Slow Period - Number of period for the slow MA = 26
* @param optInSignalPeriod Signal Period - Smoothing for the signal line (nb of period) = 9
*/
export async function MACD(inReal: number[], optInFastPeriod: number = 12, optInSlowPeriod: number = 26, optInSignalPeriod: number = 9): Promise<IExecutionResult<{ outMACD: number[], outMACDSignal: number[], outMACDHist: number[]}>> {
return await execute_async({ name: "MACD", startIdx: 0, endIdx: inReal.length - 1, inReal, optInFastPeriod, optInSlowPeriod, optInSignalPeriod}) as any;
}
/**
* MACDEXT - MACD with controllable MA type
* @category Momentum Indicators
*
* @param inReal
* @param optInFastPeriod Fast Period - Number of period for the fast MA = 12
* @param optInFastMAType Fast MA - Type of Moving Average for fast MA = 0
* @param optInSlowPeriod Slow Period - Number of period for the slow MA = 26
* @param optInSlowMAType Slow MA - Type of Moving Average for slow MA = 0
* @param optInSignalPeriod Signal Period - Smoothing for the signal line (nb of period) = 9
* @param optInSignalMAType Signal MA - Type of Moving Average for signal line = 0
*/
export async function MACDEXT(inReal: number[], optInFastPeriod: number = 12, optInFastMAType: MAType = 0, optInSlowPeriod: number = 26, optInSlowMAType: MAType = 0, optInSignalPeriod: number = 9, optInSignalMAType: MAType = 0): Promise<IExecutionResult<{ outMACD: number[], outMACDSignal: number[], outMACDHist: number[]}>> {
return await execute_async({ name: "MACDEXT", startIdx: 0, endIdx: inReal.length - 1, inReal, optInFastPeriod, optInFastMAType, optInSlowPeriod, optInSlowMAType, optInSignalPeriod, optInSignalMAType}) as any;
}
/**
* MACDFIX - Moving Average Convergence/Divergence Fix 12/26
* @category Momentum Indicators
*
* @param inReal
* @param optInSignalPeriod Signal Period - Smoothing for the signal line (nb of period) = 9
*/
export async function MACDFIX(inReal: number[], optInSignalPeriod: number = 9): Promise<IExecutionResult<{ outMACD: number[], outMACDSignal: number[], outMACDHist: number[]}>> {
return await execute_async({ name: "MACDFIX", startIdx: 0, endIdx: inReal.length - 1, inReal, optInSignalPeriod}) as any;
}
/**
* MFI - Money Flow Index
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param volume
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function MFI(high: number[], low: number[], close: number[], volume: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MFI", startIdx: 0, endIdx: high.length - 1, high, low, close, volume, optInTimePeriod}) as any;
}
/**
* MINUS_DI - Minus Directional Indicator
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function MINUS_DI(high: number[], low: number[], close: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MINUS_DI", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod}) as any;
}
/**
* MINUS_DM - Minus Directional Movement
* @category Momentum Indicators
*
* @param high
* @param low
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function MINUS_DM(high: number[], low: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MINUS_DM", startIdx: 0, endIdx: high.length - 1, high, low, optInTimePeriod}) as any;
}
/**
* MOM - Momentum
* @category Momentum Indicators
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 10
*/
export async function MOM(inReal: number[], optInTimePeriod: number = 10): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "MOM", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* PLUS_DI - Plus Directional Indicator
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function PLUS_DI(high: number[], low: number[], close: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "PLUS_DI", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod}) as any;
}
/**
* PLUS_DM - Plus Directional Movement
* @category Momentum Indicators
*
* @param high
* @param low
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function PLUS_DM(high: number[], low: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "PLUS_DM", startIdx: 0, endIdx: high.length - 1, high, low, optInTimePeriod}) as any;
}
/**
* PPO - Percentage Price Oscillator
* @category Momentum Indicators
*
* @param inReal
* @param optInFastPeriod Fast Period - Number of period for the fast MA = 12
* @param optInSlowPeriod Slow Period - Number of period for the slow MA = 26
* @param optInMAType MA Type - Type of Moving Average = 0
*/
export async function PPO(inReal: number[], optInFastPeriod: number = 12, optInSlowPeriod: number = 26, optInMAType: MAType = 0): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "PPO", startIdx: 0, endIdx: inReal.length - 1, inReal, optInFastPeriod, optInSlowPeriod, optInMAType}) as any;
}
/**
* ROC - Rate of change : ((price/prevPrice)-1)*100
* @category Momentum Indicators
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 10
*/
export async function ROC(inReal: number[], optInTimePeriod: number = 10): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ROC", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* ROCP - Rate of change Percentage: (price-prevPrice)/prevPrice
* @category Momentum Indicators
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 10
*/
export async function ROCP(inReal: number[], optInTimePeriod: number = 10): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ROCP", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* ROCR - Rate of change ratio: (price/prevPrice)
* @category Momentum Indicators
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 10
*/
export async function ROCR(inReal: number[], optInTimePeriod: number = 10): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ROCR", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* ROCR100 - Rate of change ratio 100 scale: (price/prevPrice)*100
* @category Momentum Indicators
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 10
*/
export async function ROCR100(inReal: number[], optInTimePeriod: number = 10): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ROCR100", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* RSI - Relative Strength Index
* @category Momentum Indicators
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function RSI(inReal: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "RSI", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* STOCH - Stochastic
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInFastK_Period Fast-K Period - Time period for building the Fast-K line = 5
* @param optInSlowK_Period Slow-K Period - Smoothing for making the Slow-K line. Usually set to 3 = 3
* @param optInSlowK_MAType Slow-K MA - Type of Moving Average for Slow-K = 0
* @param optInSlowD_Period Slow-D Period - Smoothing for making the Slow-D line = 3
* @param optInSlowD_MAType Slow-D MA - Type of Moving Average for Slow-D = 0
*/
export async function STOCH(high: number[], low: number[], close: number[], optInFastK_Period: number = 5, optInSlowK_Period: number = 3, optInSlowK_MAType: MAType = 0, optInSlowD_Period: number = 3, optInSlowD_MAType: MAType = 0): Promise<IExecutionResult<{ outSlowK: number[], outSlowD: number[]}>> {
return await execute_async({
name: "STOCH", startIdx: 0, endIdx: high.length - 1, high, low, close, optInFastK_Period, optInSlowK_Period, optInSlowK_MAType, optInSlowD_Period, optInSlowD_MAType,
}) as any;
}
/**
* STOCHF - Stochastic Fast
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInFastK_Period Fast-K Period - Time period for building the Fast-K line = 5
* @param optInFastD_Period Fast-D Period - Smoothing for making the Fast-D line. Usually set to 3 = 3
* @param optInFastD_MAType Fast-D MA - Type of Moving Average for Fast-D = 0
*/
export async function STOCHF(high: number[], low: number[], close: number[], optInFastK_Period: number = 5, optInFastD_Period: number = 3, optInFastD_MAType: MAType = 0): Promise<IExecutionResult<{ outFastK: number[], outFastD: number[]}>> {
return await execute_async({ name: "STOCHF", startIdx: 0, endIdx: high.length - 1, high, low, close, optInFastK_Period, optInFastD_Period, optInFastD_MAType}) as any;
}
/**
* STOCHRSI - Stochastic Relative Strength Index
* @category Momentum Indicators
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 14
* @param optInFastK_Period Fast-K Period - Time period for building the Fast-K line = 5
* @param optInFastD_Period Fast-D Period - Smoothing for making the Fast-D line. Usually set to 3 = 3
* @param optInFastD_MAType Fast-D MA - Type of Moving Average for Fast-D = 0
*/
export async function STOCHRSI(inReal: number[], optInTimePeriod: number = 14, optInFastK_Period: number = 5, optInFastD_Period: number = 3, optInFastD_MAType: MAType = 0): Promise<IExecutionResult<{ outFastK: number[], outFastD: number[]}>> {
return await execute_async({ name: "STOCHRSI", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod, optInFastK_Period, optInFastD_Period, optInFastD_MAType}) as any;
}
/**
* TRIX - 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA
* @category Momentum Indicators
*
* @param inReal
* @param optInTimePeriod Time Period - Number of period = 30
*/
export async function TRIX(inReal: number[], optInTimePeriod: number = 30): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "TRIX", startIdx: 0, endIdx: inReal.length - 1, inReal, optInTimePeriod}) as any;
}
/**
* ULTOSC - Ultimate Oscillator
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod1 First Period - Number of bars for 1st period. = 7
* @param optInTimePeriod2 Second Period - Number of bars fro 2nd period = 14
* @param optInTimePeriod3 Third Period - Number of bars for 3rd period = 28
*/
export async function ULTOSC(high: number[], low: number[], close: number[], optInTimePeriod1: number = 7, optInTimePeriod2: number = 14, optInTimePeriod3: number = 28): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "ULTOSC", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod1, optInTimePeriod2, optInTimePeriod3}) as any;
}
/**
* WILLR - Williams' %R
* @category Momentum Indicators
*
* @param high
* @param low
* @param close
* @param optInTimePeriod Time Period - Number of period = 14
*/
export async function WILLR(high: number[], low: number[], close: number[], optInTimePeriod: number = 14): Promise<IExecutionResult<{ outReal: number[]}>> {
return await execute_async({ name: "WILLR", startIdx: 0, endIdx: high.length - 1, high, low, close, optInTimePeriod}) as any;
}
/**
* HT_DCPERIOD - Hilbert Transform - Dominant Cycle Period
* @category Cycle Indicators