rust_ta-lib 0.6.0-rc.1.build.6

TA-Lib - Technical Analysis Library
Documentation
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
/* TA-LIB Copyright (c) 1999-2008, Mario Fortier
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or
 * without modification, are permitted provided that the following
 * conditions are met:
 *
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in
 *   the documentation and/or other materials provided with the
 *   distribution.
 *
 * - Neither name of author nor the names of its contributors
 *   may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/* List of contributors:
 *
 *  Initial  Name/description
 *  -------------------------------------------------------------------
 *  MF       Mario Fortier
 *
 *
 * Change history:
 *
 *  MMDDYY BY   Description
 *  -------------------------------------------------------------------
 *  130101 MF   First version.
 *  111503 MF   Add TA_DEF_UI_Input_Price_CV
 */

/* Description:
 *    Defines const structures representing how data can be
 *    input/output from the TA functions.
 *    These structure are mainly used to build the tables\table<a..z>.c files.
 */
#include <stdlib.h>
#include "ta_abstract.h"
#include "ta_def_ui.h"

const char TA_GroupId_MathOperatorsString[]        = "Math Operators";
const char TA_GroupId_MathTransformString[]        = "Math Transform";
const char TA_GroupId_OverlapStudiesString[]       = "Overlap Studies";
const char TA_GroupId_VolatilityIndicatorsString[] = "Volatility Indicators";
const char TA_GroupId_MomentumIndicatorsString[]   = "Momentum Indicators";
const char TA_GroupId_CycleIndicatorsString[]      = "Cycle Indicators";
const char TA_GroupId_VolumeIndicatorsString[]     = "Volume Indicators";
const char TA_GroupId_PatternRecognitionString[]   = "Pattern Recognition";
const char TA_GroupId_StatisticString[]            = "Statistic Functions";
const char TA_GroupId_PriceTransformString[]       = "Price Transform";

const char *TA_GroupString[TA_NB_GROUP_ID] =
{
   &TA_GroupId_MathOperatorsString[0],
   &TA_GroupId_MathTransformString[0],
   &TA_GroupId_OverlapStudiesString[0],
   &TA_GroupId_VolatilityIndicatorsString[0],
   &TA_GroupId_MomentumIndicatorsString[0],
   &TA_GroupId_CycleIndicatorsString[0],
   &TA_GroupId_VolumeIndicatorsString[0],
   &TA_GroupId_PatternRecognitionString[0],
   &TA_GroupId_StatisticString[0],
   &TA_GroupId_PriceTransformString[0]
};

/*************************************************************
 * Define from here the TA_InputParameterInfo
 * These shall be sufficient for all possible TA functions.
 *************************************************************/
const TA_InputParameterInfo TA_DEF_UI_Input_Price_OHLCV =
                                  { TA_Input_Price, "inPriceOHLCV",
                                    TA_IN_PRICE_OPEN   |
                                    TA_IN_PRICE_HIGH   |
                                    TA_IN_PRICE_LOW    |
                                    TA_IN_PRICE_CLOSE  |
                                    TA_IN_PRICE_VOLUME };

const TA_InputParameterInfo TA_DEF_UI_Input_Price_HLCV =
                                  { TA_Input_Price, "inPriceHLCV",
                                    TA_IN_PRICE_HIGH   |
                                    TA_IN_PRICE_LOW    |
                                    TA_IN_PRICE_CLOSE  |
                                    TA_IN_PRICE_VOLUME };

const TA_InputParameterInfo TA_DEF_UI_Input_Price_OHLC =
                                  { TA_Input_Price, "inPriceOHLC",
                                    TA_IN_PRICE_OPEN   |
                                    TA_IN_PRICE_HIGH   |
                                    TA_IN_PRICE_LOW    |
                                    TA_IN_PRICE_CLOSE  };

const TA_InputParameterInfo TA_DEF_UI_Input_Price_HLC =
                                  { TA_Input_Price, "inPriceHLC",
                                    TA_IN_PRICE_HIGH   |
                                    TA_IN_PRICE_LOW    |
                                    TA_IN_PRICE_CLOSE  };

const TA_InputParameterInfo TA_DEF_UI_Input_Price_HL =
                                  { TA_Input_Price, "inPriceHL",
                                    TA_IN_PRICE_HIGH   |
                                    TA_IN_PRICE_LOW    };

const TA_InputParameterInfo TA_DEF_UI_Input_Price_OC =
                                  { TA_Input_Price, "inPriceOC",
                                    TA_IN_PRICE_OPEN  |
                                    TA_IN_PRICE_CLOSE };

