Quantstrat - extracting current symbol
On 05/12/2017 03:58 AM, Oskar Gottlieb wrote:
I have multiple symbols (futures contracts) of one product and I would like to access a data frame with their meta information. I would then parse the meta info into an add.indicator argument list. Is there a function, which would return the current symbol over which we are looping?
quantstrat would expect the metadata for these symbols to be in FinancialInstrument, not in a data.frame. That is where quantstrat and blotter expect to get things like tick size, multiplier, expiration date, and currency for each instrument. Inside quantstrat, there will always be a 'symbol' variable which you could access to find out what symbol is currently being processed (unless we're in a rebalancing rule, when that doesn't apply). What I would recommend is to put all your instrument metadata in FinancialInstrument (since that is what it is for) and have your indicator and signal functions access that data with getInstrument(symbol) To further guess at what you're trying to do, you talk about using this list for add.indicator. I don't understand what you're trying to do with that statement. The strategy object is a specification of how the strategy will work. The indicators, signals, and rules should all work on the mktdata passed to them by the applyStrategy function (and inside that by applyIndicators, applySignals, applyRules). So any call to add.indicator should be generic for the entire strategy specification. If you wanted an indicator to do something different based on tenor or days to expiration, for example, you'd handle that inside the indicator function, not as parameters to the call to add.indicator. (probably after calling getInstrument to get the metadata, as described above). If this hasn't answered your question, perhaps you could follow up with something more specific including a *minimal* example. Regards, Brian
Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock