# Options lose value every day: Measure it with Theta decay

# Options lose value every day: Measure it with Theta decay

Options trading can be tricky, especially when dealing with time decay. Misunderstanding it can lead to losing money since options lose value over time. Many traders try holding onto options too long and end up watching their profits evaporate.

Time decay is a silent profit killer.

I've faced this issue myself. Once I figured out how time decay impacts options value, I started selling credit spreads and making consistently profitable trades. I used Python with QuantLib to value the options, compute Theta, and analyze it.

By reading today's newsletter, you'll learn how to measure time decay effectively.

Let's go!

## Options lose value every day: Measure it with theta decay

Understanding Theta and time decay is key in options trading. Theta measures the daily decline in an option's price as it nears expiration. This decline, known as time decay, impacts options' value because they have a finite lifespan.

Options with longer expiration periods decay more slowly. Options with shorter expirations decay rapidly. Factors such as volatility and moneyness also influence Theta. High volatility can slow time decay, while at-the-money options decay the fastest.

Professionals use strategies like selling options to profit from time decay. Calendar spreads exploit different decay rates by combining options with varying expirations. Managing expiration dates and considering volatility are also crucial tactics.

Let's see how it all works with Python.

### Import necessary QuantLib modules and set up the option parameters

We'll start by importing QuantLib and setting up the basic parameters for our option, such as the expiry date, strike price, and underlying asset price.

```
1import QuantLib as ql
2import matplotlib.pyplot as plt
3
4# Define option parameters
5expiry_date = ql.Date(15, 6, 2023)
6strike_price = 100
7spot_price = 105
8volatility = 0.2
9risk_free_rate = 0.01
10dividend_yield = 0.02
11
12# Set up the QuantLib calendar and day count convention
13calendar = ql.UnitedStates(ql.UnitedStates.NYSE)
14day_count = ql.Actual365Fixed()
15
16# Create the QuantLib objects for the option
17exercise = ql.EuropeanExercise(expiry_date)
18payoff = ql.PlainVanillaPayoff(ql.Option.Call, strike_price)
19option = ql.VanillaOption(payoff, exercise)
```

We start by importing the necessary QuantLib module. Then, we define various parameters like the expiry date, strike price, and spot price of the underlying asset. The volatility, risk-free rate, and dividend yield are also specified.

We set up the QuantLib calendar for the United States and use the Actual365Fixed day count convention. Finally, we create QuantLib objects for the option, including the exercise type and payoff type.

### Create the market environment and the Black-Scholes process

Next, we'll create the market environment by setting up the interest rate curve, the dividend yield curve, and the volatility surface. We'll then define the Black-Scholes process.

```
1# Create the interest rate curve
2risk_free_rate_handle = ql.YieldTermStructureHandle(ql.FlatForward(0, calendar, ql.QuoteHandle(ql.SimpleQuote(risk_free_rate)), day_count))
3
4# Create the dividend yield curve
5dividend_yield_handle = ql.YieldTermStructureHandle(ql.FlatForward(0, calendar, ql.QuoteHandle(ql.SimpleQuote(dividend_yield)), day_count))
6
7# Create the volatility surface
8volatility_handle = ql.BlackVolTermStructureHandle(ql.BlackConstantVol(0, calendar, ql.QuoteHandle(ql.SimpleQuote(volatility)), day_count))
9
10# Create the Black-Scholes process
11spot_handle = ql.QuoteHandle(ql.SimpleQuote(spot_price))
12bs_process = ql.BlackScholesMertonProcess(spot_handle, dividend_yield_handle, risk_free_rate_handle, volatility_handle)
```

We create the interest rate curve by defining a flat forward curve with the given risk-free rate. Similarly, we create the dividend yield curve using a flat forward curve with the specified dividend yield. The volatility surface is created using a constant volatility term structure. We then define the Black-Scholes process by combining the spot price, dividend yield, risk-free rate, and volatility.

### Calculate the option theta and plot it over time to expiration

In this section, we will calculate the theta of the option for different times to expiration and plot the results.

```
1# Define the range of days to expiration up until 15 days
2days_to_expiry = range(365, 15, -1)
3
4# Container for theta values
5theta_values = []
6
7# Calculate theta for each day
8for days in days_to_expiry:
9 expiry_date = calendar.advance(ql.Date().todaysDate(), ql.Period(int(days), ql.Days))
10 exercise = ql.EuropeanExercise(expiry_date)
11 option = ql.VanillaOption(payoff, exercise)
12
13 # Set up the pricing engine
14 engine = ql.AnalyticEuropeanEngine(bs_process)
15 option.setPricingEngine(engine)
16
17 # Calculate theta
18 theta = option.theta() / 365
19 theta_values.append(theta)
```

We define a range of days to expiration. We then create an empty list to store theta values. For each day in the range, we advance the expiry date accordingly and create a new exercise and option object.

Finally, we plot the theta values against the days to expiration using Matplotlib.

```
1# Plot the theta values
2plt.figure(figsize=(10, 6))
3plt.plot(days_to_expiry, theta_values, label='Theta')
4plt.xlabel('Days to Expiration')
5plt.ylabel('Theta')
6plt.title('Option Theta over Time to Expiration')
7plt.gca().invert_xaxis()
8ticks = range(365, 15, -50)
9plt.xticks(ticks)
10plt.show()
```

The result is a plot showing the value of Theta accelerating. This reduces the options value as it gets closer to expiration.

### Your next steps

Try changing the parameters of the option, such as the strike price or volatility, and observe how the Theta values change. You can also experiment with different types of options, such as put options, to see how their Theta behaves over time. This will help you get a deeper understanding of how option Greeks are influenced by various factors.