Course12 Lessons

Futures & Commodities Trading for Programmers

A fundamentals-to-slightly-advanced course on futures and commodities trading for programmers: what a future is, the linear payoff, cost-of-carry pricing and basis, contango vs backwardation, the commodity universe (NSE index/stock futures + MCX bullion/energy/metals), margin, daily mark-to-market and leverage, rollover and term structure, directional strategies, spreads and arbitrage, hedging, risk and position sizing, the data/broker-API tooling stack (and the continuous-contract trap), and building a simple futures algo. Real cost-of-carry, margin and roll numbers, Python you can run, Indian (NSE/MCX, SPAN margin, STT/CTT) context. Educational only.

Start Course arrow_forward
Futures & Commodities Trading for Programmers

This is the third course in the trading-for-programmers set, alongside Options Trading and Crypto Options & Algo Trading. Futures are, in a sense, the simplest derivative — a plain, linear bet on price with no premium and no Greeks — which makes them a clean thing to automate. But that same simplicity hides real teeth: leverage, daily cash settlement, and the quiet mechanics of rollover and term structure that have wiped out many traders who thought “just buy the future and hold” was a strategy. We will cover both the simplicity and the teeth, for programmers, with real numbers.

A serious note up front — please read it. This is educational material, not financial advice and not a recommendation to trade. Futures are leveraged (often ~8× or more), marked to market in cash every day, and can lose far more than an option’s premium — a big adverse move or an overnight gap is a big, real loss, and margin calls can force you out at the worst time. Most retail derivatives traders lose money. Learn first, paper-trade, size tiny, and treat not blowing up as the goal. All numbers are illustrative examples.

Futures and Commodities Trading for Programmers course roadmap, twelve lessons. 1 why futures for coders: leverage, hedging, speculation and the techie edge. 2 futures basics: long and short, contract specs, the linear payoff. 3 pricing and basis: cost of carry, basis, contango versus backwardation. 4 the commodity universe: MCX bullion, energy and metals plus index and stock futures. 5 margin, mark-to-market and leverage: SPAN margin, daily settlement, about 8x leverage. 6 rollover and term structure: expiry, rolling, roll yield, the contango bleed. 7 directional strategies: trend following, breakout, mean reversion. 8 spreads and arbitrage: calendar, inter-commodity crack spread, cash-and-carry. 9 hedging, the real purpose: jeweller, airline, farmer, hedger versus speculator. 10 risk and position sizing: leverage, gaps, limit up or down, margin calls. 11 data and tooling stack: continuous contracts, broker APIs, backtesting. 12 build a futures algo: signal to risk to order to mark-to-market to roll, end to end.

Why futures suit a programmer

A future has a linear, 1:1 payoff — no option Greeks, no volatility surface, no premium decay. That makes the maths refreshingly simple: your P&L is just (exit − entry) × lot size, settled in cash. For automation, that simplicity is a gift. The complexity that does exist is mechanical and very learnable: cost-of-carry pricing (why a future sits a little above or below spot), margin and daily mark-to-market (why a losing position bleeds cash in real time), and rollover (why holding a future past expiry quietly costs or pays you, depending on the term structure). Get those three right and futures are a clean, powerful instrument to build systematic strategies on — across NSE index/stock futures and MCX commodities.

We ground everything in real numbers you can reproduce: a Nifty one-month future’s fair value of 24,138 (basis +138) from the cost of carry; ~8.3× leverage on a ₹18-lakh contract against ~₹2.16-lakh margin; a ₹15,000 daily mark-to-market credit on a 200-point move; and a ~7.6%/year “contango bleed” on a rolled long. Then we build up strategies, hedging, risk and a simple algo.

What this course covers

# Lesson What you will learn
1 Why Futures (for Coders) Leverage, hedging, speculation; the mindset
2 Futures Basics Long/short, contract specs, the linear payoff
3 Pricing & Basis Cost of carry, basis, contango vs backwardation
4 The Commodity Universe NSE index/stock futures + MCX bullion/energy/metals
5 Margin, MTM & Leverage SPAN margin, daily mark-to-market, ~8× leverage
6 Rollover & Term Structure Rolling, roll yield, the contango bleed
7 Directional Strategies Trend following, breakout, mean reversion
8 Spreads & Arbitrage Calendar, inter-commodity (crack), cash-and-carry
9 Hedging Jeweller, airline, farmer; hedger vs speculator
10 Risk & Position Sizing Leverage, gaps, limit up/down, margin calls
11 Data & Tooling Stack Continuous contracts, broker APIs, backtesting
12 Build a Futures Algo Signal → risk → order → MTM → roll, end to end

It is written in plain Indian English with a working engineer in mind, grounded in real cost-of-carry and margin numbers, and every lesson ends with the pitfalls and a quick recap. After reading it you should understand futures and commodities properly — basics and a fair bit of the advanced — and be able to build small, safe systematic tools around them.

Start with Lesson 1: Why Futures (for Coders).

For related material, see the Options Trading for Programmers course, the Low-Latency Trading Systems course, the algo trading vocabulary, and the strategy articles on moving-average crossover, mean reversion and momentum/trend-following.

Curriculum