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
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
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 :)
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
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 :)
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.