[R-SIG-Finance] Extracting OHLC from trade price series
Jeff Ryan
jeff.a.ryan at gmail.com
Wed Feb 20 17:46:53 CET 2008
I wanted to clarify my comment with respect to timeDate:
>
> The GMT issue has been discussed here many times over - try
> Sys.setenv(TZ='GMT') for starters. You are probably better off _not_
> using timeDate - but I wrote xts so I wouldn't have to - to each his
> own.
>
>
The 'timeDate' class itself is quite worthwhile. There are many
methods that seem to be available that can make life easier. My point
was more to the task at hand. Simply subsetting an existing series,
or aggregating to a lower periodicity doesn't require much beyond
knowing time-stamps.
If time-stamps are needed - POSIXct, Date, and chron are all up to the
task. It is entirely possible that 'timeDate' is equally useful, but
my thinking is always to start simple and them progress to the more
complicated only if necessary.
For what it's worth, 'xts' can also handle indexing by 'timeDate'.
See ?indexClass
I'd love to hear a bit from the Rmetrics developers regarding the
merits of 'timeDate'. A comparison table of the different time/date
classes would be very beneficial to many I suspect. I'd be more than
willing to try and put one together.
Jeff
On Tue, Feb 19, 2008 at 6:39 PM, Jeff Ryan <jeff.a.ryan at gmail.com> wrote:
> Hi,
>
> The package 'xts' (the function in question previously part of
> 'quantmod') has a nice and fast aggregation function that allows you
> to create OHLC from any univariate series, or from an existing OHLC
> series - called 'to.period'.
>
> library(quantmod)
> getSymbols("QQQQ")
>
> to.monthly(QQQQ) # yields a monthly series from daily data
>
> The code works equally well for anything from minute bars on up. It
> should work below that, though I can't promise anything as I haven't
> really tested that recently. Other functions in the group are
> to.minutes, to.hourly, to to.daily... you get the idea.
>
> to.period is the function you want to look at. It calls Fortran - so
> it is very fast on all but gigantic data sets - and then nothing is :)
>
>
> The GMT issue has been discussed here many times over - try
> Sys.setenv(TZ='GMT') for starters. You are probably better off _not_
> using timeDate - but I wrote xts so I wouldn't have to - to each his
> own.
>
>
> As for the last question... I am not too sure if I understand it
> correctly. As long as you subset the data before hand 'to.period'
> shouldn't care about your index dates/times.
>
> 'xts' also allows for easier subsetting by date:
>
> as.xts(myts)['2007-01-01::2007-01-23']
>
> The help with regard to the latter is not all there yet - so feel free
> to contact me with specific questions.
>
> Jeff
>
>
>
>
> On Feb 19, 2008 6:22 PM, <adschai at optonline.net> wrote:
> > Hi - I have a trade price series whose file is really big. My first question is, is there any existing routine in R to extract OHLC (Open-High-Low-Close) of specified interval from irregular trade price series?
> >
> > My second question is from my attempt to do this. The logic is not difficult but I am not familiar with fCalendar package especially timeDate object.
> >
> > First of all, I do:
> >
> > timeDate('2007-11-01',zone='GMT'); # I expect '2007-11-01 00:00:00 GMT'
> >
> > The result sometimes show '2007-11-01 GMT' or '2007-10-31 18:00:00 Central standard time'. My question is how do I specify display format, says in 'EST' consistently? Note that my machine time locale is CST.
> >
> > Third question, I try to generate a sequence of OHLC bar given a user input date. For example, I am interested in extracting OHLC from 6:00:00 EST to 14:30:00 EST on every weekday. How can I do that?
> >
> > Thank you,
> >
> > - adschai
> >
> > _______________________________________________
> > 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.
> >
>
>
>
> --
> There's a way to do it better - find it.
> Thomas A. Edison
>
--
There's a way to do it better - find it.
Thomas A. Edison
More information about the R-SIG-Finance
mailing list