NexusFi: Find Your Edge


Home Menu

 





Backadjust futures contracts for spread trading backtesting


Discussion in Commodities

Updated
      Top Posters
    1. looks_one atmaweapon with 3 posts (1 thanks)
    2. looks_two SMCJB with 2 posts (6 thanks)
    3. looks_3 Hulk with 2 posts (1 thanks)
    4. looks_4 kevinkdog with 1 posts (3 thanks)
      Best Posters
    1. looks_one SMCJB with 3 thanks per post
    2. looks_two kevinkdog with 3 thanks per post
    3. looks_3 Hulk with 0.5 thanks per post
    4. looks_4 atmaweapon with 0.3 thanks per post
    1. trending_up 755 views
    2. thumb_up 11 thanks given
    3. group 4 followers
    1. forum 7 posts
    2. attach_file 3 attachments




 
Search this Thread

Backadjust futures contracts for spread trading backtesting

  #1 (permalink)
atmaweapon
madrid spain
 
Posts: 3 since Dec 2022
Thanks Given: 0
Thanks Received: 1

Hello, I have a doubt that I have been thinking about for a while.

I know that if I want to backtest a strategy on futures contract I have to adjust the rollover spread between contacts by "stitching" them together (sometimes called panama adjustment, if I am not wrong), in order to get a continous contract.

But let's say I want to trade the Gasoline / Brent spread, or the gold / silver spread. So, I want a time series that represents the backadjusted spread netween the two legs (the difference or the ratio, it does not matter).
How should I proceed? Should I simply first backadjust the two legs separately and take difference (or the ratio), obviously correctly calibrated (in the case of gasoline/brent I would multiply gasoline by 42 or something, it depend on the case).

Or should I do something else? Do you have an example of the backadjusted gasoline/brent spread to double check?

thank you very much

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Any futures traders in Texas looking to give back to tho …
Traders Hideout
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
20 thanks
My NQ Trading Journal
19 thanks
Just another trading journal: PA, Wyckoff & Trends
17 thanks
Daytrading ES & NQ
9 thanks
HumbleTraders next chapter
9 thanks
  #2 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,661 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,347


atmaweapon View Post
Hello, I have a doubt that I have been thinking about for a while.

I know that if I want to backtest a strategy on futures contract I have to adjust the rollover spread between contacts by "stitching" them together (sometimes called panama adjustment, if I am not wrong), in order to get a continous contract.

But let's say I want to trade the Gasoline / Brent spread, or the gold / silver spread. So, I want a time series that represents the backadjusted spread netween the two legs (the difference or the ratio, it does not matter).
How should I proceed? Should I simply first backadjust the two legs separately and take difference (or the ratio), obviously correctly calibrated (in the case of gasoline/brent I would multiply gasoline by 42 or something, it depend on the case).

Or should I do something else? Do you have an example of the backadjusted gasoline/brent spread to double check?

thank you very much

Typical backadjusted continuous futures contracts work well with price DIFFERENCES, but will give incorrect results for RATIO calculations (incorrect in that the ratio for a date late year will change at the next rollover. This sometimes leads to signals that were not present at the original creation date). This is regardless of it is a single instrument or a combination/ratio of many instruments.

So, if you are doing a ratio, I would use the unadjusted continuous contract. Problem with crude is it rolls earlier than heating oil or unleaded gas, so you will have to adjust for that.

What you actually trade should be backadjusted data, to make sure your strategy does not improperly take advantage of rollover gaps.

I would recommend examining the data by hand and seeing what works for your need before any heavy testing.

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,048 since Dec 2013
Thanks Given: 4,381
Thanks Received: 10,205


As somebody who almost only trades spreads (and even spreads of spreads) this is something I have given some thought to, but not come up with a good answer. As already diagnosed the big issue is how to adjust for rollovers. For something like ES/NQ (S&P500/Nasdaq) or ZB/ZN (30 yr vs 10 yr Treasury) this probably isn't as a big an issue as it is for Gasoline/Brent (RB/BZ).

In the case of ES/NQ the rollover only occurs once every 3 months, it occurs on the same day for both contracts, and the rollover premium/discount will be highly correlated since both are really just dividends minus cost of carry. Hence as @kevinkdog said using the unadjusted continuous contract probably works.

