ta-lib is a collection of math/statistical function library for price
variability analysis written in C.
There is no port availiable for it in ruby.
Since i badly needed one … so i started researching on.
I went along the pickaxe book.
since there are about 120 odd functions to port … I was thinking to
embark upon the SWIG.
I read along the SWIG docs and ruby mailing list for hints but
somehow could not zero upon how to kick start.
one of the function header looks like this
TA_RetCode TA_MA( int startIdx,
int endIdx,
const double inReal[],
int optInTimePeriod,
int optInMAType,
int *outBegIdx,
int *outNbElement,
double outReal[],
)
this is called from c in this way
=======================
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] );
given this I was wondering If I would need to write some typemaps for
SWIG or the typemap.i inclusion will be sufficient?
Specifically…
In the C function above the <const double inReal[]> argument is
passed as &closePrice[0] … In ruby i won’t be able to do that… I
will have to pass in an array containing… double… how do i do that
using typemap?
==============
Cheers
Rajib