Re: Futures Tradingss - Future Continuations

I am studying you Futures Tradings coourse.  I would like to ask that for the additiive adjustment python code, how can I combine three or more futures contracts in one graph with additive adjustment.    I have tried to amend the code but which is not successful.  Please find my code in the link.

Hey Alan,



The link you've shared is not accessible. Could please share the access?



Thanks

Rushda

Right granted.   Please find the link again.



https://drive.google.com/drive/folders/1oZLf9_c63xeQUkmiI7hAEvLy1upUf_6D?usp=sharing

To combine more than two contracts you need to follow the same process as you did for the first two contracts (defined in the notebook above cell 3).



In the code that you shared, it looks like you have not defined adjustment factor 2. You can do this by getting the difference between the second and third contract (similar to what you did for 1st and 2nd contract)



Hope this helps!

Please find my link again, I have added adjustment factor 2 but still can't plot the additive futures chart to include three futures contract.   Kindly advice.   Thanks!



https://drive.google.com/drive/folders/1oZLf9_c63xeQUkmiI7hAEvLy1upUf_6D?usp=drive_link

After calculating the adjustment factor there are a few more steps that you need to follow:

  • Store the second contract's data in the variable named continuous_futures_by_addition.
  • Add the adjustment factor to the continuous_futures_by_addition till the expiry of the second contract.
  • Append the third contract to continuous_futures_by_addition to get the continuous data.



    Hope this helps :slight_smile:

I have added those steps but didn't work.   Could you please help to amend my code in following link?



https://drive.google.com/drive/folders/1oZLf9_c63xeQUkmiI7hAEvLy1upUf_6D?usp=drive_link

Well done! Looks like you've successfully added the steps and the code is running without any errors.



In case you are getting any FutureWarning for the append() method, you can ignore the same as this is a non-critical warning.



Other than that, if you have any specific issues, do let me know :slight_smile:

Could you please look into my code a bit serious?  



I can't see the third contract in the chart when I tried to visualize with following code:


Define the plot size

plt.figure(figsize=(15, 7))

plt.title('Adjusted Futures Contracts', fontsize=14)

plt.xlabel('Year-Month', fontsize=12)

plt.ylabel('Price', fontsize=12)


Plotting the continous contract

plt.plot(continuous_futures_by_addition)


Show the plot

plt.show()

I re-checked your code and was able to see the third contract (mentioned in your code as: Third Contract - DCE Iron Ore Sep 2021 Futures) on the plot.



Here's a screenshot of the output of the code shared by you. The third contract has been highlighted in red:







If there's any confusion, please let me know I'd be happy to help.

I got it.   Thank you very much!

I have finished the code for adding 9 contracts.  Could you please help to check my code again as follows?



Additive Adjustment (Iron Ore).ipynb - Google Drive



The starting point of my Adjusted Futurres Contracts graph become 0.



 

Hey Alan,



It looks like you've successfully added all the 9 contracts. 



If you have any specific questions regarding this code, please let me know. I'd be happy to help!

The starting point of my Adjusted Futurres Contracts graph become 0.   This is the problem I raised!

Hey Alan,



Usually, when transitioning from one contract to the next, the new contract's price is lower than the previous contract's price on the expiry date. Over an extended period of using additive adjustments, this can result in the starting point of the series becoming negative.



One drawback of the additive adjustment method is that it can lead to a series going negative after multiple adjustments, as you're observing in your code.



To overcome this issue, you might want to consider using a proportional adjustment approach. This is covered in Section 8, Unit 13 of the course. With proportional adjustment, when transitioning from one contract to the next, the first contract's price is adjusted using a ratio, rather than adding a fixed number.



Hope this helps!



Thanks

Rushda

Understood.   Thanks!

Hi,
In case if we have to use Proportionate Adjustment Factor, instead of Additive method, how can we do so if we are analysing data for 12 months to 15 months. Does it mean we have calculate the Factor for each month, like more than 12-15 adjustment factors?

For eg, in the course module, only 2 months data was analysed and only one factor needed to be calculated. However, if I am analysing data for even larger period like 2 -4 years, how will I make adjustments to prices in this case to avoid artificial jumps?

Hi Shalaka,
Yes, for the proportionate adjustment factor method, you calculate an adjustment factor every time the contract rolls to the next one.

So if you analyse 2–4 years of data, you’ll have many factors (one per rollover). Each time you roll, you compute the ratio between the new and old contract price at the roll point, and multiply all the earlier prices by that ratio.

Doing this at every roll keeps the full price series smooth and avoids artificial jumps.

In a nutshell:
You calculate a proportional adjustment factor each time the front contract rolls to the next.
Multiply prior history by each new factor; multi-year series remains smooth despite numerous rollovers.

Hope this helps !