[R-SIG-Finance] rbind and duplicates in monthly futures

Joshua Ulrich josh.m.ulrich at gmail.com
Thu Apr 7 02:57:25 CEST 2016

On Tue, Apr 5, 2016 at 3:06 PM, Peter Neumaier <peter.neumaier at gmail.com> wrote:
> Hi all, in the interim I've managed to import the halfhourly data, cast to a
> matrix, then rbind the two months
> and convert to XTS for later use by my algo strategy.
> I am wondering how the data overlap will be treated by the quantstrat
> framework and how
> it might be impacting the calculations (i.e. P&L during overlaps).
It wasn't clear to me from your original question, but I can now see
that you want to create a single continuous futures series using
adjacent futures contracts.  As you probably guessed, the overlap in
data in your APR_MAY object would be very bad.

There is not a single correct way to create a continuous futures
series for every futures market.  You could roll to the next contract
when the current contract expires, when volume or open interest in the
current contract drops below some threshold over the next contract's
volume or open interest, etc.

I realize this doesn't completely answer your question... because your
question is not just about programming.  It's also about the
microstructure of the market you're researching.  Searching for
"continuous futures" or "futures roll" should help give you some ideas
about how to solve the problem for this specific futures market.

> Below the files and the code I am using:
> APR <-
> as.matrix(read.zoo("NGF201404_6weeks30mins.csv",sep=",",tz="",header=T))
> MAY <-
> as.matrix(read.zoo("NGF201405_6weeks30mins.csv",sep=",",tz="",header=T))
> APR_MAY <- as.xts(rbind(APR,MAY))
> http://tempsend.com/BBA86DB4ED
> http://tempsend.com/0EDA07753B
> Thanks
> Peter
> On Mon, Apr 4, 2016 at 2:30 PM, Joshua Ulrich <josh.m.ulrich at gmail.com>
> wrote:
>> On Mon, Apr 4, 2016 at 7:24 AM, Peter Neumaier <peter.neumaier at gmail.com>
>> wrote:
>> > Hi all, I am trying to rbind monthly futures to a continuous time series
>> > to
>> > be run through an algo strategy. The problem here is that data is
>> > overlapping, i.e. my Feb contract trades for 6 weeks and when I rbind
>> > with
>> > my March data I get an overlap for last two weeks of Jan.
>> >
>> > How can I create a time series that is continuous, not overlapping and
>> > useable in quantstrat (i.e. XTS format)? I am not posting any code as it
>> > would be really one single rbind statement.
>> >
>> Even though the code may be simple, you still would be more likely to
>> receive help if you provide a minimal reproducible example of the
>> issue.  In this case, the data are not simple, and most people will
>> not take the time to construct sample data in order to attempt to
>> reproduce the issue you describe.
>> > Thanks
>> > Peter
>> >
>> >         [[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.
>> --
>> Joshua Ulrich  |  about.me/joshuaulrich
>> FOSS Trading  |  www.fosstrading.com
>> R/Finance 2016 | www.rinfinance.com

Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com
R/Finance 2016 | www.rinfinance.com

More information about the R-SIG-Finance mailing list