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.
From this code, I think I, or others, can point you in the right direction.
If steps 1 or 2 are not working, we can help you.
From your BB, CC, AA example, it looks like you are trying to reorder the
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
From: Frank <mailto: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)
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 <mailto: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]] _______________________________________________ mailto: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.