[R-SIG-Finance] Dealing with the futures roll in quantstrat and blotter

Brian G. Peterson brian at braverock.com
Mon Mar 14 18:06:14 CET 2011


On 03/14/2011 10:56 AM, Gei Lin wrote:
> My issue with one continuous series is that the spliced series does not
> reflect actual performance on the roll date.  There is an inherent drop in
> price from one contract to the next that if the strategy holds over the
> roll.  What's need is a rolled performance series, and but in that case,
> rolled performance is what is being traded and not prices, resulting in an
> orderBook this can't be directly piped to or compared to a real life order
> management system.
>
> I would like to actually simulate trading the roll within the blotter rather
> than mask it away with a shortcut.  I suppose this can be done by setting up
> different portfolios with the set of tradeable symbols for each time frame
> and lopping calls to applyStrategy for each portfolio?

Sorry, I didn't understand what you were getting at, specifically.

Yes.  You've got the right idea.  You don't need to separate them into 
different portfolios if you subset your price data first, wince 
quantstrat will loop over symbols anyway.

I'd probably do something like this:
- create all the future_series instruments

- create a portfolio with all these instruments in it,
   in order of expiration

- construct your roll calendar

- subset your data for each instrument based on the roll calendar

- build your strategy

- make sure the strategy knows to 'get flat' on
   the last day of the data series for each instrument

- call applyStrategy

There are other ways to do this, but this seems the simplest, and 
doesn't require any code changes.

Regards,

    - Brian


> On Mon, Mar 14, 2011 at 11:35 AM, Brian G. Peterson<brian at braverock.com>wrote:
>
>> On 03/14/2011 10:02 AM, Gei Lin wrote:
>>
>>> Has anyone dealt with rolling futures in the quantstrat and blotter
>>> framework?
>>>
>>
>> Yes,  we roll products manually.
>>
>> The 'best' approach is probably to construct some sort of continuous series
>> that implements whatever rules you use (roll calendar, volume cross,
>> whatever).
>>
>> Robert Sams wrote splicing functions, but they assume univariate data, and
>> have not been ported to handle multi-column data (e.g. OHLC or TBBO data)
>> for each instrument.
>>
>> Any assistance or contributions on the splicing front would be gladly
>> accepted.
>>
>>
>>   I am working on an event based strategy -- the eventIndicators function
>>> just
>>> returns a whole list of events in xts format (values = 1) that coincide
>>> with
>>> the index datetimes of the mktdata
>>>
>>> # add the event indicators
>>> stratEvent<- add.indicator(strategy = stratEvent, name =
>>> "eventIndicators",
>>> arguments = list(price = quote(getPrice(mktdata))))
>>>
>>> I then add rules for entry and exit based on the event column being true:
>>>
>>> stratEvent<- add.rule(stratEvent, name='ruleSignal', arguments =
>>> list(sigcol="MEm1"),sigval=TRUE, orderqty=100, ordertype= 'market',
>>> orderside=NULL, threshold=NULL),type='enter')
>>>
>>> I would like to have this strategy applied to a futures contract based on
>>> a
>>> specified rolling convention (e.g. if<   2 days before first notice of
>>> delivery, trade the 2nd contract, otherwise trade the 1st e.g. TY2 Comdty
>>> versus TY1 Comdty).
>>>
>>> I would like to apply this strategy to 1 portfolio covering multiple
>>> decades
>>> of data of closing price data with the whole futures chain.  I'm not sure
>>> how to call applyStrategy to get the result I want when the instrument the
>>> strategy is trading changes over time.
>>>
>>
>> I would construct a continuous series first, then add an instrument for
>> that continuous series to your portfolio, and test your strategy using the
>> continuous series information.
>>
>> Regards,
>>
>>   - Brian
>>
>> --
>> Brian G. Peterson
>> http://braverock.com/brian/
>> Ph:<773-459-4973>773-459-4973
>> IM: bgpbraverock
>>
>> _______________________________________________
>> 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]]
>
> _______________________________________________
> 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.


-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list