

Sendt fra min HTC

----- Reply message -----
Fra: r-sig-finance-request@r-project.org
Til: <r-sig-finance@r-project.org>
Emne: R-SIG-Finance Digest, Vol 88, Issue 28
Dato: tor., sep. 29, 2011 12:00


Send R-SIG-Finance mailing list submissions to
	r-sig-finance@r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
	https://stat.ethz.ch/mailman/listinfo/r-sig-finance
or, via email, send a message with subject or body 'help' to
	r-sig-finance-request@r-project.org

You can reach the person managing the list at
	r-sig-finance-owner@r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-SIG-Finance digest..."


Today's Topics:

   1. Re: Stock Model Question! (Brian G. Peterson)
   2. Re: RBloomberg connection options - Email found in subject
      (David Reiner)
   3. Re: Seasonal Dummy Variables in VECM (tsDyn) (Matthieu Stigler)
   4. Displaying candle data for thinly traded stocks (Stefan Petry)
   5. Re: Displaying candle data for thinly traded stocks (G See)
   6. Re: Displaying candle data for thinly traded stocks (Jeffrey Ryan)
   7. Re: Weird problem with latest RQuantLib not working with
      QuantMod on R 2.13.1 (Dirk Eddelbuettel)
   8. Re: Weird problem with latest RQuantLib not working with
      QuantMod on R 2.13.1 (Jeffrey Ryan)
   9. Re: Weird problem with latest RQuantLib not working with
      QuantMod on R 2.13.1 (Dirk Eddelbuettel)
  10. extract a particular hour of tick data from	multiple days
      form xts object (Muhammad Abuizzah)
  11. Re: extract a particular hour of tick data from multiple days
      form xts object (Brian G. Peterson)
  12. Re: Open to Close to Open data transformation (quantmod, xts
      and possibly zoo) + chart.TimeSeries (Costas Vorlow)


----------------------------------------------------------------------

Message: 1
Date: Wed, 28 Sep 2011 05:02:20 -0500
From: "Brian G. Peterson" <brian@braverock.com>
To: Anna Dunietz <anna.dunietz@gmail.com>
Cc: r-sig-finance@r-project.org
Subject: Re: [R-SIG-Finance] Stock Model Question!
Message-ID: <1317204140.4192.270.camel@brian-desktop>
Content-Type: text/plain; charset="UTF-8"

On Wed, 2011-09-28 at 11:25 +0200, Anna Dunietz wrote:
> 
> I am interested in plotting my portfolio's performance and don't
> exactly know how to do it.  I have built a (not-so-great) model - the
> data below is found below.  I used information on each individual S&P
> 500 stock over the past ~10 years (RSI, moving averages, price
> changes, and price).  Selling the stock occurs when a stop loss or
> take profit is signaled.  The model was built without using the
> blotter or quantstrat packages - it was built with a which function.
> The code is quite long. However, if you think it will be helpful, I
> can always attach it.  I would like inital equity to be $100000,
> and I would like to invest $25000 per buy signal.  I hope this is
> clear enough.  If not, please let me know!
> 
> Thanks!
> Anna
> 
> 
>        BuyDate         Equity BuyPrice Action   SellDate SellPrice
> PerformancePerc.
> 51  2001-07-02  FCX.UN.Equity   5.3600   LONG 2001-07-11    5.9450
>   0.10914179
> 122 2001-07-02  TIE.UN.Equity   2.2875   LONG 2001-07-17    2.6050
>   0.13879781
> 82  2001-07-13    L.UN.Equity  19.2867   LONG 2001-07-20   18.2667
>  -0.05288619 
<...>

Anna,

Of course posting a reproducible example *always* helps.

You have all the data to create a bar chart of returns for each of your
investments, but not a time series of returns. I'll assume you're
looking for a time series chart, for which you must construct a time
series.

To use any of the open source package tools (in R or any other
language!) for backtesting investment models, you'll need either a list
of transactions, or a set of periodic returns.

It seems that you are close to generating this from your code, but
you've munged everything together on one line.  Your output is a nice
summary of actions and results, but insufficient for charting.

It's nice that your summary table includes 'PerformancePerc', and you
could of course use that to generate a total performance if those are
log returns (which would be additive), but your data does not have
enough information to construct a time series of returns from.

You have a few options, which may be easier or harder based on your
other code which you have not shared:

