Forum: Ruby extending ta-lib using SWIG

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7785f254d50e146127c2fed102c63443?d=identicon&s=25 BENI (Guest)
on 2007-03-13 09:25
(Received via mailing list)
ta-lib ( 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,
&outBeg, &outNbElement, &out[0] );

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

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

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;


This topic is locked and can not be replied to.