[R-SIG-Finance] Read some data from TradeStation to display using barChart
R. Michael Weylandt
michael.weylandt at gmail.com
Tue Oct 2 22:09:31 CEST 2012
On Tue, Oct 2, 2012 at 8:13 PM, Mark Knecht <markknecht at gmail.com> wrote:
> 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,
> ### Requires MWKFunctions.R be loaded first
> source("C:/Documents and Settings/Mark/My
We don't have any of these functions, so we can't actually debug your
code. If you want real help, try whipping up a reproducible example:
> SystemTable = read.table("C:\\Test1.csv",sep=",",header=TRUE)
> SystemTable[,1] = TStoDate(SystemTable[,1])
> SystemXTS = as.xts(SystemTable[,1:7])
What does SystemTable wind up looking like? You might need to do
something like this instead:
SystemXTS <- xts(SystemTable[,2:7], as.POSIXct(SystemTable[,1], format
where you put in the appropriate format string for as.POSIXct(). See
?strptime for the details.
What might also be easier is simply:
SystemXTS <- as.xts(read.zoo("C:\\Test1.csv"))
>> ### 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])
>  "list"
> 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
> Error in try.xts(x, error = "chartSeries requires an xtsible object") :
> chartSeries requires an xtsible object
> R-SIG-Finance at r-project.org mailing list
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
More information about the R-SIG-Finance