- subset your input asset return time series for times when you are in
the market with each of your instruments, (invert if short), turn each
of those subsets into log returns if they aren't already, apply weights
if necessary, cbind, add each row for portfolio return, and plot your
portfolio return column using charts.PerformanceSummary or similar.

- extract your transactions into a time series by asset.  Feed those
transactions into blotter or equivalent.  If using blotter, use
extractReturns to get your returns out, and use
charts.PerformanceSummary to or equivalent to chart.

- probably least appealing, rewrite your model using one of the packages
 
The key is that to chart your returns, you need the time series with
returns at each point in time, not just the summary output.  Given the
data you've posted, I can't unmix your mixture.  The good news is that
you probably still have all the components in your code, you'll just
need to add some of them to your output.

I'll note that the reason we/I wrote all these packages was to eliminate
most of the issues I ran into every time I wrote a custom one-off model,
because all those standard bits would be done, and I wouldn't have to
redo or adapt custom code each time.  Every model has custom code, of
course, but the idea was to maximise reuse of the common bits and focus
coding on the bits that are specific to one model, to the degree
possible. Of course, you give up something in return, often speed of
execution (though blotter/quantstrat can be very fast, your which
statement could be faster), or some degreee of flexibility.

You indicated that your code is 'quite long'.  It seems likely that your
indicators, signals, and rules for a(ny) model using "RSI, moving
averages, price changes, and price" could be recast in far less code
using quantstrat, though that of course is not necessary, and I trust my
pointers above will point you in the right direction.

Regards,

   - Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



------------------------------

Message: 2
Date: Wed, 28 Sep 2011 10:57:31 -0500
From: David Reiner <David.Reiner@xrtrading.com>
To: John Laing <john.laing@gmail.com>
Cc: "r-sig-finance@r-project.org" <r-sig-finance@r-project.org>
Subject: Re: [R-SIG-Finance] RBloomberg connection options - Email
	found in subject
Message-ID: <9DE405308A6AA24AA794B76282C6C00F0A069BF1E5@HQ-POST1>
Content-Type: text/plain; charset="iso-8859-1"

Thanks for the response, John.
I tried this:
> tick(conn, "ESA Index", c("BID", "ASK"), "2011-09-28 10:00:00.000", "2011-09-28 10:00:01.000", option_names="useUTCTime",option_values="FALSE")
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  com.bloomberglp.blpapi.NotFoundException: Element Defintion: useUTCTime not found in: IntradayTickRequest

I guess I will have to always remember to shift my times to/from UTC or write a wrapper.
I'm not sure it is supported for intraday tick requests; on WAPI<go> under the API development topics #5,
they seem to indicate that it should work for at least VWAPs, but it's a little hard to know if it applies to others.

Thanks for all your good work on this package!
-- David

> sessionInfo()
R version 2.13.1 Patched (2011-08-17 r56745)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] zoo_1.7-3          RBloomberg_0.4-150 rJava_0.9-1       

loaded via a namespace (and not attached):
[1] grid_2.13.1     lattice_0.19-31

-----Original Message-----
From: John Laing [mailto:john.laing@gmail.com] 
Sent: Tuesday, September 27, 2011 9:19 PM
To: David Reiner
Cc: r-sig-finance@r-project.org
Subject:  Re: [R-SIG-Finance] RBloomberg connection options

David,

These options in the RBloomberg package correspond directly to options that Bloomberg exposes through the API. I haven't been able to come up with any cases where the options do interesting things, but they would be set through a bdp (or similar) call like this:

bdp(conn, "GOOG Equity", "PX_LAST", option_names = "includeExchangeCodes", option_values = "TRUE")

Sorry if that's not especially helpful... If I come up with a better example I'll be sure to let you know.

John

