tulirb 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,751 @@
1
+ #include "tulirb.h"
2
+
3
+ static void xfree_ptr_arr(TI_REAL **, size_t);
4
+
5
+ static inline VALUE ti_wrapper(VALUE inputs, VALUE opts, char *indicator_name)
6
+ {
7
+ Check_Type(inputs, T_ARRAY);
8
+ Check_Type(opts, T_ARRAY);
9
+ const ti_indicator_info *indicator = ti_find_indicator(indicator_name);
10
+
11
+ if (RARRAY_LEN(inputs) != indicator->inputs)
12
+ {
13
+ rb_raise(rb_eArgError, "Invalid inputs size, expected: %i inputs", indicator->inputs);
14
+ }
15
+
16
+ if (RARRAY_LEN(opts) != indicator->options)
17
+ {
18
+ rb_raise(rb_eArgError, "Invalid options size, expected: %i options", indicator->options);
19
+ }
20
+
21
+ TI_REAL *options = (TI_REAL *)xmalloc(sizeof(TI_REAL[RARRAY_LEN(opts)]));
22
+
23
+ for (size_t i = 0; i < RARRAY_LEN(opts); i++)
24
+ options[i] = NUM2DBL(rb_ary_entry(opts, i));
25
+
26
+ const int start = indicator->start(options);
27
+
28
+ const int size = RARRAY_LEN(rb_ary_entry(inputs, 0));
29
+ const int output_length = size - start;
30
+
31
+ if (output_length < 0)
32
+ return Qnil;
33
+
34
+ TI_REAL **c_inputs = xmalloc(indicator->inputs * sizeof(TI_REAL *));
35
+ for (size_t i = 0; i < indicator->inputs; i++)
36
+ {
37
+ TI_REAL *c_entry = xmalloc(sizeof(TI_REAL[size]));
38
+ VALUE entry = rb_ary_entry(inputs, i);
39
+ for (size_t j = 0; j < size; j++)
40
+ {
41
+ c_entry[j] = NUM2DBL(rb_ary_entry(entry, j));
42
+ }
43
+ c_inputs[i] = c_entry;
44
+ }
45
+
46
+ TI_REAL **outputs = xmalloc(indicator->outputs * sizeof(TI_REAL *));
47
+ for (size_t i = 0; i < indicator->outputs; i++)
48
+ outputs[i] = xmalloc(sizeof(TI_REAL[output_length]));
49
+
50
+ int error = indicator->indicator(size, (const TI_REAL *const *)c_inputs, options, outputs);
51
+
52
+ xfree_ptr_arr(c_inputs, indicator->inputs);
53
+ xfree(options);
54
+
55
+ if (error == TI_INVALID_OPTION)
56
+ {
57
+ xfree_ptr_arr(outputs, indicator->outputs);
58
+ rb_raise(rb_eArgError, "The combination of option values is invalid");
59
+ }
60
+
61
+ VALUE ret = rb_ary_new_capa(indicator->outputs);
62
+ for (int i = 0; i < indicator->outputs; i++)
63
+ {
64
+ VALUE output = rb_ary_new_capa(output_length);
65
+ for (size_t j = 0; j < output_length; j++)
66
+ {
67
+ rb_ary_push(output, DBL2NUM(outputs[i][j]));
68
+ }
69
+ rb_ary_push(ret, output);
70
+ }
71
+
72
+ xfree_ptr_arr(outputs, indicator->outputs);
73
+ return ret;
74
+ }
75
+
76
+ static void xfree_ptr_arr(TI_REAL **ptr, size_t size)
77
+ {
78
+ for (int i = 0; i < size; i++)
79
+ xfree(ptr[i]);
80
+ xfree(ptr);
81
+ }
82
+
83
+ // Alphabetical order
84
+
85
+ VALUE rb_tulip_abs(VALUE self, VALUE inputs, VALUE opts)
86
+ {
87
+ return ti_wrapper(inputs, opts, "abs");
88
+ }
89
+
90
+ VALUE rb_tulip_acos(VALUE self, VALUE inputs, VALUE opts)
91
+ {
92
+ return ti_wrapper(inputs, opts, "acos");
93
+ }
94
+
95
+ VALUE rb_tulip_ad(VALUE self, VALUE inputs, VALUE opts)
96
+ {
97
+ return ti_wrapper(inputs, opts, "ad");
98
+ }
99
+
100
+ VALUE rb_tulip_add(VALUE self, VALUE inputs, VALUE opts)
101
+ {
102
+ return ti_wrapper(inputs, opts, "add");
103
+ }
104
+
105
+ VALUE rb_tulip_adosc(VALUE self, VALUE inputs, VALUE opts)
106
+ {
107
+ return ti_wrapper(inputs, opts, "adosc");
108
+ }
109
+
110
+ VALUE rb_tulip_adx(VALUE self, VALUE inputs, VALUE opts)
111
+ {
112
+ return ti_wrapper(inputs, opts, "adx");
113
+ }
114
+
115
+ VALUE rb_tulip_adxr(VALUE self, VALUE inputs, VALUE opts)
116
+ {
117
+ return ti_wrapper(inputs, opts, "adxr");
118
+ }
119
+
120
+ VALUE rb_tulip_ao(VALUE self, VALUE inputs, VALUE opts)
121
+ {
122
+ return ti_wrapper(inputs, opts, "ao");
123
+ }
124
+
125
+ VALUE rb_tulip_apo(VALUE self, VALUE inputs, VALUE opts)
126
+ {
127
+ return ti_wrapper(inputs, opts, "apo");
128
+ }
129
+
130
+ VALUE rb_tulip_aroon(VALUE self, VALUE inputs, VALUE opts)
131
+ {
132
+ return ti_wrapper(inputs, opts, "aroon");
133
+ }
134
+
135
+ VALUE rb_tulip_aroonosc(VALUE self, VALUE inputs, VALUE opts)
136
+ {
137
+ return ti_wrapper(inputs, opts, "aroonosc");
138
+ }
139
+
140
+ VALUE rb_tulip_asin(VALUE self, VALUE inputs, VALUE opts)
141
+ {
142
+ return ti_wrapper(inputs, opts, "asin");
143
+ }
144
+
145
+ VALUE rb_tulip_atan(VALUE self, VALUE inputs, VALUE opts)
146
+ {
147
+ return ti_wrapper(inputs, opts, "atan");
148
+ }
149
+
150
+ VALUE rb_tulip_atr(VALUE self, VALUE inputs, VALUE opts)
151
+ {
152
+ return ti_wrapper(inputs, opts, "atr");
153
+ }
154
+
155
+ VALUE rb_tulip_avgprice(VALUE self, VALUE inputs, VALUE opts)
156
+ {
157
+ return ti_wrapper(inputs, opts, "avgprice");
158
+ }
159
+
160
+ VALUE rb_tulip_bbands(VALUE self, VALUE inputs, VALUE opts)
161
+ {
162
+ return ti_wrapper(inputs, opts, "bbands");
163
+ }
164
+
165
+ VALUE rb_tulip_bop(VALUE self, VALUE inputs, VALUE opts)
166
+ {
167
+ return ti_wrapper(inputs, opts, "bop");
168
+ }
169
+
170
+ VALUE rb_tulip_cci(VALUE self, VALUE inputs, VALUE opts)
171
+ {
172
+ return ti_wrapper(inputs, opts, "cci");
173
+ }
174
+
175
+ VALUE rb_tulip_ceil(VALUE self, VALUE inputs, VALUE opts)
176
+ {
177
+ return ti_wrapper(inputs, opts, "ceil");
178
+ }
179
+
180
+ VALUE rb_tulip_cmo(VALUE self, VALUE inputs, VALUE opts)
181
+ {
182
+ return ti_wrapper(inputs, opts, "cmo");
183
+ }
184
+
185
+ VALUE rb_tulip_cos(VALUE self, VALUE inputs, VALUE opts)
186
+ {
187
+ return ti_wrapper(inputs, opts, "cos");
188
+ }
189
+
190
+ VALUE rb_tulip_cosh(VALUE self, VALUE inputs, VALUE opts)
191
+ {
192
+ return ti_wrapper(inputs, opts, "cosh");
193
+ }
194
+
195
+ VALUE rb_tulip_crossany(VALUE self, VALUE inputs, VALUE opts)
196
+ {
197
+ return ti_wrapper(inputs, opts, "crossany");
198
+ }
199
+
200
+ VALUE rb_tulip_crossover(VALUE self, VALUE inputs, VALUE opts)
201
+ {
202
+ return ti_wrapper(inputs, opts, "crossover");
203
+ }
204
+
205
+ VALUE rb_tulip_cvi(VALUE self, VALUE inputs, VALUE opts)
206
+ {
207
+ return ti_wrapper(inputs, opts, "cvi");
208
+ }
209
+
210
+ VALUE rb_tulip_decay(VALUE self, VALUE inputs, VALUE opts)
211
+ {
212
+ return ti_wrapper(inputs, opts, "decay");
213
+ }
214
+
215
+ VALUE rb_tulip_dema(VALUE self, VALUE inputs, VALUE opts)
216
+ {
217
+ return ti_wrapper(inputs, opts, "dema");
218
+ }
219
+
220
+ VALUE rb_tulip_di(VALUE self, VALUE inputs, VALUE opts)
221
+ {
222
+ return ti_wrapper(inputs, opts, "di");
223
+ }
224
+
225
+ VALUE rb_tulip_div(VALUE self, VALUE inputs, VALUE opts)
226
+ {
227
+ return ti_wrapper(inputs, opts, "div");
228
+ }
229
+
230
+ VALUE rb_tulip_dm(VALUE self, VALUE inputs, VALUE opts)
231
+ {
232
+ return ti_wrapper(inputs, opts, "dm");
233
+ }
234
+
235
+ VALUE rb_tulip_dpo(VALUE self, VALUE inputs, VALUE opts)
236
+ {
237
+ return ti_wrapper(inputs, opts, "dpo");
238
+ }
239
+
240
+ VALUE rb_tulip_dx(VALUE self, VALUE inputs, VALUE opts)
241
+ {
242
+ return ti_wrapper(inputs, opts, "dx");
243
+ }
244
+
245
+ VALUE rb_tulip_edecay(VALUE self, VALUE inputs, VALUE opts)
246
+ {
247
+ return ti_wrapper(inputs, opts, "edecay");
248
+ }
249
+
250
+ VALUE rb_tulip_ema(VALUE self, VALUE inputs, VALUE opts)
251
+ {
252
+ return ti_wrapper(inputs, opts, "ema");
253
+ }
254
+
255
+ VALUE rb_tulip_emv(VALUE self, VALUE inputs, VALUE opts)
256
+ {
257
+ return ti_wrapper(inputs, opts, "emv");
258
+ }
259
+
260
+ VALUE rb_tulip_exp(VALUE self, VALUE inputs, VALUE opts)
261
+ {
262
+ return ti_wrapper(inputs, opts, "exp");
263
+ }
264
+
265
+ VALUE rb_tulip_fisher(VALUE self, VALUE inputs, VALUE opts)
266
+ {
267
+ return ti_wrapper(inputs, opts, "fisher");
268
+ }
269
+
270
+ VALUE rb_tulip_floor(VALUE self, VALUE inputs, VALUE opts)
271
+ {
272
+ return ti_wrapper(inputs, opts, "floor");
273
+ }
274
+
275
+ VALUE rb_tulip_fosc(VALUE self, VALUE inputs, VALUE opts)
276
+ {
277
+ return ti_wrapper(inputs, opts, "fosc");
278
+ }
279
+
280
+ VALUE rb_tulip_hma(VALUE self, VALUE inputs, VALUE opts)
281
+ {
282
+ return ti_wrapper(inputs, opts, "hma");
283
+ }
284
+
285
+ VALUE rb_tulip_kama(VALUE self, VALUE inputs, VALUE opts)
286
+ {
287
+ return ti_wrapper(inputs, opts, "kama");
288
+ }
289
+
290
+ VALUE rb_tulip_kvo(VALUE self, VALUE inputs, VALUE opts)
291
+ {
292
+ return ti_wrapper(inputs, opts, "kvo");
293
+ }
294
+
295
+ VALUE rb_tulip_lag(VALUE self, VALUE inputs, VALUE opts)
296
+ {
297
+ return ti_wrapper(inputs, opts, "lag");
298
+ }
299
+
300
+ VALUE rb_tulip_linreg(VALUE self, VALUE inputs, VALUE opts)
301
+ {
302
+ return ti_wrapper(inputs, opts, "linreg");
303
+ }
304
+
305
+ VALUE rb_tulip_linregintercept(VALUE self, VALUE inputs, VALUE opts)
306
+ {
307
+ return ti_wrapper(inputs, opts, "linregintercept");
308
+ }
309
+
310
+ VALUE rb_tulip_linregslope(VALUE self, VALUE inputs, VALUE opts)
311
+ {
312
+ return ti_wrapper(inputs, opts, "linregslope");
313
+ }
314
+
315
+ VALUE rb_tulip_ln(VALUE self, VALUE inputs, VALUE opts)
316
+ {
317
+ return ti_wrapper(inputs, opts, "ln");
318
+ }
319
+
320
+ VALUE rb_tulip_log10(VALUE self, VALUE inputs, VALUE opts)
321
+ {
322
+ return ti_wrapper(inputs, opts, "log10");
323
+ }
324
+
325
+ VALUE rb_tulip_macd(VALUE self, VALUE inputs, VALUE opts)
326
+ {
327
+ return ti_wrapper(inputs, opts, "macd");
328
+ }
329
+
330
+ VALUE rb_tulip_marketfi(VALUE self, VALUE inputs, VALUE opts)
331
+ {
332
+ return ti_wrapper(inputs, opts, "marketfi");
333
+ }
334
+
335
+ VALUE rb_tulip_mass(VALUE self, VALUE inputs, VALUE opts)
336
+ {
337
+ return ti_wrapper(inputs, opts, "mass");
338
+ }
339
+
340
+ VALUE rb_tulip_max(VALUE self, VALUE inputs, VALUE opts)
341
+ {
342
+ return ti_wrapper(inputs, opts, "max");
343
+ }
344
+
345
+ VALUE rb_tulip_md(VALUE self, VALUE inputs, VALUE opts)
346
+ {
347
+ return ti_wrapper(inputs, opts, "md");
348
+ }
349
+
350
+ VALUE rb_tulip_medprice(VALUE self, VALUE inputs, VALUE opts)
351
+ {
352
+ return ti_wrapper(inputs, opts, "medprice");
353
+ }
354
+
355
+ VALUE rb_tulip_mfi(VALUE self, VALUE inputs, VALUE opts)
356
+ {
357
+ return ti_wrapper(inputs, opts, "mfi");
358
+ }
359
+
360
+ VALUE rb_tulip_min(VALUE self, VALUE inputs, VALUE opts)
361
+ {
362
+ return ti_wrapper(inputs, opts, "min");
363
+ }
364
+
365
+ VALUE rb_tulip_mom(VALUE self, VALUE inputs, VALUE opts)
366
+ {
367
+ return ti_wrapper(inputs, opts, "mom");
368
+ }
369
+
370
+ VALUE rb_tulip_msw(VALUE self, VALUE inputs, VALUE opts)
371
+ {
372
+ return ti_wrapper(inputs, opts, "msw");
373
+ }
374
+
375
+ VALUE rb_tulip_mul(VALUE self, VALUE inputs, VALUE opts)
376
+ {
377
+ return ti_wrapper(inputs, opts, "mul");
378
+ }
379
+
380
+ VALUE rb_tulip_natr(VALUE self, VALUE inputs, VALUE opts)
381
+ {
382
+ return ti_wrapper(inputs, opts, "natr");
383
+ }
384
+
385
+ VALUE rb_tulip_nvi(VALUE self, VALUE inputs, VALUE opts)
386
+ {
387
+ return ti_wrapper(inputs, opts, "nvi");
388
+ }
389
+
390
+ VALUE rb_tulip_obv(VALUE self, VALUE inputs, VALUE opts)
391
+ {
392
+ return ti_wrapper(inputs, opts, "obv");
393
+ }
394
+
395
+ VALUE rb_tulip_ppo(VALUE self, VALUE inputs, VALUE opts)
396
+ {
397
+ return ti_wrapper(inputs, opts, "ppo");
398
+ }
399
+
400
+ VALUE rb_tulip_psar(VALUE self, VALUE inputs, VALUE opts)
401
+ {
402
+ return ti_wrapper(inputs, opts, "psar");
403
+ }
404
+
405
+ VALUE rb_tulip_pvi(VALUE self, VALUE inputs, VALUE opts)
406
+ {
407
+ return ti_wrapper(inputs, opts, "pvi");
408
+ }
409
+
410
+ VALUE rb_tulip_qstick(VALUE self, VALUE inputs, VALUE opts)
411
+ {
412
+ return ti_wrapper(inputs, opts, "qstick");
413
+ }
414
+
415
+ VALUE rb_tulip_roc(VALUE self, VALUE inputs, VALUE opts)
416
+ {
417
+ return ti_wrapper(inputs, opts, "roc");
418
+ }
419
+
420
+ VALUE rb_tulip_rocr(VALUE self, VALUE inputs, VALUE opts)
421
+ {
422
+ return ti_wrapper(inputs, opts, "rocr");
423
+ }
424
+
425
+ VALUE rb_tulip_round(VALUE self, VALUE inputs, VALUE opts)
426
+ {
427
+ return ti_wrapper(inputs, opts, "round");
428
+ }
429
+
430
+ VALUE rb_tulip_rsi(VALUE self, VALUE inputs, VALUE opts)
431
+ {
432
+ return ti_wrapper(inputs, opts, "rsi");
433
+ }
434
+
435
+ VALUE rb_tulip_sin(VALUE self, VALUE inputs, VALUE opts)
436
+ {
437
+ return ti_wrapper(inputs, opts, "sin");
438
+ }
439
+
440
+ VALUE rb_tulip_sinh(VALUE self, VALUE inputs, VALUE opts)
441
+ {
442
+ return ti_wrapper(inputs, opts, "sinh");
443
+ }
444
+
445
+ VALUE rb_tulip_sma(VALUE self, VALUE inputs, VALUE opts)
446
+ {
447
+ return ti_wrapper(inputs, opts, "sma");
448
+ }
449
+
450
+ VALUE rb_tulip_sqrt(VALUE self, VALUE inputs, VALUE opts)
451
+ {
452
+ return ti_wrapper(inputs, opts, "sqrt");
453
+ }
454
+
455
+ VALUE rb_tulip_stddev(VALUE self, VALUE inputs, VALUE opts)
456
+ {
457
+ return ti_wrapper(inputs, opts, "stddev");
458
+ }
459
+
460
+ VALUE rb_tulip_stderr(VALUE self, VALUE inputs, VALUE opts)
461
+ {
462
+ return ti_wrapper(inputs, opts, "stderr");
463
+ }
464
+
465
+ VALUE rb_tulip_stoch(VALUE self, VALUE inputs, VALUE opts)
466
+ {
467
+ return ti_wrapper(inputs, opts, "stoch");
468
+ }
469
+
470
+ VALUE rb_tulip_stochrsi(VALUE self, VALUE inputs, VALUE opts)
471
+ {
472
+ return ti_wrapper(inputs, opts, "stochrsi");
473
+ }
474
+
475
+ VALUE rb_tulip_sub(VALUE self, VALUE inputs, VALUE opts)
476
+ {
477
+ return ti_wrapper(inputs, opts, "sub");
478
+ }
479
+
480
+ VALUE rb_tulip_sum(VALUE self, VALUE inputs, VALUE opts)
481
+ {
482
+ return ti_wrapper(inputs, opts, "sum");
483
+ }
484
+
485
+ VALUE rb_tulip_tan(VALUE self, VALUE inputs, VALUE opts)
486
+ {
487
+ return ti_wrapper(inputs, opts, "tan");
488
+ }
489
+
490
+ VALUE rb_tulip_tanh(VALUE self, VALUE inputs, VALUE opts)
491
+ {
492
+ return ti_wrapper(inputs, opts, "tanh");
493
+ }
494
+
495
+ VALUE rb_tulip_tema(VALUE self, VALUE inputs, VALUE opts)
496
+ {
497
+ return ti_wrapper(inputs, opts, "tema");
498
+ }
499
+
500
+ VALUE rb_tulip_todeg(VALUE self, VALUE inputs, VALUE opts)
501
+ {
502
+ return ti_wrapper(inputs, opts, "todeg");
503
+ }
504
+
505
+ VALUE rb_tulip_torad(VALUE self, VALUE inputs, VALUE opts)
506
+ {
507
+ return ti_wrapper(inputs, opts, "torad");
508
+ }
509
+
510
+ VALUE rb_tulip_tr(VALUE self, VALUE inputs, VALUE opts)
511
+ {
512
+ return ti_wrapper(inputs, opts, "tr");
513
+ }
514
+
515
+ VALUE rb_tulip_trima(VALUE self, VALUE inputs, VALUE opts)
516
+ {
517
+ return ti_wrapper(inputs, opts, "trima");
518
+ }
519
+
520
+ VALUE rb_tulip_trix(VALUE self, VALUE inputs, VALUE opts)
521
+ {
522
+ return ti_wrapper(inputs, opts, "trix");
523
+ }
524
+
525
+ VALUE rb_tulip_trunc(VALUE self, VALUE inputs, VALUE opts)
526
+ {
527
+ return ti_wrapper(inputs, opts, "trunc");
528
+ }
529
+
530
+ VALUE rb_tulip_tsf(VALUE self, VALUE inputs, VALUE opts)
531
+ {
532
+ return ti_wrapper(inputs, opts, "tsf");
533
+ }
534
+
535
+ VALUE rb_tulip_typprice(VALUE self, VALUE inputs, VALUE opts)
536
+ {
537
+ return ti_wrapper(inputs, opts, "typprice");
538
+ }
539
+
540
+ VALUE rb_tulip_ultosc(VALUE self, VALUE inputs, VALUE opts)
541
+ {
542
+ return ti_wrapper(inputs, opts, "ultosc");
543
+ }
544
+
545
+ VALUE rb_tulip_var(VALUE self, VALUE inputs, VALUE opts)
546
+ {
547
+ return ti_wrapper(inputs, opts, "var");
548
+ }
549
+
550
+ VALUE rb_tulip_vhf(VALUE self, VALUE inputs, VALUE opts)
551
+ {
552
+ return ti_wrapper(inputs, opts, "vhf");
553
+ }
554
+
555
+ VALUE rb_tulip_vidya(VALUE self, VALUE inputs, VALUE opts)
556
+ {
557
+ return ti_wrapper(inputs, opts, "vidya");
558
+ }
559
+
560
+ VALUE rb_tulip_volatility(VALUE self, VALUE inputs, VALUE opts)
561
+ {
562
+ return ti_wrapper(inputs, opts, "volatility");
563
+ }
564
+
565
+ VALUE rb_tulip_vosc(VALUE self, VALUE inputs, VALUE opts)
566
+ {
567
+ return ti_wrapper(inputs, opts, "vosc");
568
+ }
569
+
570
+ VALUE rb_tulip_vwma(VALUE self, VALUE inputs, VALUE opts)
571
+ {
572
+ return ti_wrapper(inputs, opts, "vwma");
573
+ }
574
+
575
+ VALUE rb_tulip_wad(VALUE self, VALUE inputs, VALUE opts)
576
+ {
577
+ return ti_wrapper(inputs, opts, "wad");
578
+ }
579
+
580
+ VALUE rb_tulip_wcprice(VALUE self, VALUE inputs, VALUE opts)
581
+ {
582
+ return ti_wrapper(inputs, opts, "wcprice");
583
+ }
584
+
585
+ VALUE rb_tulip_wilders(VALUE self, VALUE inputs, VALUE opts)
586
+ {
587
+ return ti_wrapper(inputs, opts, "wilders");
588
+ }
589
+
590
+ VALUE rb_tulip_willr(VALUE self, VALUE inputs, VALUE opts)
591
+ {
592
+ return ti_wrapper(inputs, opts, "willr");
593
+ }
594
+
595
+ VALUE rb_tulip_wma(VALUE self, VALUE inputs, VALUE opts)
596
+ {
597
+ return ti_wrapper(inputs, opts, "wma");
598
+ }
599
+
600
+ VALUE rb_tulip_zlema(VALUE self, VALUE inputs, VALUE opts)
601
+ {
602
+ return ti_wrapper(inputs, opts, "zlema");
603
+ }
604
+
605
+ static inline VALUE parameterize(char *str)
606
+ {
607
+ return rb_funcall(rb_str_new2(str), rb_intern("gsub"), 2, rb_str_new2(" "), rb_str_new2("_"));
608
+ }
609
+
610
+ static inline VALUE rb_indicators_info()
611
+ {
612
+ VALUE ret = rb_hash_new();
613
+ for (size_t i = 0; i < TI_INDICATOR_COUNT; i++)
614
+ {
615
+ VALUE indicators_hash = rb_hash_new();
616
+ const ti_indicator_info indicator = ti_indicators[i];
617
+ VALUE opts_ary = rb_ary_new();
618
+ VALUE input_names_ary = rb_ary_new();
619
+
620
+ rb_hash_aset(indicators_hash, ID2SYM(rb_intern("full_name")), rb_str_new2(indicator.full_name));
621
+ rb_hash_aset(indicators_hash, ID2SYM(rb_intern("inputs")), INT2NUM(indicator.inputs));
622
+ rb_hash_aset(indicators_hash, ID2SYM(rb_intern("outputs")), INT2NUM(indicator.outputs));
623
+ rb_hash_aset(indicators_hash, ID2SYM(rb_intern("options")), opts_ary);
624
+ rb_hash_aset(indicators_hash, ID2SYM(rb_intern("input_names")), input_names_ary);
625
+ for (int i = 0; i < indicator.options; i++)
626
+ {
627
+ rb_ary_push(opts_ary, parameterize(indicator.option_names[i]));
628
+ };
629
+ for (int i = 0; i < indicator.inputs; i++)
630
+ {
631
+ rb_ary_push(input_names_ary, parameterize(indicator.input_names[i]));
632
+ };
633
+ rb_hash_aset(ret, ID2SYM(rb_intern(indicator.name)), indicators_hash);
634
+ }
635
+ return ret;
636
+ };
637
+
638
+ void Init_tulirb(void)
639
+ {
640
+ VALUE rb_mTulirb;
641
+ VALUE rb_mTulirbExt;
642
+
643
+ rb_mTulirb = rb_define_module("Tulirb");
644
+ rb_define_const(rb_mTulirb, "INDICATORS_INFO", rb_indicators_info());
645
+ rb_mTulirbExt = rb_define_module_under(rb_mTulirb, "Ext");
646
+
647
+ rb_define_module_function(rb_mTulirbExt, "abs", rb_tulip_abs, 2);
648
+ rb_define_module_function(rb_mTulirbExt, "acos", rb_tulip_acos, 2);
649
+ rb_define_module_function(rb_mTulirbExt, "ad", rb_tulip_ad, 2);
650
+ rb_define_module_function(rb_mTulirbExt, "add", rb_tulip_add, 2);
651
+ rb_define_module_function(rb_mTulirbExt, "adosc", rb_tulip_adosc, 2);
652
+ rb_define_module_function(rb_mTulirbExt, "adx", rb_tulip_adx, 2);
653
+ rb_define_module_function(rb_mTulirbExt, "adxr", rb_tulip_adxr, 2);
654
+ rb_define_module_function(rb_mTulirbExt, "ao", rb_tulip_ao, 2);
655
+ rb_define_module_function(rb_mTulirbExt, "apo", rb_tulip_apo, 2);
656
+ rb_define_module_function(rb_mTulirbExt, "aroon", rb_tulip_aroon, 2);
657
+ rb_define_module_function(rb_mTulirbExt, "aroonosc", rb_tulip_aroonosc, 2);
658
+ rb_define_module_function(rb_mTulirbExt, "asin", rb_tulip_asin, 2);
659
+ rb_define_module_function(rb_mTulirbExt, "atan", rb_tulip_atan, 2);
660
+ rb_define_module_function(rb_mTulirbExt, "atr", rb_tulip_atr, 2);
661
+ rb_define_module_function(rb_mTulirbExt, "avgprice", rb_tulip_avgprice, 2);
662
+ rb_define_module_function(rb_mTulirbExt, "bbands", rb_tulip_bbands, 2);
663
+ rb_define_module_function(rb_mTulirbExt, "bop", rb_tulip_bop, 2);
664
+ rb_define_module_function(rb_mTulirbExt, "cci", rb_tulip_cci, 2);
665
+ rb_define_module_function(rb_mTulirbExt, "ceil", rb_tulip_ceil, 2);
666
+ rb_define_module_function(rb_mTulirbExt, "cmo", rb_tulip_cmo, 2);
667
+ rb_define_module_function(rb_mTulirbExt, "cos", rb_tulip_cos, 2);
668
+ rb_define_module_function(rb_mTulirbExt, "cosh", rb_tulip_cosh, 2);
669
+ rb_define_module_function(rb_mTulirbExt, "crossany", rb_tulip_crossany, 2);
670
+ rb_define_module_function(rb_mTulirbExt, "crossover", rb_tulip_crossover, 2);
671
+ rb_define_module_function(rb_mTulirbExt, "cvi", rb_tulip_cvi, 2);
672
+ rb_define_module_function(rb_mTulirbExt, "decay", rb_tulip_decay, 2);
673
+ rb_define_module_function(rb_mTulirbExt, "dema", rb_tulip_dema, 2);
674
+ rb_define_module_function(rb_mTulirbExt, "di", rb_tulip_di, 2);
675
+ rb_define_module_function(rb_mTulirbExt, "div", rb_tulip_div, 2);
676
+ rb_define_module_function(rb_mTulirbExt, "dm", rb_tulip_dm, 2);
677
+ rb_define_module_function(rb_mTulirbExt, "dpo", rb_tulip_dpo, 2);
678
+ rb_define_module_function(rb_mTulirbExt, "dx", rb_tulip_dx, 2);
679
+ rb_define_module_function(rb_mTulirbExt, "edecay", rb_tulip_edecay, 2);
680
+ rb_define_module_function(rb_mTulirbExt, "ema", rb_tulip_ema, 2);
681
+ rb_define_module_function(rb_mTulirbExt, "emv", rb_tulip_emv, 2);
682
+ rb_define_module_function(rb_mTulirbExt, "exp", rb_tulip_exp, 2);
683
+ rb_define_module_function(rb_mTulirbExt, "fisher", rb_tulip_fisher, 2);
684
+ rb_define_module_function(rb_mTulirbExt, "floor", rb_tulip_floor, 2);
685
+ rb_define_module_function(rb_mTulirbExt, "fosc", rb_tulip_fosc, 2);
686
+ rb_define_module_function(rb_mTulirbExt, "hma", rb_tulip_hma, 2);
687
+ rb_define_module_function(rb_mTulirbExt, "kama", rb_tulip_kama, 2);
688
+ rb_define_module_function(rb_mTulirbExt, "kvo", rb_tulip_kvo, 2);
689
+ rb_define_module_function(rb_mTulirbExt, "lag", rb_tulip_lag, 2);
690
+ rb_define_module_function(rb_mTulirbExt, "linreg", rb_tulip_linreg, 2);
691
+ rb_define_module_function(rb_mTulirbExt, "linregintercept", rb_tulip_linregintercept, 2);
692
+ rb_define_module_function(rb_mTulirbExt, "linregslope", rb_tulip_linregslope, 2);
693
+ rb_define_module_function(rb_mTulirbExt, "ln", rb_tulip_ln, 2);
694
+ rb_define_module_function(rb_mTulirbExt, "log10", rb_tulip_log10, 2);
695
+ rb_define_module_function(rb_mTulirbExt, "macd", rb_tulip_macd, 2);
696
+ rb_define_module_function(rb_mTulirbExt, "marketfi", rb_tulip_marketfi, 2);
697
+ rb_define_module_function(rb_mTulirbExt, "mass", rb_tulip_mass, 2);
698
+ rb_define_module_function(rb_mTulirbExt, "max", rb_tulip_max, 2);
699
+ rb_define_module_function(rb_mTulirbExt, "md", rb_tulip_md, 2);
700
+ rb_define_module_function(rb_mTulirbExt, "medprice", rb_tulip_medprice, 2);
701
+ rb_define_module_function(rb_mTulirbExt, "mfi", rb_tulip_mfi, 2);
702
+ rb_define_module_function(rb_mTulirbExt, "min", rb_tulip_min, 2);
703
+ rb_define_module_function(rb_mTulirbExt, "mom", rb_tulip_mom, 2);
704
+ rb_define_module_function(rb_mTulirbExt, "msw", rb_tulip_msw, 2);
705
+ rb_define_module_function(rb_mTulirbExt, "mul", rb_tulip_mul, 2);
706
+ rb_define_module_function(rb_mTulirbExt, "natr", rb_tulip_natr, 2);
707
+ rb_define_module_function(rb_mTulirbExt, "nvi", rb_tulip_nvi, 2);
708
+ rb_define_module_function(rb_mTulirbExt, "obv", rb_tulip_obv, 2);
709
+ rb_define_module_function(rb_mTulirbExt, "ppo", rb_tulip_ppo, 2);
710
+ rb_define_module_function(rb_mTulirbExt, "psar", rb_tulip_psar, 2);
711
+ rb_define_module_function(rb_mTulirbExt, "pvi", rb_tulip_pvi, 2);
712
+ rb_define_module_function(rb_mTulirbExt, "qstick", rb_tulip_qstick, 2);
713
+ rb_define_module_function(rb_mTulirbExt, "roc", rb_tulip_roc, 2);
714
+ rb_define_module_function(rb_mTulirbExt, "rocr", rb_tulip_rocr, 2);
715
+ rb_define_module_function(rb_mTulirbExt, "round", rb_tulip_round, 2);
716
+ rb_define_module_function(rb_mTulirbExt, "rsi", rb_tulip_rsi, 2);
717
+ rb_define_module_function(rb_mTulirbExt, "sin", rb_tulip_sin, 2);
718
+ rb_define_module_function(rb_mTulirbExt, "sinh", rb_tulip_sinh, 2);
719
+ rb_define_module_function(rb_mTulirbExt, "sma", rb_tulip_sma, 2);
720
+ rb_define_module_function(rb_mTulirbExt, "sqrt", rb_tulip_sqrt, 2);
721
+ rb_define_module_function(rb_mTulirbExt, "stddev", rb_tulip_stddev, 2);
722
+ rb_define_module_function(rb_mTulirbExt, "stderr", rb_tulip_stderr, 2);
723
+ rb_define_module_function(rb_mTulirbExt, "stoch", rb_tulip_stoch, 2);
724
+ rb_define_module_function(rb_mTulirbExt, "stochrsi", rb_tulip_stochrsi, 2);
725
+ rb_define_module_function(rb_mTulirbExt, "sub", rb_tulip_sub, 2);
726
+ rb_define_module_function(rb_mTulirbExt, "sum", rb_tulip_sum, 2);
727
+ rb_define_module_function(rb_mTulirbExt, "tan", rb_tulip_tan, 2);
728
+ rb_define_module_function(rb_mTulirbExt, "tanh", rb_tulip_tanh, 2);
729
+ rb_define_module_function(rb_mTulirbExt, "tema", rb_tulip_tema, 2);
730
+ rb_define_module_function(rb_mTulirbExt, "todeg", rb_tulip_todeg, 2);
731
+ rb_define_module_function(rb_mTulirbExt, "torad", rb_tulip_torad, 2);
732
+ rb_define_module_function(rb_mTulirbExt, "tr", rb_tulip_tr, 2);
733
+ rb_define_module_function(rb_mTulirbExt, "trima", rb_tulip_trima, 2);
734
+ rb_define_module_function(rb_mTulirbExt, "trix", rb_tulip_trix, 2);
735
+ rb_define_module_function(rb_mTulirbExt, "trunc", rb_tulip_trunc, 2);
736
+ rb_define_module_function(rb_mTulirbExt, "tsf", rb_tulip_tsf, 2);
737
+ rb_define_module_function(rb_mTulirbExt, "typprice", rb_tulip_typprice, 2);
738
+ rb_define_module_function(rb_mTulirbExt, "ultosc", rb_tulip_ultosc, 2);
739
+ rb_define_module_function(rb_mTulirbExt, "var", rb_tulip_var, 2);
740
+ rb_define_module_function(rb_mTulirbExt, "vhf", rb_tulip_vhf, 2);
741
+ rb_define_module_function(rb_mTulirbExt, "vidya", rb_tulip_vidya, 2);
742
+ rb_define_module_function(rb_mTulirbExt, "volatility", rb_tulip_volatility, 2);
743
+ rb_define_module_function(rb_mTulirbExt, "vosc", rb_tulip_vosc, 2);
744
+ rb_define_module_function(rb_mTulirbExt, "vwma", rb_tulip_vwma, 2);
745
+ rb_define_module_function(rb_mTulirbExt, "wad", rb_tulip_wad, 2);
746
+ rb_define_module_function(rb_mTulirbExt, "wcprice", rb_tulip_wcprice, 2);
747
+ rb_define_module_function(rb_mTulirbExt, "wilders", rb_tulip_wilders, 2);
748
+ rb_define_module_function(rb_mTulirbExt, "willr", rb_tulip_willr, 2);
749
+ rb_define_module_function(rb_mTulirbExt, "wma", rb_tulip_wma, 2);
750
+ rb_define_module_function(rb_mTulirbExt, "zlema", rb_tulip_zlema, 2);
751
+ }