Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
joellewis avatar

Commodities

  • 467 installs
  • 161 repo stars
  • Updated July 18, 2026
  • joellewis/finance_skills

commodities is an agent skill that models commodity futures exposures, margin mechanics, and roll yield for developers scoping fintech portfolios, robo-advice rules, or trading features involving physical and futures mar

About

commodities is a wealth-management plugin skill from JoelLewis/finance_skills, part of a marketplace bundling 84 skills across 7 domain plugins. It explains spot versus futures pricing through the cost-of-carry model, contango and backwardation roll yield effects, and total return decomposition into spot, roll, and collateral yield components. The skill covers energy, metals, agriculture, and livestock sectors plus S&P GSCI and Bloomberg Commodity Index construction differences. Developers reach for commodities when scoping commodity ETFs, inflation hedge features, or explaining why futures-based fund returns diverge from spot price moves. A bundled commodities.py script demonstrates calculations and supports --verify to assert worked examples such as -37.9% annualized roll drag in deep contango.

  • Futures and spot distinctions
  • Margin and leverage risks
  • Roll and contango effects
  • Suitability guardrails
  • Product scoping checklists

Commodities by the numbers

  • 467 all-time installs (skills.sh)
  • +19 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #217 of 1,106 Finance & Trading skills by installs in the Skillselion catalog
  • Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/joellewis/finance_skills --skill commodities

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs467
repo stars161
Last updatedJuly 18, 2026
Repositoryjoellewis/finance_skills

How do you model commodity futures roll yield in fintech?

Model commodity exposures, margin mechanics, and suitability considerations when scoping portfolios, robo-advice rules, or trading features involving futures and physical markets.

Who is it for?

Fintech engineers and quant-adjacent developers designing portfolio, robo-advice, or trading features tied to commodity futures and ETFs.

Skip if: Pure equity SaaS products with no commodity, inflation hedge, or futures market requirements.

When should I use this skill?

A developer asks about contango, backwardation, commodity ETF roll yield, GSCI, BCOM, or oil and gold exposure in a financial product.

What you get

Scoped commodity exposure assumptions, roll yield estimates, and verified cost-of-carry calculations from commodities.py.

  • Commodity exposure assumptions
  • Roll yield and total return estimates
  • Verified commodities.py calculation outputs

By the numbers

  • Parent finance-skills marketplace bundles 84 skills across 7 domain plugins
  • Compares S&P GSCI energy tilt near 60%+ versus BCOM 33% sector and 15% single-commodity caps
  • Worked contango example annualizes roll drag near -37.9% with a 30-day $50 to $52 roll

Files

SKILL.mdMarkdownGitHub ↗

Commodities

Core Concepts

Spot vs Futures Pricing

The futures price is related to the spot price through the cost-of-carry model:

F = S × e^((r + u - y) × t)

where S = spot price, r = risk-free rate, u = storage cost, y = convenience yield, t = time to expiration. The convenience yield represents the benefit of holding the physical commodity (e.g., avoiding production shutdowns).

Contango

When F > S, the futures curve is upward-sloping. Storage costs and financing costs exceed the convenience yield. Contango creates negative roll yield because investors must sell cheaper expiring contracts and buy more expensive later contracts. Contango is common in well-supplied markets and for storable commodities like oil and natural gas.

Backwardation

When F < S, the futures curve is downward-sloping. The convenience yield exceeds storage and financing costs, often due to near-term supply scarcity. Backwardation creates positive roll yield because investors sell expensive expiring contracts and buy cheaper later contracts. Backwardation is common in tight supply environments.

Sources of Commodity Return

Total commodity return has three components:

1. Spot return: Change in the spot price of the commodity 2. Roll yield: Gain or loss from rolling expiring futures into the next contract 3. Collateral yield: Interest earned on the margin/collateral posted to hold futures positions

Total Return = Spot Return + Roll Yield + Collateral Yield

Roll Yield

The gain or loss realized when an expiring futures contract is replaced by a longer-dated contract. In contango (upward curve), roll yield is negative. In backwardation (downward curve), roll yield is positive. Roll yield can be a significant drag or boost to total returns — in deep contango, roll yield can eliminate or even exceed spot price gains.

Commodity Sectors

  • Energy: crude oil, natural gas, gasoline, heating oil — largest sector by production value
  • Precious metals: gold, silver, platinum, palladium — safe haven and industrial uses
  • Industrial metals: copper, aluminum, zinc, nickel — tied to global economic activity
  • Agriculture: corn, wheat, soybeans, coffee, sugar, cotton — weather and harvest dependent
  • Livestock: live cattle, lean hogs — demand-driven