On Thu, Sep 22, 2011 at 10:22 AM, David Reiner <David.Reiner@xrtrading.com> wrote:
> Thanks to Ana and John for this great package!
>
> I am intrigued by the options shown in one example, but clueless as to how to take advantage of them.
> How do we set useUTCTime to FALSE ?
> Here's the example that shows there is such an option:
>
>> library(RBloomberg)
>> conn <- blpConnect()
>> conn$BOOLEAN_OPTION_NAMES
> ?[1] "useUTCTime" ? ? ? ? ? ? ? ?"returnRelativeDate" ? ? ? ?"adjustmentNormal" ? ? ? ? ?"adjustmentAbnormal"
> ?[5] "adjustmentSplit" ? ? ? ? ? "adjustmentFollowDPDF" ? ? ?"returnEids" ? ? ? ? ? ? ? ?"includeConditionCodes"
> ?[9] "includeNonPlottableEvents" "includeExchangeCodes"
>
> I tried conn$ useUTCTime and conn@ useUTCTime, and conn <- 
> blpConnect(useUTCTime=FALSE) but none of these make sense to the 
> package.
>
> Thanks for the help,
> David L. Reiner, Ph.D.
> Head Quant
> XR Trading LLC
> 550 West Jackson Boulevard, Suite 1000 Chicago, IL 60661-5704
> (312) 244-4610?direct
> (312) 244-4500?main
> David.Reiner@xrtrading.com
>
>
>
> This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are protected by intellectual property laws. ?Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.
>
> THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND. ?TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.
>
> _______________________________________________
> R-SIG-Finance@r-project.org 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.
>



------------------------------

Message: 3
Date: Wed, 28 Sep 2011 20:07:35 +0200
From: Matthieu Stigler <matthieu.stigler@gmail.com>
To: mtrokic <mirza.trokic@gmail.com>
Cc: r-sig-finance@r-project.org
Subject: Re: [R-SIG-Finance] Seasonal Dummy Variables in VECM (tsDyn)
Message-ID:
	<CAEYvigJghSULeqBAKTTzAhRtfyvsT2O6NQnpnANUJjzJad2rqw@mail.gmail.com>
Content-Type: text/plain

Dear Mirza

There is indeed a mismatch, as the possibility to include any regressor into
the cointegrating regressions was allowed earlier on. Now, with further
developments of the package (the ML estimator), this is unfortunately not
possible anymore.

Note that I do not have the book under the hand, but I suspect you want to
have the seasonal dummies in the VECM equation, not within the cointegrating
relationship? If this is the case, this is possible in the vars package.

Best

Matthieu

2011/9/26 mtrokic <mirza.trokic@gmail.com>

> Hello!
>
> I am currently working on the VECM chapters covering Lutkepohl's "New intro
> to multiple time series analysis". I would like to use the tsDyn library to
> replicate his examples. However, I for the life of me cannot understand how
> to include seasonal dummy variables in tsDyn:VECM.
>
> The time series Lutkepohl uses is bivariate quarterly data from 1972 Q2 to
> 1998 Q4. The procedure I would like to use is:
>
> library(tsDyn)
>
> e6ts = read.table('e6.dat', header = TRUE)
> e6ts = ts(e6ts, start = c(1972,2), frequency=4)
>
> e6ts.vecm.ml = VECM(e6ts, lag=3, r=1, include='const', estim='ML',
> LRinclude
> = ???)
>
> It is here where I get stuck. I want to include seasonal dummy variables of
> the sort D = (1,s1,s2,s3)'. However, I have no clue how to set up this
> matrix so that I can include it with LRinclude. In fact, whenever I try to
> put any matrix for LRinclude, such as LRinclude = D, it tells me that it
> must be NULL or a character vector.
>
> Can someone please be so kind and lead me though performing this example. I
> really need to learn how to do this.
>
> Thanking you in advance.
>
> Mirza T.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Seasonal-Dummy-Variables-in-VECM-tsDyn-tp3845323p3845323.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> R-SIG-Finance@r-project.org 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]]



------------------------------

Message: 4
Date: Wed, 28 Sep 2011 12:15:01 -0700
From: Stefan Petry <spetry@quantbench.com>
To: r-sig-finance@r-project.org
Subject: [R-SIG-Finance] Displaying candle data for thinly traded
	stocks
Message-ID:
	<CAPUJFCXdHp4QgmPM31U3k4SnRL0+2en4=dkdQUbOEkjpJPCe1A@mail.gmail.com>
Content-Type: text/plain

I would appreciate some advice on how to best display candle data for
sporadically traded stocks.
Is there any standard or best practice on how to represent a candle during
which there were zero trades?

The options I can think of are either (i) to draw a candle where OHLC are
all the same as the closing price of the previous candle or (ii) to not draw
a candle at all.
If (i) turns out to be the right answer, which price would you use for the
periods prior to the first trade?

Thanks a lot!
Stefan

	[[alternative HTML version deleted]]



------------------------------

