Thank you Brian. Your response is really clear. I really appreciate you
being so kind to newbie like me. I have another question. I was able to
install quantstrat from R-forge properly few days ago. Today I am trying to
install it on another machine. I found out from R-forge SCM page that it
fails to build. Therefore, my install.packages command just said that the
package is not available for R 2.15.1. Is there any way I can shield myself
from this? Because the build failed. I cannot even download the tar.gz. Any
input would be much appreciated.


On Thu, Dec 13, 2012 at 7:52 AM, Brian G. Peterson <brian@braverock.com>wrote:

> On 12/12/2012 09:45 PM, Robert A'gata wrote:
>
>> Thank you Aleksey. My doubt is less about whether it will be xts or zoo.
>> My
>> apology as I should be more precise. Says, I have an xts data with the
>> following columns: TradePrice, TradeSize, Bid, Ask, HistoricalVolatility.
>> Then my questions are:
>>
>> 1) How can I make this xts available to add.indicator? In most examples, I
>> see that one has to create an instrument out of it. Then assign instrument
>> ID to portfolio or strategy object. Finally rely on mktdata to look up.
>> 2) For each tick, I'd like to access all the columns in the xts. A
>> simplest
>> example would be, I'd like to compute VWAP with 100-trade rolling window.
>> Then compute the distance betwen current mid price and the running VWAP.
>> How can I let my add.indicator know that I want a whole row and not only
>> price? My understanding is that quote(mktData) will try to look for price
>> only.
>>
>>
> As is outlined in the documentation, you need instrument metadata that
> defines the instruments that you're trying to use.  For TAQ data from NYSE,
> these would be stock() instruments.
>
> quantstrat, by default, assumes that you will have data named for each
> instrument, just as though you had called getSymbols.  Other approaches are
> possible, but harder, so we'll skip that.
>
> If you use RTAQ (or the newer 'highfrequency' from R-Forge) to create xts
> objects from your TAQ CSV files, you can easily save these parsed xts
> objects to disk in a format suitable for getSymbols (specifically,
> getSymbols.FI) to go get them for you with from and to dates.  This will
> have the added advantage of making in faster and easier to get this data
> back into R for later analysis.
>
> Let's assume you've done all that, and want to add a 100-trade VWAP
> indicator, as you've requested.  That would look like:
>
> add.indicator(s, name="VWAP",
>         arguments = list(
>                 price = quote(mktdata$TradePrice)),
>                 n = 100,
>                 volume = quote(mktdata$TradeSize))
>         ),
>         label="VWAP"
> )
>
> As a side note, You could also easily create and add your
> HistoricalVolatility column as an indicator inside the strategy as well,
> encapsulating all the required analytical code in the strategy object.
>
> Regards,
>
>    - Brian
>
> --
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
>
>
> ______________________________**_________________
> R-SIG-Finance@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-sig-finance<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]]

