[R-SIG-Finance] data manipulation to for quantmod function

Brian G. Peterson brian at braverock.com
Wed Jan 11 16:10:57 CET 2012

On Wed, 2012-01-11 at 09:49 -0500, R. Michael Weylandt wrote:
> If you have tick/high(-ish) frequency data, you'll have to 
> transform it to OHLC; there's no way to keep the frequency 
> you have and to make an OHLC object out of it, since those 
> metrics are by definition aggregates. The easiest way to 
> do so is to read it in as an xts object then use one of the to.period() functions. 

Whoa.  Not (Completely) True.

getSymbols, xts, and quantmod are perfectly comfortable with tick data
of millions and even billions of rows.

chart_Series and chartSeries have built-in charting mechanisms for OHLC
data, and you may wish to transform higher freqency data to lower
frequency OHLC before charting, but this is by no means required.

Some indicator/TA methods also require OHLC data or equivalent, but many
will work fine on univariate series or on tick.

To the original poster's question, I usually use read.table or read.csv
and then as.xts to convert to an xts object.  How to do these steps has
been covered many times on this list, so please search the archives.

With the linked csv file in the original poster's messages,
see ?strftime and the list archives for information on formatting.


   - Brian

Brian G. Peterson
Ph: 773-459-4973
IM: bgpbraverock

> On Jan 11, 2012, at 4:22 AM, julien cuisinier <j_cuisinier at hotmail.com> wrote:
> > 
> > Hi,
> > 
> > 
> > Always nice to have a name on those email. 
> > 
> > quantmod "format" is xts format, you might try as.xts but i guess you will need to give it all the needed columns to fit the XTS object
> > 
> > OR use quantmod getSymbols function to download the data straight into the right format if possible
> > 
> > 
> > HTH,
> > Julien
> > 
> > 
> > 
> >> From: ktdservices01 at gmail.com
> >> To: r-sig-finance at r-project.org
> >> Date: Tue, 10 Jan 2012 22:30:33 -0600
> >> Subject: [R-SIG-Finance] data manipulation to for quantmod function
> >> 
> >> I need some help with data manipulation so I can use quantmod.
> >> 
> >> I have a data frame with three columns: time, price, volume.  This  
> >> data frame is all the trades of a product for about 15 days.  What I  
> >> want to do is modify the data so that it is in a format that quantmod  
> >> can read.  Quantmod needs data to be in columns: Open, High, Low,  
> >> Close, and Volume.
> >> 
> >> I wanted to see if anyone had some suggestions to easily modify the  
> >> data into the quantmod format.
> >> 
> >> Quantmod: http://www.quantmod.com/
> >> Data (.csv, 21.67KB) can be downloaded at http://www.mediafire.com/?fyunce685ekuyo3
> >>    [[alternative HTML version deleted]]

More information about the R-SIG-Finance mailing list