Commodity Indices

  • S&P GSCI: production-weighted, heavily tilted toward energy (~60%+ as of 2024-2025; weights are rebalanced annually, so check the current composition). Represents global commodity production.
  • Bloomberg Commodity Index (BCOM): diversified with sector caps (33%) and single commodity caps (15%). More balanced exposure.
  • Index construction affects returns significantly — energy-heavy indices behave very differently from diversified indices.

Inflation Hedge Properties

Commodities tend to correlate positively with unexpected inflation, making them a potential hedge. The mechanism is direct: rising commodity prices are a component of inflation. However, the hedge is imperfect and works better for supply-driven inflation than demand-driven or monetary inflation.

Seasonality

Agricultural commodities show harvest-related patterns (supply increases at harvest, depressing prices). Energy shows heating/cooling demand patterns (natural gas peaks in winter, gasoline in summer driving season). Seasonality is well-known and partially priced in, but seasonal patterns can still affect futures curve shape.

Key Formulas

FormulaExpressionUse Case
Cost of CarryF = S × e^((r+u-y)×t)Theoretical futures price
Roll Yield (approx)(F_near - F_far) / F_nearReturn from contract rolling
Total ReturnSpot Return + Roll Yield + Collateral YieldComplete commodity return
Annualized Roll Yield((F_near/F_far)^(365/days_between) - 1)Annualized roll impact
Convenience Yieldy = r + u - (1/t) × ln(F/S)Implied convenience yield

Worked Examples

Example 1: Roll Yield in Contango

Given: Front month crude oil futures at $50, next month at $52 (contango), 1-month roll period Calculate: Annualized roll yield Solution: Monthly roll yield = (F_near - F_far) / F_near = ($50 - $52) / $50 = -4.0% This is a 1-month loss of 4.0%. Annualized roll yield ≈ -4.0% × 12 = -48% (simple annualization) Compounded over 12 monthly rolls: (50/52)^12 - 1 = (0.9615)^12 - 1 = -37.5% Using the day-count formula above with a 30-day roll: (50/52)^(365/30) - 1 = -37.9%

This illustrates how severe contango can create enormous roll yield drag. In practice, front-to-second-month contango is rarely this steep, but the example shows why curve shape matters enormously for commodity investors.

Example 2: Total Return Decomposition for a Commodity ETF

Given: Over one year, spot crude oil rises from $70 to $77 (+10%). Roll yield = -6%. Collateral yield (T-bill rate) = 5%. Calculate: Total return of a futures-based commodity ETF Solution: Total Return = Spot Return + Roll Yield + Collateral Yield Total Return = 10% + (-6%) + 5% = 9%

Despite a 10% spot price increase, the futures-based investor earned only 9% due to 6% roll yield drag, partially offset by 5% collateral yield. A physical holder (no roll cost, no collateral yield) would have earned 10%.

Common Pitfalls

  • Confusing spot returns with futures-based returns — most investors access commodities through futures, where roll yield matters
  • Ignoring roll yield drag in contango markets — contango can erode returns substantially over time
  • Commodity ETFs track futures, not spot prices — ETF returns can diverge significantly from spot price movements
  • Storage costs matter for physical but not financial investors — financial investors face roll yield, not storage costs

Cross-References

  • historical-risk: return and risk measurement basics
  • real-assets: physical and collectible commodity ownership (bullion, farmland, timberland). Division of labor: this skill owns gold accessed via futures and the gold-as-safe-haven allocation question; real-assets owns physical/collectible gold ownership and storage
  • currencies-and-fx: commodity currency relationships
  • asset-allocation: commodities as a portfolio diversifier

Running the Script

uv run scripts/commodities.py            # run the demo (uses PEP 723 inline deps)
uv run scripts/commodities.py --verify   # check demo outputs against the worked examples (exit 1 on mismatch)
python3 scripts/commodities.py            # alternative (requires: pip install numpy)

The demo prints the calculations covered above; its values match the worked examples in this skill. Run --help for a list of the classes and functions. For programmatic use, import the module rather than running it — the demo only executes under python commodities.py.

Related skills

How it compares

Use commodities when scoping futures-based commodity exposure; pair with statistics-fundamentals from the core plugin for covariance and regression inputs.

FAQ

Why do commodity ETF returns differ from spot prices?

The commodities skill explains that futures-based investors face roll yield when replacing expiring contracts. In contango, roll yield is negative and can erase spot gains, while collateral yield from margin T-bills partially offsets the drag.

What indices does the commodities skill compare?

The commodities skill contrasts S&P GSCI, which is production-weighted and energy-heavy, with the Bloomberg Commodity Index that caps sectors at 33% and single commodities at 15% for more balanced exposure.

How can developers verify commodities skill calculations?

The commodities skill ships commodities.py runnable via uv run scripts/commodities.py --verify, which checks demo outputs against worked examples such as contango roll yield math and exits nonzero on mismatch.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.