Pricing Commodity Options with Python

Ameya Abhyankar
4 min readDec 22, 2021


Globally, the options market is huge. Options trade on both: Organized Exchanges and the much bigger Over the Counter (OTC) market. Further, this derivative product can have any asset as the underlying. When I say any asset, it means that once the counterparties to the options contract agree on using a certain underlying asset to a certain option contract, the trade goes through. A few popular asset classes that act as underlying to options are equity, currency, interest rates, credit, commodities etc. Generally, when we read / hear about people discussing options, they tend to speak more about options on financial assets i.e., non-commodity options. The reason being the volume of options that trade on financial assets is far bigger as compared to options on commodities. For example, if we observe the trading portfolio of any bank in India, you will observe that they hold large positions in options linked to FX, however, they may just hold a one-off contract / none pertaining to commodity options.

However, for one to have a holistic view of options as a product, it is beneficial to know about commodity options too. There are certain properties that are unique to commodity options including: the underlying asset, model used for valuation of such options etc. This article has been structured such that the first half of the article discusses the concept of options on commodity futures, the Black76 model for pricing such options, whereas the second half of the article explores an approach of building an option pricing model using Python.

A brief background of pricing equity options:

It will be good to have a quick recap of equity options and subsequently discuss how commodity options are different from them.

Most of us are familiar with equity options. The Black Scholes Merton (BSM) model is the most popular model for pricing equity options. Further, we are familiar with the Geometric Brownian Motion (GBM) that is used for modelling equity assets which can be subsequently consumed by BSM model for options pricing. The popular stochastic differential equation for stock price diffusion is given as

dS = r * S * dt + Ϭ * S * dW

where dS: random increments in the stock price;

r: risk free rate

dt: small time step

Ϭ: volatility

dW: the Weiner process

Also, the closed form solutions for pricing call and put options using BSM are given by formulas:

Further, the above formulas may be tweaked a bit to price options on FX too.

This recap of equity options should help us understand the key difference while pricing commodity options

Understanding Commodity options pricing:

The underlying asset for commodity options are commodity futures prices. We do not use the spot price of commodity as the underlying for commodity option. One of the reasons for using futures prices is that the futures market on commodities is very active, as a result we have liquid price quotes available for consumption in the model. As a result of this, we cannot use the popular BSM model for pricing commodity options. We use another model that was devised by Fischer Black in 1976 for modelling futures prices which is the Black76 model.

The asset price process followed is:

dF(t) = Ϭ(t) * F(t) * dW


dF: random asset price increment

Ϭ: volatility

F: Futures price

dW: the Weiner process

If we compare this equation with the equation for equities, we observe that there is no spot price term used here. The reason for not using spot price is mentioned above.

Further, below are the closed form solutions for options on commodities:

Comparing these with the equity options, we observe that we use the Futures prices to calculate the prices of call and put options. Further, Black76 model requires a continuously compounded interest rate for pricing such options. Further, exercising the commodity options contract will give the option holder a position in the underlying futures contract.

Black76 model implementation in Python:

We attempt to develop a valuation model for commodity options using Python.

  1. Import the required libraries:
import QuantLib as ql
import math

2. Model input parameters

interest_rate = 0.005
calc_date = ql.Date(23,10,2021)
DCC = ql.ActualActual()
Compounded = ql.Compounded
continuous = ql.Continuous
T = 1.
strike = 50
spot = 48
volatility = 0.45
option_type = ql.Option.Call

3. Black76 model computation

yield_curve = ql.FlatForward(calc_date,interest_rate,DCC,Compounded,continuous)
df =
opt_payoff = ql.PlainVanillaPayoff(option_type, strike)
std = volatility*math.sqrt(T)
black = ql.BlackCalculator(opt_payoff, spot, std, df)

4. Outputs (Option Price and Greeks)

print("Option Price", black.value())
print("Gamma", black.gamma(spot))
print("Theta", black.theta(spot, T))
print("Vega", black.vega(T))
print("Rho", black.rho(T))

Through this article we have explored an approach for valuing options with commodity futures as the underlying. We have leveraged the power of Python for rapid prototyping our model. Python can similarly be used for other applications including risk modelling, stress testing, scenario analysis, regulatory capital models etc. Organizations globally are moving their legacy models to Python to reap the benefits of using a robust open-source technology to strengthen their technology infrastructure to help them reach their strategic goals.