Hi Kapil,

Install two packages. xts and quantmod.

xts is very good package for time series analysis in general.
quantmod has very good timeseries charting capabilities.

There are plenty of examples for both in their help pages.

-Chinmay


On Mon, Mar 3, 2014 at 11:26 PM, Kapil Shukla <[email protected]>wrote:

> Thanks Mark for such a quick reply. I follow the following steps
>
> 1. hourly_bid <- read.table("ech14_hourly_bid.csv", header=TRUE, sep=",",
> stringsAsFactors =FALSE)
> 2.  This is how top 10 rows of my data look like.
>
>
>              Date   OPEN   HIGH    LOW LAST_PRICE NUMBER_TICKS VOLUME
>   VALUE1   7/29/2013 7:00 1.3292 1.3296 1.3288     1.3288           23
>     46  61.1444
> 2   7/29/2013 8:00 1.3286 1.3293 1.3284     1.3293           21     42
>  55.8108
> 3   7/29/2013 9:00 1.3294 1.3297 1.3292     1.3293            6     12
>  15.9534
> 4  7/29/2013 10:00 1.3294 1.3295 1.3294     1.3295            2      4
> 5.3178
> 5  7/29/2013 11:00 1.3290 1.3293 1.3288     1.3291            8     16
>  21.2648
> 6  7/29/2013 12:00 1.3286 1.3289 1.3278     1.3283           13     26
>  34.5364
> 7  7/29/2013 13:00 1.3284 1.3285 1.3280     1.3285            8     16
>  21.2528
> 8  7/29/2013 14:00 1.3280 1.3285 1.3267     1.3270           34     68
>  90.2860
> 9  7/29/2013 15:00 1.3271 1.3282 1.3265     1.3276           63    126
> 167.2468
> 10 7/29/2013 16:00 1.3271 1.3298 1.3271     1.3290          132    352
> 467.7688
>
>
> 3. Structure of my data is as follow
>
>
> 'data.frame':   10 obs. of  8 variables:
>  $ Date        : chr  "7/29/2013 7:00" "7/29/2013 8:00" "7/29/2013
> 9:00" "7/29/2013 10:00" ...
>  $ OPEN        : num  1.33 1.33 1.33 1.33 1.33 ...
>  $ HIGH        : num  1.33 1.33 1.33 1.33 1.33 ...
>  $ LOW         : num  1.33 1.33 1.33 1.33 1.33 ...
>  $ LAST_PRICE  : num  1.33 1.33 1.33 1.33 1.33 ...
>  $ NUMBER_TICKS: int  23 21 6 2 8 13 8 34 63 132
>  $ VOLUME      : int  46 42 12 4 16 26 16 68 126 352
>  $ VALUE       : num  61.14 55.81 15.95 5.32 21.26 ...
>
> 3. When i try to plot the date vs the high i get the below error
> message. I guess its due to fact that R is not able to guess the X
> asis points plot
>
> plot(a$Date, a$HIGH, type="b")Error in plot.window(...) : need finite
> 'xlim' values
>
>
> 4. Now when i try to convert Date using strptime(a$Date, format =
> "%m/%d/%Y %H:%M" my data frame shows correct structure but i still get
> the same error in plotting. Should i use any specific function to plot
> and what if i want to make candle stick chart from the data i have?
>
>
>
> Hope i was able to explain myself.
>
> Thanks
>
>
>
> On Mon, Mar 3, 2014 at 11:15 PM, Mark Knecht <[email protected]> wrote:
>
> > On Mon, Mar 3, 2014 at 7:04 AM, Kapil Shukla <[email protected]>
> > wrote:
> > > Hi All
> > >
> > > I am totally new to R so this question may sound basic to many of you.
> I
> > am
> > > trying to use R for time series analysis of some financial instruments.
> > > Currently i have hourly data of a stock which has OPEN/HIGH/LOW/CLOSE
> in
> > a
> > > CSV file. I used read.table to import the data in R in to a dataframe
> > but i
> > > am following below issues:
> > >
> > > 1. Date is coming in character format and i am not sure whats the best
> > > package of function to format the date in "DD/MM/YY HH:MM" format
> > > 2. When i plot the data using PLOT() data points are so overlapping on
> > the
> > > chart that its hard to identify the data points. I am not able to
> specify
> > > XLIM parameter as my dates are in character. I tried using the C()
> > function
> > > to provide the first hour and last hour of the data but it won't accept
> > it.
> > > Is there any better package for plotting time series data.
> > > 3. Any package which can help me plot the candle stick chart for this
> > OHLC
> > > data and help me do some statistical analysis on the data.
> > >
> > > Thanks in Advance.
> > >
> > > Regards
> > > Kapil
> >
> >
> > Kapil,
> >    Welcome to R.
> >
> >    You will do better here if you provide a reproducible example. Read
> > your data in and then segment a little piece using dput to show what
> > it looks like. Build an example that uses maybe 10 lines of data. Post
> > the code. From there's it's likely an issue of better defining for R
> > how to handle data/time. Look at the xts package for more info and
> > post real R code showing what you are doing so others can help.
> >
> >    Also, there are examples of doing this sort of thing in Stack
> > Overflow so possibly spend some time there.
> >
> > - Mark
> >
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- 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.
>

        [[alternative HTML version deleted]]

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- 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.

Reply via email to