Commodity Term Structure
Get the term structure of a commodity futures curve per day: the front contract, the 12-month calendar spread between the front and the last contract of the 12-month strip that starts with it (in price and in percent), the annualised roll yield and whether the curve is in backwardation, contango or flat.
The far contract is the furthest one delivering less than 12 months after the front: for a December 2026 front of a monthly listed commodity (crude oil, natural gas, the metals) the November 2027 contract, 11 months later, and for corn’s December 2026 front the September 2027 contract, 9 months later.
The formulas are as follows:
Spread = Front - Far Slope = Far / Front - 1 Roll Yield = ln(Front / Far) x 12 / Months
The spread follows the exchange quote of a calendar spread, nearby minus deferred, so it is positive in backwardation, and its widest backwardation is its maximum. The slope is the percentage the far contract lies above the front (negative in backwardation). The roll yield is the annualised log basis of Fama and French (1987) and Szymanowska, De Roon, Nijman and Van den Goorbergh (2014): the continuously compounded yearly return a long position earns from the shape of the curve alone, positive in backwardation and negative in contango, with Months the months between both delivery months.
By default the front of each day is the nearest contract that had not expired on that day (see get_commodity_forward_curve with generic=True), so the spread is a time series of the curve as it stood each day. Yahoo Finance drops a contract once it expires, so on the days whose front has expired since, Front, the Spread, Slope and Roll Yield are NaN while Front Contract names the contract. generic=False instead takes today’s front and far contract on every day (e.g. December 2026 against November 2027 for crude oil): a fixed calendar spread with its full history.
Also known as: calendar spread, roll yield, carry, basis, backwardation, contango.
Commodity Term Structure in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_commodity_term_structure as shown below.
from financetoolkit import Economics
economics = Economics(start_date='2026-10-26', end_date='2026-11-06')
economics.get_commodity_term_structure("Crude Oil")
Or, after setting up the Finance Toolkit MCP, ask:
Was the crude oil futures curve in backwardation or contango from 26 October to 6 November 2026, and what roll yield did that give?
Which returns:
| Date | Front Contract | Front | Far Contract | Far | Months | Spread | Slope | Roll Yield | Structure |
|---|---|---|---|---|---|---|---|---|---|
| 2026-10-26 | 2026-12 | 101.76 | 2027-11 | 81.98 | 11 | 19.78 | -0.1944 | 0.2358 | Backwardation |
| 2026-10-27 | 2026-12 | 99.9 | 2027-11 | 82.07 | 11 | 17.83 | -0.1785 | 0.2145 | Backwardation |
| 2026-10-28 | 2026-12 | 102.78 | 2027-11 | 83.15 | 11 | 19.63 | -0.191 | 0.2312 | Backwardation |
| 2026-10-29 | 2026-12 | 102 | 2027-11 | 82.54 | 11 | 19.46 | -0.1908 | 0.2309 | Backwardation |
| 2026-10-30 | 2026-12 | 104.12 | 2027-11 | 83.01 | 11 | 21.11 | -0.2027 | 0.2472 | Backwardation |
| 2026-11-02 | 2026-12 | 96.46 | 2027-11 | 80.05 | 11 | 16.41 | -0.1701 | 0.2034 | Backwardation |
| 2026-11-03 | 2026-12 | 96.09 | 2027-11 | 80.31 | 11 | 15.78 | -0.1642 | 0.1957 | Backwardation |
| 2026-11-04 | 2026-12 | 88.12 | 2027-11 | 75.32 | 11 | 12.8 | -0.1453 | 0.1712 | Backwardation |
| 2026-11-05 | 2026-12 | 90.52 | 2027-11 | 75.11 | 11 | 15.41 | -0.1702 | 0.2036 | Backwardation |
| 2026-11-06 | 2026-12 | 90.83 | 2027-11 | 76.42 | 11 | 14.41 | -0.1586 | 0.1884 | Backwardation |
Parameters
get_commodity_term_structure accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
commodity | str | list[str] | None | The commodity, or a list of them: “Crude Oil”, “Natural Gas”, “Gold”, “Silver”, “Copper”, “Corn”, “Wheat” or “Soybeans”. Defaults to None, which retrieves every one of them. | "Gold" |
generic | bool | Whether the front and far contract are those of each day’s curve, instead of today’s. Defaults to True. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None. | 2 |