extending ta-lib using SWIG

B

BENI

ta-lib (http://ta-lib.org/) is a package availiable which has port for
perl,python?,excel etc.

I needed it in ruby... since no port is availiable (AFAIK) ... i
thought of building a port.

i have read along the pickaxe book of extending ruby....

after evaluating all the options i thought i will give SWIG a shot...

given the header like

=================================================
TA_RetCode TA_MA( int START_IDX,
int END_IDX,
const double *IN_ARRAY /* inReal */,
int OPT_INT /* optInTimePeriod */, /* From
1 to 100000 */
TA_MAType OPT_MATYPE /* optInMAType */,
int *BEG_IDX,
int *OUT_SIZE,
double *OUT_ARRAY /* outReal */ );
==================================================

in C it can be called like
=====================
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 );

=======================
*********************************************
could any one give me a lead how should the typemap for *IN_ARRAY look
like?

for python the typemap for *IN_ARRAY looks like
=====================================
%typemap(in) const double *IN_ARRAY
{
int array_size = endIdx2 + 1;

$1 = ($1_ltype) calloc(array_size, sizeof($*1_ltype));
if (!convert_darray($input, $1, array_size)) goto fail;
}
=======================================

cheers

Rajib
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top