OPEN-SOURCE SCRIPT
Futures Forward Price [NeoButane]

In futures markets, the theoretical value of a futures contract can be derived from its underlying price and cost of carry. By baking in the costs and potential yields, the theoretical forward price then be used in basis against futures prices in place of the underlying spot price.
Usage
The script creates plots on the main chart and a separate window pane. Both are meant to be used to visualize dislocations in the market.
By using a futures vs. forward basis instead of futures vs. spot basis, discounts in the market are clearer.

Last month, the gold futures market GCZ2025 traded >1% above forward price when tariffs were announced and fell back in line once the tariffs were verbally retracted.

View roll spreads over a back-adjusted continuous chart. I guess. I don't think spread traders only look at one chart. This is as educational for me as it is you.

Configuration
The underlying reference needs to be changed to match the futures contract you are using.
The Risk-Free Rate defaults to FRED:SOFR. I found the contract month matched 3-Month SOFR Futures to be the closest for forward price.
The following are meant to be used with the continuous formula as they are compounded. However the rate sources don't differ much for the purpose of futures prices.
3-Month CME SOFR Futures
3-Month ICEEUR SONIA Futures
3-Month Osaka TONA Futures
The other rate sources are either meant for futures contracts shorter than quarterly such as monthly crypto futures or were meant to help myself understand how different rates would align with futures prices, like inflation.
What this script does
It uses the cost of carry formula to output the forward price (red line). The underlying reference (green line) is plotted alongside and a futures-derived reference (blue line) can be displayed to see how it looks next to the real reference price.
The data pane displays either the nominal difference or percentage difference between the real futures price and the calculated forward price.
Further reading
investopedia.com/terms/f/forwardprice.asp
cmegroup.com/education/files/understanding-stock-index-futures.pdf
oxfordenergy.org/wpcms/wp-content/uploads/2021/08/Is-the-Oil-Price-Inflation-Relationship-Transitory.pdf
www-2.rotman.utoronto.ca/~hull/TechnicalNotes/TechnicalNote24.pdf
cmegroup.com/education/articles-and-reports/trading-comex-gold-and-silver.html
3-month rate futures
cmegroup.com/education/files/sofr-futures-contract-specifications.pdf
ice.com/interest-rates/short-term-interest-rate-futures/sonia-futures
bankofengland.co.uk/markets/transition-to-sterling-risk-free-rates-from-libor
jpx.co.jp/english/derivatives/products/interest-rate/3m-tona-futures/index.html
Usage
The script creates plots on the main chart and a separate window pane. Both are meant to be used to visualize dislocations in the market.
By using a futures vs. forward basis instead of futures vs. spot basis, discounts in the market are clearer.
Last month, the gold futures market GCZ2025 traded >1% above forward price when tariffs were announced and fell back in line once the tariffs were verbally retracted.
View roll spreads over a back-adjusted continuous chart. I guess. I don't think spread traders only look at one chart. This is as educational for me as it is you.
Configuration
The underlying reference needs to be changed to match the futures contract you are using.
The Risk-Free Rate defaults to FRED:SOFR. I found the contract month matched 3-Month SOFR Futures to be the closest for forward price.
- Risk-Free Rate: The interest rate source for forward price.
- Constant Risk-Free Rate: a static interest rate that can be used in advance of future changes in risk-free rate.
- Underlying Reference: spot or index price. Some examples include TVC:SPX, TVC:GOLD, CRYPTO:BTCUSD, TVC:USOIL.
- Forward Price Compounding: determines which formula to use. They're similar and become closer as the contract matures.
- Alternative Contract: enable and select a futures contract to use it on a chart different than the main.
- Storage Cost and Yield: for use with commodities. I haven't found a proper use for them yet but enabling is simple if you are able to.
The following are meant to be used with the continuous formula as they are compounded. However the rate sources don't differ much for the purpose of futures prices.
3-Month CME SOFR Futures
3-Month ICEEUR SONIA Futures
3-Month Osaka TONA Futures
The other rate sources are either meant for futures contracts shorter than quarterly such as monthly crypto futures or were meant to help myself understand how different rates would align with futures prices, like inflation.
What this script does
It uses the cost of carry formula to output the forward price (red line). The underlying reference (green line) is plotted alongside and a futures-derived reference (blue line) can be displayed to see how it looks next to the real reference price.
The data pane displays either the nominal difference or percentage difference between the real futures price and the calculated forward price.
Further reading
investopedia.com/terms/f/forwardprice.asp
cmegroup.com/education/files/understanding-stock-index-futures.pdf
oxfordenergy.org/wpcms/wp-content/uploads/2021/08/Is-the-Oil-Price-Inflation-Relationship-Transitory.pdf
www-2.rotman.utoronto.ca/~hull/TechnicalNotes/TechnicalNote24.pdf
cmegroup.com/education/articles-and-reports/trading-comex-gold-and-silver.html
3-month rate futures
cmegroup.com/education/files/sofr-futures-contract-specifications.pdf
ice.com/interest-rates/short-term-interest-rate-futures/sonia-futures
bankofengland.co.uk/markets/transition-to-sterling-risk-free-rates-from-libor
jpx.co.jp/english/derivatives/products/interest-rate/3m-tona-futures/index.html
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
My published indicators: tradingview.com/u/NeoButane/
Sorry if I haven't replied to your message yet, I'm a bit backlogged :)
Sorry if I haven't replied to your message yet, I'm a bit backlogged :)
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
My published indicators: tradingview.com/u/NeoButane/
Sorry if I haven't replied to your message yet, I'm a bit backlogged :)
Sorry if I haven't replied to your message yet, I'm a bit backlogged :)
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.