Message: 5
Date: Wed, 28 Sep 2011 14:19:56 -0500
From: G See <gsee000@gmail.com>
To: Stefan Petry <spetry@quantbench.com>
Cc: r-sig-finance@r-project.org
Subject: Re: [R-SIG-Finance] Displaying candle data for thinly traded
	stocks
Message-ID:
	<CA+xi=qZMzSogMm7x-inAyP1E17-hqujWotcVDeLwS473-DSBxw@mail.gmail.com>
Content-Type: text/plain

What does this have to do with R?

On Wed, Sep 28, 2011 at 2:15 PM, Stefan Petry <spetry@quantbench.com> wrote:

> I would appreciate some advice on how to best display candle data for
> sporadically traded stocks.
> Is there any standard or best practice on how to represent a candle during
> which there were zero trades?
>
> The options I can think of are either (i) to draw a candle where OHLC are
> all the same as the closing price of the previous candle or (ii) to not
> draw
> a candle at all.
> If (i) turns out to be the right answer, which price would you use for the
> periods prior to the first trade?
>
> Thanks a lot!
> Stefan
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance@r-project.org 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]]



------------------------------

Message: 6
Date: Wed, 28 Sep 2011 14:52:32 -0500
From: Jeffrey Ryan <jeffrey.ryan@lemnica.com>
To: Stefan Petry <spetry@quantbench.com>
Cc: r-sig-finance@r-project.org
Subject: Re: [R-SIG-Finance] Displaying candle data for thinly traded
	stocks
Message-ID:
	<CABDUZc-SEZ81bDm84OerMQ-KzqMkAMGvMUbpszUGDUFXxkkCRw@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

In addition to 'nothing to do with R' at present, your affiliation
links back to a private beta, which would make me think you are simply
soliciting opinions for commercial purposes.

While the latter is fine I suppose, you haven't provided anyone
anything to motivate a response.

That said, I'd think (ii) is the best option, since I *am* responding.
 Using R's quantmod, times without any trading would be skipped -
either with a gap in a regularized series, or no gap in an irregular
one.  This is pretty consistent with most every implementation I can
think of.

Jeff

On Wed, Sep 28, 2011 at 2:15 PM, Stefan Petry <spetry@quantbench.com> wrote:
> I would appreciate some advice on how to best display candle data for
> sporadically traded stocks.
> Is there any standard or best practice on how to represent a candle during
> which there were zero trades?
>
> The options I can think of are either (i) to draw a candle where OHLC are
> all the same as the closing price of the previous candle or (ii) to not draw
> a candle at all.
> If (i) turns out to be the right answer, which price would you use for the
> periods prior to the first trade?
>
> Thanks a lot!
> Stefan
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance@r-project.org 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.
>



-- 
Jeffrey Ryan
jeffrey.ryan@lemnica.com

www.lemnica.com
www.esotericR.com



------------------------------

Message: 7
Date: Wed, 28 Sep 2011 14:58:22 -0500
From: Dirk Eddelbuettel <edd@debian.org>
To: chandra bajpai <cbajpai@gmail.com>
Cc: r-sig-finance@r-project.org, Dirk Eddelbuettel <edd@debian.org>
Subject: Re: [R-SIG-Finance] Weird problem with latest RQuantLib not
	working with QuantMod on R 2.13.1
Message-ID: <20099.31838.491135.252189@max.nulle.part>
Content-Type: text/plain; charset=us-ascii


Chandra,

FYI, here is a simple patch I tossed at Jeff earlier today and which he is
pondering.  In the meantime, apply it to quantmod sources and you're safe
from any interferene from objects named 'adjust' by rewriting the test a
little more conservatively.

Hope this helps,  Dirk


Index: pkg/R/getSymbols.R
===================================================================
--- pkg/R/getSymbols.R	(revision 567)
+++ pkg/R/getSymbols.R	(working copy)
@@ -190,7 +190,7 @@
 function(Symbols,env,return.class='xts',index.class="Date",
          from='2007-01-01',
          to=Sys.Date(),
-         ...)
+         ..., adjust)
 {
      importDefaults("getSymbols.yahoo")
      this.env <- environment()
@@ -198,7 +198,7 @@
         # import all named elements that are NON formals
         assign(var, list(...)[[var]], this.env)
      }
-     if(!exists("adjust", environment()))
+     if(missing("adjust"))
        adjust <- FALSE
 
      default.return.class <- return.class

