[R-SIG-Finance] Quantstrat - Multi-symbol (cross-section) analysis implimentation question..
Michael Chen
mwc4120 at hotmail.com
Mon Jul 31 15:55:58 CEST 2017
Hi Frank,
Thanks. Yes, reproducible code would be good, but unfortunately I have been struggling on that end, but I will try to put something together. At the mean time, please let me explain the problem conceptually again, it may help.
Using Quantstrat, once you load the symbols and initialize the parameters, I would define the indicators. For example:
add.indicator(strategy.st, name = "runPercentRank",
arguments = list(x = quote(Vo(mktdata)), n=90),
label = "VolPctRnkX")
This indicator is just the running percent rank on Volume data for the past 90 days for each symbol. Then I add signals and strategy rules, simple enough. However, as far as I can know, strategy rules (signals and indicators) in quanstrat are applied to each symbol in the dataset sequentially and in chronological order. Let's say, I have three futures in my dataframe: AA, BB, and CC (as an example), the "VolPctRnkX" will be calculated for each future: AA, BB, CC. If I examine the mktdata for each symbol (AA, BB, or CC), each will have a column data named "VolPctRankX"
My problem is that I want to compare this indictor "VolPctRnkX" for each symbol at each timestamp to that of other symbols. In otherwords, ranks the sybmols according to its own "VolPctRnkX" value. So, in this example, at a particular date: "2010-10-01, the ranking could be BB, CC, AA, based on each's "VolPctRankX" value on that day.
Symbol VolPctRankX
BB 0.95
CC 0.85
AA 0.50
Then, I can make another indicator or rule using this ranking to size my order. For this to work, there has to be cross-section (across symbols) comparasion at each time stamp. How do I impliment this in the Quanstrat framework?
Is this a little clearer??
thanks again,
Michael
________________________________
From: Frank <frankm60606 at gmail.com>
Sent: Sunday, July 30, 2017 12:53 PM
To: 'Michael Chen'; 'r-sig-finance'
Subject: RE: [R-SIG-Finance] Quantstrat - Multi-symbol (cross-section) analysis implimentation question..
Hi,
Well, reproducible code would get us all closer to making helpful
suggestions. Would you show us the code to read in two futures price streams
and make your calculation? Then we can see what the ranking problem is.
Thanks,
Frank
Chicago
-----Original Message-----
From: R-SIG-Finance [mailto:r-sig-finance-bounces at r-project.org] On Behalf
Of Michael Chen
Sent: Sunday, July 30, 2017 12:11 PM
To: r-sig-finance <R-SIG-Finance at r-project.org>
Subject: [R-SIG-Finance] Quantstrat - Multi-symbol (cross-section) analysis
implimentation question..
Hi,
I am trying to impliment a seemingly simple analysis in Quanstrat, but I am
stuck. Let's say that I have 50 futures in my data frame. Each future is a
time series of OHLC data. I want to at each time stamp, compare the value
of an indicator for each future and rank the futures accordingly. For
example, I want to rank the futures based on each's 5-day return. How do I
impliment this in Quanstrat?
So far, the only way I came up with go get around this is to pre-process
each future's data then store the ranking data for each future in its own
data set. But this is not flexible and cumbersome.
Thank your for any suggestions, obviously I don't have a reproducible code
yet.
Michael
[[alternative HTML version deleted]]
_______________________________________________
R-SIG-Finance at 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]]
More information about the R-SIG-Finance
mailing list