const TA_InputParameterInfo TA_DEF_UI_Input_Price_CV =
                                  { TA_Input_Price, "inPriceCV",
                                    TA_IN_PRICE_CLOSE  |
                                    TA_IN_PRICE_VOLUME };

const TA_InputParameterInfo TA_DEF_UI_Input_Price_V =
                                  { TA_Input_Price, "inPriceV",
                                    TA_IN_PRICE_VOLUME };

const TA_InputParameterInfo TA_DEF_UI_Input_Real =
                                  { TA_Input_Real, "inReal", 0 };

const TA_InputParameterInfo TA_DEF_UI_Input_Periods =
                                  { TA_Input_Real, "inPeriods", 0 };

const TA_InputParameterInfo TA_DEF_UI_Input_Real0 =
                                  { TA_Input_Real, "inReal0", 0 };

const TA_InputParameterInfo TA_DEF_UI_Input_Real1 =
                                  { TA_Input_Real, "inReal1", 0 };

const TA_InputParameterInfo TA_DEF_UI_Input_Integer =
                                  { TA_Input_Integer, "inInteger", 0 };


/*************************************************************
 * Define from here the TA_OutputParameterInfo
 * These shall be sufficient for most of the TA functions.
 *************************************************************/
const TA_OutputParameterInfo TA_DEF_UI_Output_Real =
                                  { TA_Output_Real, "outReal", TA_OUT_LINE };

const TA_OutputParameterInfo TA_DEF_UI_Output_Integer =
                                  { TA_Output_Integer, "outInteger", TA_OUT_LINE };

/*****************************************************
 * Define from here the TA_Integer ranges
 ****************************************************/

const TA_IntegerRange TA_DEF_TimePeriod_Positive =
{
   1,             /* min */
   100000,        /* max */
   1,             /* suggested start */
   200,           /* suggested end   */
   1              /* suggested increment */
};

const TA_IntegerRange TA_DEF_TimePeriod_Positive_Minimum5 =
{
   5,             /* min */
   100000,        /* max */
   5,             /* suggested start */
   200,           /* suggested end   */
   1              /* suggested increment */
};

const TA_IntegerRange TA_DEF_TimePeriod_Positive_Minimum2 =
{
   2,             /* min */
   100000,        /* max */
   4,             /* suggested start */
   200,           /* suggested end   */
   1              /* suggested increment */
};

const TA_IntegerRange TA_DEF_HorizontalShiftPeriod =
{
   -200,               /* min */
    200,               /* max   */
   0,                  /* suggested start */
   8,                  /* suggested end   */
   1                   /* suggested increment */
};


/*****************************************************
 * Define from here the TA_Real ranges
 ****************************************************/
const TA_RealRange TA_DEF_VerticalShiftPercent =
{
   -99.0,            /* min */
   99.0,             /* max   */
   1,                /* precision */
   -10.0,            /* suggested start */
   10.0,             /* suggested end   */
   0.5               /* suggested increment */
};

const TA_RealRange TA_DEF_NbDeviation =
{
   TA_REAL_MIN,    /* min */
   TA_REAL_MAX,    /* max */
   2,              /* precision */
   -2.0,           /* suggested start */
   2.0,            /* suggested end   */
   0.2             /* suggested increment */
};

const TA_RealRange TA_DEF_ZeroToOne =
{
   0.00,  /* min */
   1.00,  /* max */
   2,     /* precision */
   0.01,  /* suggested start */
   1.00,  /* suggested end   */
   0.05   /* suggested increment */
};

const TA_RealRange TA_DEF_RealPositive =
{
   0.00,  /* min */
   TA_REAL_MAX,  /* max */
   0,    /* precision */
   0.0,  /* suggested start */
   0.0,  /* suggested end   */
   0.0   /* suggested increment */
};

/*****************************************************
 * Define from here the TA_OptInputParameterInfo.
 ****************************************************/

