fTrading bug

chalabi at phys.ethz.ch chalabi at phys.ethz.ch
Wed Mar 5 15:27:06 CET 2008


Adam Murphy <ammurphy at yahoo.com> writes:

> Diethelm et al,
>
> Hi, I have been using fairly regulary a number of packages in the rmetrics group--most recently both fImport and fTrading.  I noticed a bug in one of the functions in the fTrading package.  The function cdoTA() is defined as below:
>
>   
>> cdoTA
> function (x, lag1 = 12, lag2 = 26, lag3 = 9) 
> {
>     cdo = macdTA(x, lag1, lag2) - cdsTA(x, lag3)
>     if (is.timeSeries(x)) 
>         colnames(cdo) <- "CDO"
>     cdo
> }
>
> The problem occurs when it calls cdsTA, which is defined as below:
>
>  
>> cdsTA
> function (x, lag1 = 12, lag2 = 26, lag3 = 9) 
> {
>     cds = emaTA(macdTA(x, lag1, lag2), lag3)
>     if (is.timeSeries(x)) 
>         colnames(cds) <- "CDS"
>     cds
> }
>
> cdsTA is expecting a vector and three lag terms.  cdoTA feeds a vector and only one lag term, lag3.  However, cdsTA is expecting lag1 to be the first term.  Thus whatever cdoTA thinks lag3 is, cdsTA is treating it as if it's actually lag1.  This all seems a bit wordy, I know.  However, if you replace the blue text above with:
>
> cdo = macdTA(x, lag1, lag2) - cdsTA(x, lag3=lag3)
>
> That should clear up the assignment problems.
>
> Best Regards,
> Adam Murphy
>
>
>
>  
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Rmetrics-core mailing list
> Rmetrics-core at r-project.org
> https://stat.ethz.ch/mailman/listinfo/rmetrics-core


Hi Adam,

Thanks for your helpful feedback,

I made the changes to the code.

regards,
Yohan

-- 


The 2nd International R/Rmetrics User and Developer Workshop ...
[http://www.rmetrics.org]



More information about the Rmetrics-core mailing list