-- 
New Rcpp master class for R and C++ integration is scheduled for 
San Francisco (Oct 8), more details / reg.info available at
http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php



------------------------------

Message: 8
Date: Wed, 28 Sep 2011 15:20:17 -0500
From: Jeffrey Ryan <jeffrey.ryan@lemnica.com>
To: chandra bajpai <cbajpai@gmail.com>
Cc: r-sig-finance@r-project.org
Subject: Re: [R-SIG-Finance] Weird problem with latest RQuantLib not
	working with QuantMod on R 2.13.1
Message-ID:
	<CABDUZc8qFoK7qa18gCWiUNxTDwjNtQeV=Zmincwcq6QmFF3PUQ@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Chandra,

A bug in getSymbols yahoo.  Patched in rev 568 on R-forge.  exists was
walking up the enclosing frames until it found a bound variable
'adjust' which in this case came from RQuantlib.  I added
inherits=FALSE to patch.

Thanks for the report (as well as thanks to Dirk for a suggested fix).

Best,
Jeff

On Tue, Sep 27, 2011 at 10:12 PM, chandra bajpai <cbajpai@gmail.com> wrote:
> Hi,
> I just got a new machine and installed a fresh version of R 2.13.1
> (latest version) and
> I think I found a problem with RQuantLib causing a problem an external
> module (QuantMod).
>
> I've got a 3 line program that shows the problem:
>
> R Version - R 2.13.1 ?(32 bit)
> OS: WIndows 7-64 bit
> RQuantLib ver: 0.3.8
> QuantMod ver: 0.3-17
>
> R Test Program Execution:
>
>> library(quantmod)
>> library(RQuantLib)
> Loading required package: Rcpp
>>
>> getSymbols("GOOG", from = "2011-05-01", to="2011-05-30", auto.assign = FALSE)
> Error in if (adjust) { : argument is not interpretable as logical
>>
>
> Now if I comment out library(RQuantLib), it works perfectly.
>
> What am I doing wrong? ?Any workaround?
> bw - This works perfectly on my R 2.11.1 machine.
>
> Thanks,
> Chandra
>
> _______________________________________________
> R-SIG-Finance@r-project.org 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.
>



-- 
Jeffrey Ryan
jeffrey.ryan@lemnica.com

www.lemnica.com
www.esotericR.com



------------------------------

Message: 9
Date: Wed, 28 Sep 2011 15:21:55 -0500
From: Dirk Eddelbuettel <edd@debian.org>
To: Dirk Eddelbuettel <edd@debian.org>
Cc: r-sig-finance@r-project.org, chandra bajpai <cbajpai@gmail.com>
Subject: Re: [R-SIG-Finance] Weird problem with latest RQuantLib not
	working with QuantMod on R 2.13.1
Message-ID: <20099.33251.458409.326225@max.nulle.part>
Content-Type: text/plain; charset=us-ascii


On 28 September 2011 at 14:58, Dirk Eddelbuettel wrote:
| FYI, here is a simple patch I tossed at Jeff earlier today and which he is

Jeff being Jeff, a more compact patch has now been committed.  Upgrade to
HEAD of svn also fixes things.

Dirk

-- 
New Rcpp master class for R and C++ integration is scheduled for 
San Francisco (Oct 8), more details / reg.info available at
http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php



------------------------------

Message: 10
Date: Wed, 28 Sep 2011 16:36:06 -0700 (PDT)
From: Muhammad Abuizzah <izzah100@yahoo.com>
To: "r-sig-finance@r-project.org" <r-sig-finance@r-project.org>
Subject: [R-SIG-Finance] extract a particular hour of tick data from
	multiple days form xts object
Message-ID: <1317252966.9240.YahooMailNeo@web45203.mail.sp1.yahoo.com>
Content-Type: text/plain; charset=iso-8859-1

Hi,

I have an xts dataframe called a1. ?Its tick data for many months. ?The data is already in xts format so the first column is the index.
I reviewed the xts manual and on page 5 of the xts package manual it talks about extracting recurring times between 8:30 to 15:00 using the code ?.parseISO8601('T08:30/T15:00')
My objective is to assign names to certain recurring times such as to call the ticks prior to 9:30 "premarket" so obviously it's to work on a certain hour across all dates

It wasn't clear from the manual's example above how to construct the code so I tried the following and none worked:-

premkt <- a1 [.parseISO8601('T06:30/T9:30'),] ?## used the example supplied by the manual to specify the rows I want from my dataframe


premkt <-?.parseISO8601(a1,'T06:30/T9:30') ?## again I wasn't sure how to use the example in the package so I tried to use the time bracket as an argument for a parseISO8601 function with my dataframe as the first argument



also tried ?premkt <-?a1['T06:30/T9:30' ] ?## I saw a question by someone in which such or similar code was used.

Thanks for the help in advance!!

.



------------------------------

Message: 11
Date: Wed, 28 Sep 2011 19:25:45 -0500
From: "Brian G. Peterson" <brian@braverock.com>
To: Muhammad Abuizzah <izzah100@yahoo.com>
Cc: "r-sig-finance@r-project.org" <r-sig-finance@r-project.org>
Subject: Re: [R-SIG-Finance] extract a particular hour of tick data
	from multiple days form xts object
Message-ID: <1317255945.4192.282.camel@brian-desktop>
Content-Type: text/plain; charset="UTF-8"

On Wed, 2011-09-28 at 16:36 -0700, Muhammad Abuizzah wrote:
> premkt <- a1['T06:30/T9:30' ]

premkt <- a1['T06:30/T09:30' ]

the ISO 8601 format is very particular.

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



------------------------------

Message: 12
Date: Thu, 29 Sep 2011 09:54:44 +0300
From: Costas Vorlow <costas.vorlow@gmail.com>
To: <peter@braverock.com>
Cc: r-sig-finance@stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] Open to Close to Open data transformation
	(quantmod, xts and possibly zoo) + chart.TimeSeries
