systematicinvestor / SIT

Systematic Investor Toolkit
483 stars 382 forks source link

Compatibility of the fast alternative of index.xts #2

Closed yinhm closed 12 years ago

yinhm commented 12 years ago

Hi,

I try to using SIT with other packages as well, unfortunately it breaks my exists code due to compatibility of the fast alternative of index.xts.

Error in `[.xts`(data, timestamp) : subscript out of bounds
In addition: Warning messages:

Removing the following function everything works smoothly.

###############################################################################
# Fast alternative to index(x) for XTS object
###############################################################################
index.xts <- function
(
    x           # XTS object
)
{
    temp = attr(x, 'index')
    class(temp)='POSIXct' 

    if( attr(x, '.indexCLASS')[1] == 'Date') {  
        as.Date(temp)
    } else {
        as.POSIXct(temp, tz = Sys.getenv('TZ'))
    }
}
systematicinvestor commented 12 years ago

Please provide a concrete code example, so I can have a look at this issue.

yinhm commented 12 years ago

Sorry I don't have a standalone reproducible example now.

I'm calling R from Python bridged by rpy2, my quotes data feeded from Python to quantstrat for backtesting.

I'm intended to open source it later since it still in heavy development stage also I'm new to R.

Maybe I could do a reproducible example latter.

systematicinvestor commented 12 years ago

Let me know when you have an example