[R-SIG-Finance] Read some data from TradeStation to display using barChart

Mark Knecht markknecht at gmail.com
Tue Oct 2 21:13:35 CEST 2012


Hi,
   I haven't done any R programming in maybe 2 years but I got
interested recently in looking at something and quantmod seems like it
would be good for a basic start. As a first step I'm trying to get
some price data saved in a running strategy on TradeStation into a
barChart using quantmod.

   The following code seems to read my data file successfully and
produces reasonable looking (to me anyway) data.  I think I need to
convert the data to xts to get barChart to work but I cannot quite get
there. Is there a straightforward way to do this? Maybe the date
format isn't right for use with xts?

   Can someone point out how to do this?

Thanks in advance,
Mark


require(reshape)
require(TTR)
require(ggplot2)
require(chron)
require(quantmod)

### Requires MWKFunctions.R be loaded first
source("C:/Documents and Settings/Mark/My
Documents/R/MWKFunctions/MWKFunctions.R")

SystemTable = read.table("C:\\Test1.csv",sep=",",header=TRUE)
SystemTable[,1] = TStoDate(SystemTable[,1])
typeof(SystemTable)

SystemTable[1:4,1:7]

SystemXTS = as.xts(SystemTable[,1:7])

barChart(SystemTable)



<SNIP>
>
> ### Requires MWKFunctions.R be loaded first
> source("C:/Documents and Settings/Mark/My Documents/R/MWKFunctions/MWKFunctions.R")
>
> SystemTable = read.table("C:\\Test1.csv",sep=",",header=TRUE)
> SystemTable[,1] = TStoDate(SystemTable[,1])
> typeof(SystemTable)
[1] "list"
>
> SystemTable[1:4,1:7]
        Date Time   Open    High     Low   Close Volume
1 2011-09-20 2225 1175.5 1176.00 1174.25 1174.50    102
2 2011-09-20 2230 1174.5 1175.50 1174.25 1175.25    267
3 2011-09-20 2235 1175.5 1175.75 1174.00 1175.00    248
4 2011-09-20 2240 1175.0 1175.50 1175.00 1175.25    135
>
> SystemXTS = as.xts(SystemTable[,1:7])
Error in as.POSIXlt.character(x, tz, ...) :
  character string is not in a standard unambiguous format
>
> barChart(SystemTable)
Error in try.xts(x, error = "chartSeries requires an xtsible object") :
  chartSeries requires an xtsible object
>



More information about the R-SIG-Finance mailing list