Message-ID:
	<CABfqsR8bzYVuu3OHxPJvCNxargKOYP6HnV1Y=Ao1KMOjN-z+mg@mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"

Dear Peter,

Still no hope. I am doing something wrong. I noticed that the times
are also going through. Maybe that's the problem?
I tried to include them to the area-event-dates list in the function
call but still no shading....

> tail(newdata,50)
                    SP500  Close
2011-08-22 08:30:00      1123.55
2011-08-22 15:00:00      1123.82
2011-08-23 08:30:00      1124.36
2011-08-23 15:00:00      1162.35
2011-08-24 08:30:00      1162.16
2011-08-24 15:00:00      1177.60
2011-08-25 08:30:00      1176.69
2011-08-25 15:00:00      1159.27
2011-08-26 08:30:00      1158.85
2011-08-26 15:00:00      1176.80
2011-08-29 08:30:00      1177.91
2011-08-29 15:00:00      1210.08
2011-08-30 08:30:00      1209.76
2011-08-30 15:00:00      1212.92
2011-08-31 08:30:00      1213.00
2011-08-31 15:00:00      1218.89
2011-09-01 08:30:00      1219.12
2011-09-01 15:00:00      1204.42
2011-09-02 08:30:00      1203.90
2011-09-02 15:00:00      1173.97
2011-09-06 08:30:00      1173.97
2011-09-06 15:00:00      1165.24
2011-09-07 08:30:00      1165.85
2011-09-07 15:00:00      1198.62
2011-09-08 08:30:00      1197.98
2011-09-08 15:00:00      1185.90
2011-09-09 08:30:00      1185.37
2011-09-09 15:00:00      1154.23
2011-09-12 08:30:00      1153.50
2011-09-12 15:00:00      1162.27
2011-09-13 08:30:00      1162.59
2011-09-13 15:00:00      1172.87
2011-09-14 08:30:00      1173.32
2011-09-14 15:00:00      1188.68
2011-09-15 08:30:00      1189.44
2011-09-15 15:00:00      1209.11
2011-09-16 08:30:00      1209.21
2011-09-16 15:00:00      1216.01
2011-09-19 08:30:00      1214.99
2011-09-19 15:00:00      1204.09
2011-09-20 08:30:00      1204.50
2011-09-20 15:00:00      1202.09
2011-09-21 08:30:00      1203.63
2011-09-21 15:00:00      1166.76
2011-09-22 08:30:00      1164.55
2011-09-22 15:00:00      1129.56
2011-09-23 08:30:00      1128.82
2011-09-23 15:00:00      1136.43
2011-09-26 08:30:00      1136.91
2011-09-26 15:00:00      1162.95

