Commodity Futures#

1 Stack and Roll#

Use the data in data/futures_data.xlsx

1.1#

The time-series data in futures timeseries has price data on crude oil and gold.

Consider trading…

  • crude oil, CL.

  • on START_DATE of 2025-03-25.

Consider a stack and roll strategy.

  • Suppose on START_DATE an investor buys 100 contracts of the front oil futures, using end-of-day prices, and noting the contract size listed in the futures contracts tab.

  • On the final day of the contract’s reported price, sell the contracts at the listed price. Keep track of the daily profit or loss.

  • Roll into the next contract, buying in at the previous end-of-day (EOD) price.

  • Hold this until the time series ends, rolling into the next contract.

  • At each roll, buy 100 contracts.

  • Continue rolling until the end of the time-series.

Caveat

  • Drop any date where there is no price.

Plot the timeseries of cumulative profit and loss.

  • Do not consider as a loss (profit) the additional capital contributed (withdrawn) at the roll.

Report the mean daily profit as well as the cumulative total.

1.2#

From the tab roll conventions CL, use the series, CL1.

Assume this is a proxy for the stack and roll strategy above.

  • scale it by the contract size (100)

  • calculate the day-over-day differences as profit (loss).

Does it match your answer in 1.1?


2. Margin and Capital#

Reconsider the stack and roll of Problem 1, but this time keep track of the margin account. Assume that…

  • when purchasing the contracts, an initial margin of INIT_MARGIN per contract is paid into the margin account, (not the entire purchase price!)

  • if the margin account goes below LOWER_MARGIN per contract, you must pay additional capital to raise the margin back to LOWER_MARGIN per contract..

  • if the margin account goes above UPPER_MARGIN per contract, you take out the additional capital to lower the margin back to UPPER_MARGIN per contract.

  • at the roll, add in (or take out) capital such that the margin account resets to the initial margin of INIT_MARGIN per contract.

Set

  • LOWER_MARGIN TO 5,000

  • INIT_MARGIN to 6,000.

  • UPPER_MARGIN TO 7,000.

This is a conceptually simple problem, but setting it up correctly in python may be challenging. Consider starting with a spreadsheet.

2.1#

Plot the timeseries of the margin account.

How many times is there a margin call to continue the contract position? (This does not include rolling contracts.)

2.2#

Consider two measures of total return on this strategy.

\[\text{return} = \frac{\text{total profit}}{\text{initial capital}}\]

where we measure the “initial capital” as…

  • total price of the initial 100 contracts paid in 1.1

  • initial margin for the 100 contracts, as calculated in 1.3.

Ignore the fact that additional capital may have been paid in on the rolls.

How does the margin system change the total return?

2.3#

Reconsider the calculation of profit from Problem 1.

When the contract rolls, the investor may need to pay in additional capital to keep the 100 contracts. Consider this a loss.

On the other hand, if rolling into the new contract frees up capital, consider this a profift.

  1. How does this change the total profit (loss)?

  2. How does this change the total return defined above?

  3. Do you think this roll capital should be considered P&L (profit and loss?)