Skip to content
Prev 14364 / 15274 Next

Quantstrat - Multi-symbol (cross-section) analysis implimentation question..

Hi Michael,

?but unfortunately I have been struggling on that end.? Show us your
struggles:

1)	Show us the code you have to read in three commodities. 
2)	Show us the code that calculates the indicator.
If steps 1 or 2 are not working, we can help you.
symbols. Don?t do that. Have an indicator

AA 3
BB 1
CC 2

Where BB is the first commodity to trade, CC is second and AA is third. 

" rule using this ranking to size my order"

I can't tell what order sizing rule you are trying to use. If you only trade
one commodity, then you need another column for the allowed size for BB in
this case, but for all commodities in case they are traded. What seems
likely is you want to trade more than one commodity up to a risk limit of
$100,000 as an example. If your size in BB is constrained to 100 contracts
which is $75,000 of risk, then you have up to $25,000 of risk to trade in
CC. If CC maxes out at 50 contracts with $20,000 of risk, then you would add
some size for AA.


Best,

Frank

=================================

From: Michael Chen [mailto:mwc4120 at hotmail.com] 
Sent: Monday, July 31, 2017 8:56 AM
To: Frank <frankm60606 at gmail.com>; 'r-sig-finance'
<R-SIG-Finance at r-project.org>
Subject: Re: [R-SIG-Finance] Quantstrat - Multi-symbol (cross-section)
analysis implimentation question..

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