On 28 September 2011 14:08, Peter Carl <peter@braverock.com> wrote:
> Linux, although I don't think that should have a bearing on this issue.
> Windows issues are more common around timezones. ?That said, I'm not a
> Windows expert...
>
> Did you also try a lower time granularity, such as:
> chart.TimeSeries(newdata, date.format="%d-%m-%y", period.areas =
> list(c("2011-01", "2011-05")), period.color = "blue", lwd = 2)
>
> I'm using PerformanceAnalytcs_1.0.3.3. ?This behavior did change in a
> recent CRAN release, so it might also be a version issue. ?Check with:
> sessionInfo()
>
> HTH,
>
> pcc
> --
> Peter Carl
> http://www.braverock.com/~peter
>
>> Thanks but I am not getting anything. Are you using Linux or Windows
>> platforms?
>>
>> On 27 September 2011 19:54, Peter Carl <peter@braverock.com> wrote:
>>> You may have already figured this out, but the dates have to appear in
>>> the
>>> timeseries at the same granularity you are looking to match.
>>>
>>>> chart.TimeSeries(newdata, date.format="%d-%m-%y", period.areas =
>>> list(c("03-01-2011","05-06-2011")), period.color = "blue", lwd = 2)
>>>
>>> should be...
>>>
>>>> chart.TimeSeries(newdata, date.format="%d-%m-%y", period.areas =
>>> list(c("2011-01-03","2011-06-06")), period.color = "blue", lwd = 2)
>>>
>>> ... where the list of areas is specified in 8601 format. ?Also note that
>>> the fifth of June does not appear in your data series. ?If you are
>>> looking
>>> to match at a higher granularity, then period.areas = list(c("2011-01",
>>> "2011-05")) would also work.
>>>
>>> HTH,
>>>
>>> pcc
>>> --
>>> Peter Carl
>>> http://www.braverock.com/~peter
>>>
>>>> Thanks again.
>>>>
>>>> One more point:
>>>>
>>>> When I try
>>>>
>>>> chart.TimeSeries(newdata, date.format="%d-%m-%y", period.areas =
>>>> list(c("03-01-2011","05-06-2011")), period.color = "blue", lwd = 2)
>>>>
>>>> I can't get the event period shadings.
>>>>
>>>> This has to do I guess with the fact that 2 prices have the same data
>>>> though different hourly time signature.
>>>>
>>>> Is this correct and how do I rectify it?
>>>>
>>>> I've been trying around with formats but no result so far.
>>>>
>>>> On 23 September 2011 14:56, G See <gsee000@gmail.com> wrote:
>>>>> FWIW, I misread the docs for getSymbols.yahoo which says
>>>>> ? ? ?In the case of xts objects, the indexing will be by Date. This
>>>>> can
>>>>> ? ? ?be altered with the ?index.class? argument. ?See ?indexClass? for
>>>>> ? ? ?more information on changing index classes.
>>>>> So, this should be perfectly acceptable as well:
>>>>> medata <- getSymbols("^GSPC",
>>>>> ? ? ? ? from=Sys.Date()-400,
>>>>> ? ? ? ? index.class='POSIXct',
>>>>> ? ? ? ? auto.assign=FALSE)
>>>>> opens <- Op(medata)
>>>>> closes <- Cl(medata)
>>>>> index(opens) <- index(opens) + (60*60*8) + (60*30)
>>>>> index(closes) <- index(closes) + (60*60*15)
>>>>> newdata <- rbind(opens,closes)
>>>>> colnames(newdata) <- "GSPC.OC"
>>>>>> tail(newdata)
>>>>> ? ? ? ? ? ? ? ? ? ? GSPC.OC
>>>>> 2011-09-20 08:30:00 1204.50
>>>>> 2011-09-20 15:00:00 1202.09
>>>>> 2011-09-21 08:30:00 1203.63
>>>>> 2011-09-21 15:00:00 1166.76
>>>>> 2011-09-22 08:30:00 1164.55
>>>>> 2011-09-22 15:00:00 1129.56
>>>>>
>>>>> On Fri, Sep 23, 2011 at 8:25 AM, G See <gsee000@gmail.com> wrote:
>>>>>>
>>>>>> Hi Costas,
>>>>>> You need an indexClass that can handle times. ?By default
>>>>>> getSymbols.yahoo
>>>>>> gives you an object with 'Date' indexClass which you need to change
>>>>>> to
>>>>>> something like 'POSIXct' or 'POSIXlt'
>>>>>> (You *can* do this directly in your getSymbols call using the
>>>>>> argument
>>>>>> index.class='POSIXct', but the documentation says only "Date" is
>>>>>> supported,
>>>>>> so I'll do it the other way)
>>>>>> require(quantmod)
>>>>>> getSymbols("^GSPC",from='1990-01-01')
>>>>>> medata <- tail(GSPC, 400)
>>>>>> indexClass(medata) <- "POSIXct"
>>>>>> opens <- Op(medata)
>>>>>> closes <- Cl(medata)
>>>>>> index(opens) <- index(opens) + (60*60*8) + (60*30)
>>>>>> index(closes) <- index(closes) + (60*60*15)
>>>>>> newdata <- rbind(opens,closes)
>>>>>> colnames(newdata) <- "GSPC.OC"
>>>>>> > tail(newdata)
>>>>>> ? ? ? ? ? ? ? ? ? ? GSPC.OC
>>>>>> 2011-09-20 08:30:00 1204.50
>>>>>> 2011-09-20 15:00:00 1202.09
>>>>>> 2011-09-21 08:30:00 1203.63
>>>>>> 2011-09-21 15:00:00 1166.76
>>>>>> 2011-09-22 08:30:00 1164.55
>>>>>> 2011-09-22 15:00:00 1129.56
>>>>>> Regards,
>>>>>> Garrett
>>>>>> On Fri, Sep 23, 2011 at 4:50 AM, Costas Vorlow
>>>>>> <costas.vorlow@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I want to put in order (preferably as a zoo or xts object with a
>>>>>>> suitable
>>>>>>> timestamp)
>>>>>>> the open anc closing prices of an (say) index downloaded from YAHOO
>>>>>>> finance:
>>>>>>>
>>>>>>> require(quantmod)
>>>>>>> getSymbols('^GSPC',from='1990-01-01')
>>>>>>>
>>>>>>> medata<- tail((GSPC),400)
>>>>>>> opens<-Op(medata)
>>>>>>> closes<-Cl(medata)
>>>>>>>
>>>>>>> i.e., I want ?asingle sequence of ?1095.89, ? ?1105.24 , 1101.24 ,
>>>>>>> 1102.94, and so on ... preferably with a timestamp (morning -
>>>>>>> evening
>>>>>>> of
>>>>>>> same day as for daily prices zoo does not like the same date in two
>>>>>>> consecutive prices...
>>>>>>>
>>>>>>> > head(merge(opens,closes))
>>>>>>> ? ? ? ? ? GSPC.Open GSPC.Close
>>>>>>> 2010-02-24 ? 1095.89 ? ?1105.24
>>>>>>> 2010-02-25 ? 1101.24 ? ?1102.94
>>>>>>> 2010-02-26 ? 1103.10 ? ?1104.49
>>>>>>> 2010-03-01 ? 1105.36 ? ?1115.71
>>>>>>> 2010-03-02 ? 1117.01 ? ?1118.31
>>>>>>> 2010-03-03 ? 1119.36 ? ?1118.79
>>>>>>> >
>>>>>>> >
>>>>>>> Probably I could use the OpCl in quantmod and caclulate the Cl price
>>>>>>> from
>>>>>>> Op, though Is there any easy way using some implicit zoo/xts
>>>>>>> function
>>>>>>> for
>>>>>>> this? I have problems in puting the timestamps in the xts vobject.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Costas
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> R-SIG-Finance@r-project.org 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.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>>>> |c|o|s|t|a|s|@|v|o|r|l|o|w|.|o|r|g|
>>>> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>>>>
>>>> _______________________________________________
>>>> R-SIG-Finance@r-project.org 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.
>>>>
>>>
>>>
>>>
>>
>>
>>
>> --
>>
>> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> |c|o|s|t|a|s|@|v|o|r|l|o|w|.|o|r|g|
>> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>>
>
>
>



-- 

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|c|o|s|t|a|s|@|v|o|r|l|o|w|.|o|r|g|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+



------------------------------

_______________________________________________
R-SIG-Finance mailing list
R-SIG-Finance@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-finance


End of R-SIG-Finance Digest, Vol 88, Issue 28
*********************************************

	[[alternative HTML version deleted]]