const TA_OptInputParameterInfo TA_DEF_UI_MinPeriod =
{
   TA_OptInput_IntegerRange, /* type */
   "optInMinPeriod",        /* paramName */
   0,                        /* flags */

   "Minimum Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   2, /* defaultValue */
   "Value less than minimum will be changed to Minimum period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_MaxPeriod =
{
   TA_OptInput_IntegerRange, /* type */
   "optInMaxPeriod",        /* paramName */
   0,                        /* flags */

   "Maximum Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   30, /* defaultValue */
   "Value higher than maximum will be changed to Maximum period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_30_MINIMUM2 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   30, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_20_MINIMUM2 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   20, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_21_MINIMUM2 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   21, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_14_MINIMUM2 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   14, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_14_MINIMUM5 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum5, /* dataSet */
   14, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_10_MINIMUM2 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   10, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_5_MINIMUM2 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   5, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_30 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive, /* dataSet */
   30, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_14 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive, /* dataSet */
   14, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_10 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive, /* dataSet */
   10, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_TimePeriod_5 =
{
   TA_OptInput_IntegerRange, /* type */
   "optInTimePeriod",        /* paramName */
   0,                        /* flags */

   "Time Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive, /* dataSet */
   5, /* defaultValue */
   "Number of period", /* hint */

   NULL /* helpFile */
};


/* Use for the multiplier of standard deviations. */
const TA_OptInputParameterInfo TA_DEF_UI_NbDeviation =
{
   TA_OptInput_RealRange, /* type */
   "optInNbDev",          /* paramName */
   0,                     /* flags */

   "Deviations",          /* displayName */
   (const void *)&TA_DEF_NbDeviation, /* dataSet */
   1.0, /* defaultValue */
   "Nb of deviations", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_Penetration_30 =
{
   TA_OptInput_RealRange,     /* type */
   "optInPenetration",        /* paramName */
   0,                         /* flags */

   "Penetration",             /* displayName */
   (const void *)&TA_DEF_RealPositive, /* dataSet */
   0.3, /* defaultValue */
   "Percentage of penetration of a candle within another candle", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_Penetration_50 =
{
   TA_OptInput_RealRange,     /* type */
   "optInPenetration",        /* paramName */
   0,                         /* flags */

   "Penetration",             /* displayName */
   (const void *)&TA_DEF_RealPositive, /* dataSet */
   0.5, /* defaultValue */
   "Percentage of penetration of a candle within another candle", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_VerticalShift =
{
   TA_OptInput_RealRange,  /* type */
   "optInVertShift",       /* paramName */
   TA_OPTIN_IS_PERCENT,       /* flags */

   "Vertical Shift",       /* displayName */
   (const void *)&TA_DEF_VerticalShiftPercent, /* dataSet */
   0, /* defaultValue */
   "Positive number shift upwards, negative downwards", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_HorizontalShift =
{
   TA_OptInput_IntegerRange,  /* type */
   "optInHorizShift",         /* paramName */
   0,                         /* flags */

   "Horizontal Shift",        /* displayName */
   (const void *)&TA_DEF_HorizontalShiftPeriod, /* dataSet */
   0, /* defaultValue */
   "Positive number shift 'n' period to the right, negative shift to the left", /* hint */

   NULL /* helpFile */
};

/* Define the values available for the MA function. 
 * 
 * Many TA function using the MA internally may wish to
 * re-use this parameter as one of their own. That way a
 * new MA will provide automatically a new way of calculating
 * to a multitude of other TA functions.
 */
static const TA_IntegerDataPair TA_MA_TypeDataPair[] =
{
   {0,"SMA"},
   {1,"EMA"},
   {2,"WMA"},
   {3,"DEMA" },
   {4,"TEMA" },
   {5,"TRIMA"},
   {6,"KAMA" },
   {7,"MAMA" },
   {8,"T3"}
   /*{...,"Linear Regression"}*/
};

const TA_IntegerList TA_MA_TypeList =
{
   &TA_MA_TypeDataPair[0],
   sizeof(TA_MA_TypeDataPair)/sizeof(TA_IntegerDataPair)
};

const TA_OptInputParameterInfo TA_DEF_UI_MA_Method =
{
   TA_OptInput_IntegerList, /* type */
   "optInMAType",           /* paramName */
   0,                       /* flags */

   "MA Type",                /* displayName */
   (const void *)&TA_MA_TypeList, /* dataSet */
   0, /* defaultValue = simple average */
   "Type of Moving Average", /* hint */

   NULL /* helpFile */
};

/* When a TA function needs two period (often called
 * a fast and slow period).
 */
const TA_OptInputParameterInfo TA_DEF_UI_Fast_Period =
{
   TA_OptInput_IntegerRange, /* type */
   "optInFastPeriod",        /* paramName */
   0,                        /* flags */

   "Fast Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   12, /* defaultValue */
   "Number of period for the fast MA", /* hint */

   NULL /* helpFile */
};

const TA_OptInputParameterInfo TA_DEF_UI_Slow_Period =
{
   TA_OptInput_IntegerRange, /* type */
   "optInSlowPeriod",        /* paramName */
   0,                        /* flags */

   "Slow Period",            /* displayName */
   (const void *)&TA_DEF_TimePeriod_Positive_Minimum2, /* dataSet */
   26, /* defaultValue */
   "Number of period for the slow MA", /* hint */

   NULL /* helpFile */
};