Gasoline/WTI though is the opposite. Both roll every month. Crude rolls around the 20th and Gasoline rolls at month end. Also the rollover premium/discount will be highly UNcorrelated. Crude is a non-seasonal contract based upon delivery in the Midwest US. Gasoline is very seasonal contract based upon delivery in NY Harbor. So you have product differences (supply/demand), locational differences (Midwest vs NYH) and seasonal differences. Gasoline/Brent has the advantage that the contracts roll at the same time, but Brent is North Sea Crude benchmark and probably even more fundamentally different than WTI when compared to Gasoline. NOTE: The seasonality is a big issue here. If you just use the unadjusted continuous contract it will look like you should go long this spread every spring and short it every fall. In reality that is mostly a factor of the seasonality/rollovers and not actual price changes. Similar issues with Gold (which trades GJMQVZ) vs Silver (which trades FHKNUZ). Now imagine that you want to spread between a basket of energies (say Gasoline, Heating Oil & Brent) vs a basket of Metals (say Gold, Silver and Copper).

Additionally not only is the ES/NQ (and ZB/ZN) spread a lot easier to model but there is a whole world of people, managing billions of dollars looking at the ES/NQ spread, so finding and edge in there may be difficult. On the other hand there's very few people looking at a basket of Energies vs a basket of Metals so I think the chance of finding something there is higher.

Sorry I didn't add much to this thread! Very interested in it though and would love to promote additional discussion. Unfortunately not many around here interested in this subject and hence not sure who else on futures.io might find this interesting. Maybe @Hulk ?

NOTE: You can use back-adjusted contracts if your momentum trading, ie picking/buying the contract with the most positive momentum, and selling the contract with the most negative momentum, but don't believe that was what the OP was asking.

Reply With Quote
  #4 (permalink)
 
Hulk's Avatar
 Hulk 
Texas, USA
 
Experience: Advanced
Platform: TT, Custom
Trading: Futures, Spreads
Posts: 369 since May 2014
Thanks Given: 731
Thanks Received: 901


atmaweapon View Post
Hello, I have a doubt that I have been thinking about for a while.

I know that if I want to backtest a strategy on futures contract I have to adjust the rollover spread between contacts by "stitching" them together (sometimes called panama adjustment, if I am not wrong), in order to get a continous contract.

But let's say I want to trade the Gasoline / Brent spread, or the gold / silver spread. So, I want a time series that represents the backadjusted spread netween the two legs (the difference or the ratio, it does not matter).
How should I proceed? Should I simply first backadjust the two legs separately and take difference (or the ratio), obviously correctly calibrated (in the case of gasoline/brent I would multiply gasoline by 42 or something, it depend on the case).

Or should I do something else? Do you have an example of the backadjusted gasoline/brent spread to double check?

thank you very much

Gasoline/Brent is an exchanged traded spread. You can get the spread data without having to do any calculations. The NYMEX symbol is RBBZ and ICE Europe its UHUBRN. Unlike futures that have contract specs, quotes etc listed on the exchange website, these crack spreads do not have a dedicated page so its hard to find information but rest assured, they exist and are traded just like the more popular WTI crack spreads.

Spreads listing from TT



Charts of the Mar spreads


For many reasons, you may still want to build your own synthetic spread by using the legs. Brent expires a month before RB for the same contract month so you have a choice as to which months you want to use and when. In this case, I would first convert RB to Crude terms by multiplying RB by 42 as you said. Then you can choose when you want to roll the legs, then "stitch" individual legs and then apply the difference to create the spread time series. The important thing here is to roll both legs on the same date. I would test each one of the following roll strategies and see which one works best for you.

Potential roll strategies:
  • Roll when Brent expires and use the same contract month: In this case, today, you would be using the March contract for both legs. On the last day of January, when Mar brent expires, you would roll both legs to April.
  • Roll when RB expires and use the front months: In this case, today, you would use the Feb RB vs the Mar Brent contract. On the last day of Jan, you roll RB to Mar and Brent to Apr
  • Roll when WTI expires: Depending upon what you are looking for, this is also a valid roll strategy. Liquidity in RB and HO futures is correlated with the WTI front month more than anything. In this case, today, you would be using the March contract for both RB and BZ because the front month for WTI is March. When March WTI expires on 02/21/23, you would roll both RB and brent to April.

