[R-SIG-Finance] Date format for quantmod SQLite tables

Jeff Ryan jeff.a.ryan at gmail.com
Fri Aug 28 04:58:10 CEST 2009


Hi Sean,

The wrapper in quantmod is mostly a 'how you might use' function.

That said, without any modification to the getSymbols.SQLite function,
you would need the row_names to be text representations of numeric
time, either POSIXct or Date.

> as.numeric(Sys.Date())
[1] 14483
> as.numeric(Sys.time())
[1] 1251428145

As this gets converted via:

if (POSIX) {
            d <- as.numeric(fr[, 1])
            class(d) <- c("POSIXt", "POSIXct")
            fr <- xts(fr[, -1], order.by = d)
        }
        else {
            fr <- xts(fr[, -1], order.by = as.Date(as.numeric(fr[,
                1]), origin = "1970-01-01"))
        }

where POSIX=TRUE by default.

You could of course change the function to reflect your actual table
construction, and get rid of the as.numeric conversion, instead
calling as.Date or as.POSIXct directly.

HTH
Jeff


On Thu, Aug 27, 2009 at 9:30 PM, Sean Carmody<seancarmody at gmail.com> wrote:
> I am trying to use quantmod with src="SQLite". I have looked at the
> documentation for getSymbols.sqlite and feel I am getting close. For each
> symbol, I have a SQLite table with the fields
>
> row_names TEXT
> Open NUMERIC
> High NUMERIC
> Low NUMERIC
> Close NUMERIC
> Volume NUMERIC
> Adjusted NUMERIC
>
> When I use getSymbols I get a warning sayig "NAs introduced by coercion".
> The data seems to have been loaded, except for the row names (zoo index),
> which are all NA. At the moment, the contents of my row_names field are text
> strings with the format YYYY-MM-DD. Is it simply a matter of changing the
> format of these strings, or is there something else I have to do to get this
> working?
>
> Regards,
> Sean.
>
> --
> Sean Carmody
>
> The Stubborn Mule
> http://www.stubbornmule.net
> http://twitter.com/seancarmody
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



-- 
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com



More information about the R-SIG-Finance mailing list