# Ta-lib port for ruby using swig

**URL:** <https://www.ruby-forum.com/t/ta-lib-port-for-ruby-using-swig/88671>\
**Category:** Ruby\
**Created:** [March 13, 2007, 1:31pm UTC](https://www.ruby-forum.com/t/ta-lib-port-for-ruby-using-swig/88671 "2007-03-13T13:31:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BENI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BENI](https://www.ruby-forum.com/u/BENI)\
**Post date:** [March 13, 2007, 1:31pm UTC](https://www.ruby-forum.com/t/ta-lib-port-for-ruby-using-swig/88671/1 "2007-03-13T13:31:05Z")

</div>

I was trying to SWIG onto the ta-lib .

the ta-lib is a collection of c functions for financial data analysis.

[Account Suspended](http://ta-lib.org/d_api/d_api.html).

I was trying with one function.

the header

TA\_RetCode TA\_MA( int startIdx,  
int endIdx,  
const double inReal[],  
int optInTimePeriod,  
int optInMAType,  
int \*outBegIdx,  
int \*outNbElement,  
double outReal[],  
)

the c call:  
Lets say you wish to calculate a 30 day moving average using closing  
prices. The function call could look as follow:

TA\_Real closePrice[400];  
TA\_Real out[400];  
TA\_Integer outBeg;  
TA\_Integer outNbElement;

/\* … initialize your closing price here… \*/

retCode = TA\_MA( 0, 399,  
&closePrice[0],  
30,TA\_MAType\_SMA,  
&outBeg, &outNbElement, &out[0] );

/\* The output is displayed here \*/  
for( i=0; i \< outNbElement; i++ )  
printf( “Day %d = %f\n”, outBeg+i, out[i] );

============

i was wondering how the typemap for the arguments in swig will look  
like.

```
             1>const double inReal[],
              2> int optInMAType,
             3> int *outBegIdx,
             4> int *outNbElement,
             5> double outReal[],

```

Any lead will be very helpful.

btw. i have all the docs rltd to swig and the pickaxe as well.

regards
