Hi QC Community
Contango in Futures occurs when the spot prices of further-term contracts are higher than that of nearer-term contracts, adjusted for inflation. It can be considered the Futures yield curve. Contango happens due to rising costs in holding the physical asset, such as storage, insurance, and financing costs. When investors believe these costs are increasing, the demand of using a forward contract to secure the trading price increases.
In this strategy, we try to make a profit from predicting the development of this horizontal spread and monetary inflation. We set our universe to be all gold Futures contracts expiring within 90 days to avoid tying up our fund for too long. Since contango is most likely to happen when the future cost is higher, we set up an SMA of ROC indicator to predict short-term return mean-reversion. When the last return is lower than the trailing mean return, we measure the horizontal spread between each pair of contracts in the universe. We select the pair of contracts that has the lowest horizontal spread, then buy the contract in the pair with the furthest expiry and sell the contract in the pair with the nearest expiry in order to maximize the possibility of mean-reversion.
The strategy successfully yielded a positive return with a 1.28 Sharpe Ratio, but it is likely not translatable into all-weather usage since it has no mechanism to neutralize systematic risk and solely relies on microeconomics. It's recommended to use with a market regime identifier.
The current implementation doesn't evaluate the potential contango chance and size. To improve the strategy, we could set up a calculator for that and an early exit handler to free up invested capital for more opportunities. We might also refine the indicator for future price/contango prediction. One more suggestion would be to construct an efficient portfolio by treating the price difference between a pair of contracts as a single series to obtain a covariance matrix for all pairs. We can thus include more assets and contracts to scale up the investment.
Best
Louis
Manav Trivedi
Excellent strategy Louis, but one thing to ask is - why did you use SMA instead of EMA as the indicator? Plus, the signals generated here can include some noise which is reflected in the low Sharpe over a long run.
Louis Szeto
Hi Manav
Thank you! This algorithm serves as a basic example of this type of strategy. While the predictors are not close to optimum, we encourage you to further engineer to refine and share the results with us!
Best
Louis
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jesso joy
Are we making trade on adjusted price data or raw price data?
Andrea Gazdek
Hi Louis Szeto ,
I have just cloned strategy and run for the periodÂ
but there are only for trades. Were there changes in the API that causes diferent results?
Ashutosh
Hi Andrea GazdekÂ
I implemented the backtest with both the timeframes.
1) 2015-8-1 to 2020-9-1 as set by Louis.
The backtest results and values of performance were nearly almost identical with changes in Sharpe Ratio, Alpha, and Treynor ratios. This is in view of the change made in calculating these ratios more precisely using dynamically adjusted risk-free return. [Reference]
old numbers:
Alpha = 0.046
Sharpe = 1.28
Treynor = -2.501
new numbers:
Alpha = 0.014
Sharpe = 0.382
Treynor = -0.902
2) 2015-8-1 to 2023-9-1
The backtest result produced 174 trades with lower sharpe as expected along the lines of high risk free return environment from 2021-2023 ranging from 0.98%-4.98% (10 year treasury rate)
Â
Â
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Louis Szeto
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!