Sitemap
Image Source: https://www.pexels.com/photo/iconic-parthenon-temple-under-bright-blue-sky-32138599/

Greeks with Python

7 min readMay 21, 2025

Introduction:

Options are popular products in the trading books of banks, financial institutions, asset managers and individual investors too. Just like any position on the trading book, market participants use a variety of tools for measurement and management of risk of the options book. Popular measures of risk include Value at Risk, expected shortfall, greeks etc.

In this article, we focus on:

· Options greeks and learn their definition and properties,

· Know the formulas for each one of them

· Python model for estimating greeks of a sample option position.

What and why of greeks:

For a plain vanilla option, the functional form of the option price is given as below:

V = f (S ,K ,T ,r ,σ)

Where, V: option price; S: underlying asset price (we assume stock price); K: strike price; T: time to maturity; r: risk free rate; σ: volatility

Thus, we observe that option price is a function of 5 parameters mentioned on the right-hand side of the above equation. Therefore, it’s natural to ask how each of these independent parameters would impact the option price. This gives rise to the idea of option greeks. Further, as many of you may have guessed, mathematically, this will involve computing partial derivatives of the option price with respect to each of these parameters individually.

Greeks

In this article, we will discuss the following most frequently used greeks.

· Delta

· Theta

· Rho

· Vega

· Gamma

Delta:

Delta is a first order Greek. Delta explains the change in price of an option w.r.t the change in the underlying.

Where ∆: Is delta of the option

V: option price

S: underlying price

Delta is a linear measure of sensitivity of option price to the underlying. Delta may be estimated at a point by allowing a small change in the stock price and then plotting a slope line at that point to estimate delta.

Range of delta: A long call option delta moves between [0,1]. A long put option delta moves between [-1,0].

Delta hedging:

The concept of delta hedging is one of the building blocks for understanding the fundamental concepts for option pricing models including binomial, Black Scholes etc. Deltah hedging along with other concepts like Ito’s and no-arbitrage help in derivation and a thorough understanding of option pricing models.

Delta hedging may be done in two ways:

Static delta hedging: Create a delta hedged position and leave it that way. We do not attempt to rebalance our position by trading options and/or the underlying. This is like a “create and forget strategy”.

Dynamic delta hedging: Dynamic delta hedging implies that we continuously delta hedge our position by trading options and the underlying.

However, a delta hedged position remains that way only for a very short period of time. This is because, the delta position is very sensitive to the changes in the underlying price and the way the option price responds to this change in the underlying. Therefore, there is a need to trade the option and underlying at frequent intervals of time to maintain a delta hedged position. However, this comes at a cost because every time we transact in the market we have to pay certain transaction costs. Therefore, the market participants decide for themselves as to how frequently they wish to delta hedge their portfolios. Generally, market participants delta hedge their positions at the end of the trading day. However, in times of market stress, delta hedging may be done more frequently during the trading day.

Delta for Calls and Puts:

Gamma:

Gamma is a second order Greek. Gamma explains the rate of change of delta

Where ϒ : Is gamma of the option

V: option price

S: stock rate

From the equation of gamma above, it is viewed as the sensitivity of option price to change in delta.

Hedging gamma:

For hedging gamma, one needs to trade options. Gamma of a portfolio cannot be hedged by trading the underlying shares. This is because, the underlying shares being cash instruments have no impact on the gamma of the portfolio. Therefore, to hedge/manage the gamma of a portfolio, one has to trade options. For example, assume a fund manager wishes to hedge gamma of an existing delta hedged portfolio. He will have to trade options to hedge his gamma position. Doing this, however, will disturb the delta hedge of his portfolio, as a result he will have to trade the underlying shares to re-adjust his delta hedge.

Sign of the gamma:

Long option positions contribute a positive gamma. Short options positions contribute a negative gamma. Gamma is highest for options that are at the money.

Gamma and passage of time:

As the time to expiration draws nearer, the gamma of at-the-money options increases while the gamma of in-the-money and out-of-the-money options decreases.

Volatility impact on gamma:

When volatility is low, the gamma of at-the-money options is high while the gamma for deep in or out-of-the-money options approaches 0. This phenomenon arises because when volatility is low, the time value of such options are low but it goes up substantially as the underlying stock price approaches the strike price.

When volatility is high, gamma tends to be stable across all strike prices. This is due to the fact that when volatility is high, the time value of deep in/out-of-the-money options are already quite substantial. Thus, the increase in the time value of these options as they go nearer the money will be less dramatic and hence the low and stable gamma.

Theta:

Theta is a first order Greek. Theta explains the change in price of an option w.r.t time.

Where Ɵ : theta of the option

V: option price

t: time

Theta is the sensitivity of option price to time. Time is one parameter which will continue to move even if we hypothetically assume that all other market parameters are constant. Theta thus measures the time decay of an option. With passage of time, the option value is expected to decay because, as the option moves closer to its time to maturity, the probability that an out of the money option may end up in the money goes on decreasing. As the probability of the option giving a positive payoff decreases, so does the option price.

Sign of theta:

Long option positions contribute to a negative theta.

Short options contribute to a positive theta.

Rho:

Rho is a first order Greek. Rho explains the change in price of an option w.r.t interest rate.

Where Ƿ : rho of the option

V: option price

r: interest rate

Rho is the sensitivity of option price to interest rate.

Impact of rho on option price: It is observed that the call option price increases and Put option price decreases with the rise in interest rates.

Vega:

Vega is a first order Greek. Vega explains the change in price of an option w.r.t the volatility.

Vega is the sensitivity of option price to change in implied volatility.

Life of the option and its effect on vega:

The more residual time to maturity of the option, the higher the vega. This is because as time value makes up a larger proportion of the premium for longer term options and it is the time value that is sensitive to changes in volatility, the vega is higher.

Strike price’s effect of vega:

The strike price of an option can also affect the amount of vega it has. More precisely, the relative closeness of the strike price to the spot price is what matters. Options that are very far out-of-the-money tend to have little or no vega. But at-the-money options are far more sensitive to changes in implied volatility. Higher volatility greatly increases their chances of moving in-the-money, so their value is sensitive to changes in implied volatility i.e. they have more vega.

Hedging vega:

Just like gamma, vega is also a very important Greek which has a high impact on the option price. Vega hedging of a portfolio is also done by trading options.

Python implementation of the greeks:

Option greeks can be solved numerically using techniques like finite differences. This will, however, involve some programming effort. Fortunately, Python with its rich set of libraries allows a quick implementation of greeks. Below given is the implementation of option greeks using Python:

The above implementation is for equity option greeks using the BSM model. However, the above Python library also supports the implementation of FX option greeks using the Garman-Kohlhagen model too.

Greeks are an important area of risk management and trading. A good understanding of options greeks including a few higher order greeks is beneficial for applications on industry projects, as well as for potential job interviews that one may be appearing for.

Thank you for reading. Hope you enjoyed it!

****

--

--

No responses yet