Skip to content

Quantstrat with TAQ data

10 messages · Robert A'gata, Aleksey Schukin, Chinmay Patil +1 more

#
On 12/12/2012 09:45 PM, Robert A'gata wrote:
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
1 day later