Skip to content

Dealing with the futures roll in quantstrat and blotter

4 messages · Gei Lin, Brian G. Peterson

#
On 03/14/2011 10:02 AM, Gei Lin wrote:
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 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
#
On 03/14/2011 10:56 AM, Gei Lin wrote:
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