[R-SIG-Finance] Time Series For ohlcPlot

Jeff Ryan jeff.a.ryan at gmail.com
Sun Dec 6 03:16:23 CET 2009


Hi Nick,

A more flexible visualization of OHLC data is available in quantmod.

See:

http://www.quantmod.com/examples/charting/

Assuming a data.frame you can do something like:

x <- xts(table[,-1], order.by=as.POSIXct(table[,1]))

Then:

barChart(x) OR
chartSeries(x)

HTH
Jeff

On Sat, Dec 5, 2009 at 7:10 PM, Nick Torenvliet
<n_torenvliet at hotmail.com> wrote:
>
> Hi,
>
> I've got daily historical ohlc data in a MySQL db.
>
> I can get the data into R and manage to get a data.frame that looks like this
>
>> table
>    Date                            Open   High  Low     Close
> 1  2009-12-04 00:00:00   62.38   63.37  61.53    62.06
> 2  2009-12-03 00:00:00   63.00   63.00  61.51    61.53
> 3  2009-12-02 00:00:00   62.73   64.18  62.45    62.88
> 4  2009-12-01 00:00:00   61.37   63.05  61.12    62.61
> 5  2009-11-30 00:00:00   61.50   62.93  60.92    60.97
> 6  2009-11-27 00:00:00   61.80   62.58  61.40    61.45
> 7  2009-11-26 00:00:00   62.34   62.39  61.51    61.60
> 8  2009-11-25 00:00:00   62.70   63.15  62.42    62.52
> 9  2009-11-24 00:00:00   63.31   63.43  62.69    62.98
> 10 2009-11-23 00:00:00   64.10   64.88  63.10    63.47
> 11 2009-11-20 00:00:00   62.05   64.25  61.90    63.66
> 12 2009-11-19 00:00:00   63.00   63.22  61.88    62.71
> 13 2009-11-18 00:00:00   64.01   64.01  62.52    63.25
> 14 2009-11-17 00:00:00   64.57   66.00  64.22    64.53
> 15 2009-11-16 00:00:00   66.27   66.27  63.69    64.25
> 16 2009-11-13 00:00:00   66.57   66.57  65.13    65.95
> 17 2009-11-12 00:00:00   67.79   68.13  66.22    66.63
> 18 2009-11-11 00:00:00   67.73   68.00  66.82    67.78
> 19 2009-11-10 00:00:00   65.10   67.98  65.10    66.80
> 20 2009-11-09 00:00:00   62.77   65.30  62.11    65.06
> 21 2009-11-06 00:00:00   61.54   63.30  60.59    63.20
> 22 2009-11-05 00:00:00   62.93   63.39  61.00    61.65
> 23 2009-11-04 00:00:00   64.30   64.30  61.14    61.39
> 24 2009-11-03 00:00:00   59.83   64.14  59.79    63.89
> 25 2009-11-02 00:00:00   61.52   61.52  58.64    60.15
>
> That was this morning, I've been struggling all day with time series concepts...
>
> Two Questions...
>
> 1/ How can get table into a time series object (usable with ohlcPlot)?
>
> Nick
>
>
>
>
>        [[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