Typically, you want to roll 3 days before expiry (when options expire) because thats when liquidity generally rolls over to the next month.

Let me know if there are any questions.

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
atmaweapon
madrid spain
 
Posts: 3 since Dec 2022
Thanks Given: 0
Thanks Received: 1


SMCJB View Post
A

If you just use the unadjusted continuous contract it will look like you should go long this spread every spring and short it every fall. In reality that is mostly a factor of the seasonality/rollovers and not actual price changes.

Thank you very much.
In fact, by looking at the unadjusted RB/BZ spread I could notice some appealing seasonality, but once you backajuast it, it goes away...:-( (also, the backadjusted spread has a strong upward trend)

Attached Thumbnails
Click image for larger version

Name:	image_154.png
Views:	49
Size:	60.8 KB
ID:	329296  
Reply With Quote
  #6 (permalink)
atmaweapon
madrid spain
 
Posts: 3 since Dec 2022
Thanks Given: 0
Thanks Received: 1


Hulk View Post
Gasoline/Brent is an exchanged traded spread. You can get the spread data without having to do any calculations. The NYMEX symbol is RBBZ and ICE Europe its UHUBRN. Unlike futures that have contract specs, quotes etc listed on the exchange website, these crack spreads do not have a dedicated page so its hard to find information but rest assured, they exist and are traded just like the more popular WTI crack spreads.

Thank you, I was aware about the pre-packaged spread contracts, however some broker do not provide them (or I want to create other custum synthetic spreads).


Hulk View Post
The important thing here is to roll both legs on the same date.

I had never though about this, could you please explain me why this is important?


thanks

Reply With Quote
  #7 (permalink)
 
Hulk's Avatar
 Hulk 
Texas, USA
 
Experience: Advanced
Platform: TT, Custom
Trading: Futures, Spreads
Posts: 369 since May 2014
Thanks Given: 731
Thanks Received: 901


atmaweapon View Post

I had never though about this, could you please explain me why this is important?

thanks

It is important to roll on the same date because thats how you would roll your position if you are in a trade. For instance If you are long 1 March RBBZ contract today and you want to keep your length when the Mar contract expires on 01/31, you would sell 1 Mar RBBZ and buy 1 Apr RBBZ, preferably at the same time to prevent any execution loss. When you are backtesting on continuous contract data and your position spans a roll, this is what you would do to actually roll your position. If you are using different dates to roll each leg, how would you actually execute to roll that position? Think about it.

Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,048 since Dec 2013
Thanks Given: 4,381
Thanks Received: 10,205


Hulk View Post
Gasoline/Brent is an exchanged traded spread. You can get the spread data without having to do any calculations. The NYMEX symbol is RBBZ and ICE Europe its UHUBRN. Unlike futures that have contract specs, quotes etc listed on the exchange website, these crack spreads do not have a dedicated page so its hard to find information but rest assured, they exist and are traded just like the more popular WTI crack spreads.

The CME Globex Product Reference Sheet available on the CME Website on this page is very useful. It actually lists every spread type available, but unfortunately even that is difficult to read. A lot of the products listed only trade "over the counter" and not on Globex. For example the Gasoline/Brent Futures spread is line 289 of the spreadsheet. Other liquid energy futures spreads that aren't highly visible unless you know they are there are Brent-WTI, Brent-Heating Oil, Brent-Gasoil (on ICE), WTI-Heating Oil, WTI-Gasoline, Heating Oil-Gasoline, Heating Oil-Gasoil (on ICE). I thought CME also had 2:1:1 cracks (2 WTI vs 1 Heating Oil & 1 Gasoline) as well but I don't seem to be able to find them on that sheet. There's also a bunch of spreads to Oman and Dubai crude but these don't trade on screen much, if at all. Don't think Metals have any similar spreads, and they only ags spread I know of is SOM which is the Implied Soybean Crush. The problem is software like Tradestation won't let you trade these products!

Note: When we say Gasoline in this thread, I believe we actually mean the NYMEX RB contract which is actually a Reformulated Blendstock for Oxygenate Blending contract. RBOB while the a major component of Oxygenated Gasoline is not actually a finished gasoline product itself.

Reply With Quote
Thanked by:




Last Updated on January 22, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts