MovingAverage / system-backtest-project

Backtest result of projects
0 stars 0 forks source link

import forex data not working #1

Open MovingAverage opened 7 years ago

MovingAverage commented 7 years ago

?POSIXct could fix import of CSV forex data

as.POSIXct("150721 17:12", format = "%y%m%d %H:%M") https://finbloggers.wordpress.com/2015/11/29/some-basic-informationand-conventions/ @

MovingAverage commented 7 years ago

Possible fix:

source data: http://www.forextester.com/data/datasources

# Function used in read.zoo to combine two fields
f <- function(a, b) {
  c <- paste(a, b)
  return(strptime(c, format = "%Y%m%d %H%M%S"))
}

# read the data from .cvs files and convert it to the xts format
data <- xts(read.zoo(file=paste(thePath,"EURUSD.txt",sep=""), 
                     header=TRUE, 
                     sep=",", 
                     tz = '',
                     col.names = c('Ticker','DTYYYYMMDD','TIME','OPEN','HIGH','LOW','CLOSE','VOL'),
                     FUN = f, 
                     index.column = list("DTYYYYMMDD", "TIME")
                     )
            )
head(data)
to.hourly(data)