Options Trading with Black Scholes Derivative Model

Options Trading with Black Scholes Derivative Model

Article Overview

In the current expansive realm of global financial markets, the Black and Scholes model retains significant relevance. It is definitely one of my favorite financial models and mastering Black and Scholes provides unique insights to the world of volatility, trading and even macroeconomic dynamics. Employing its intricate mathematical framework, the Black-Scholes model offers unparalleled insights into the nuanced dynamics of option pricing amidst the complex world of modern financial markets.

In addition, programming languages like Python are becoming pivotal to capture and leverage opportunities in the finance world as the activity volumes reach unprecedented levels. Although aspiring finance professionals might find themselves at the crossroads of traditional theory and cutting-edge modern applications, there are better ways to harvest the best of both worlds and become highly successful in finance. Why not merge both approaches and benefit from the significant advantages of edge-cutting tools while masterfully applying proven finance concepts? 

I’ve been successfully using Black and Scholes model for years on a daily basis in my own finance and trading career and I put together this informative article which gradually builds on the legendary Black and Scholes concept and its implementation with Python.

Table of Contents

  1. Major Insights
  2. Introduction to Black and Schole
    1. Long-Term Capital Management (LTCM)
    2. Noble Prize Recognition
  3. Black & Scholes Formula
  4. Black & Scholes: Python Code
    1. Option Examples with Black & Scholes Model
    2. Validation of Python Black & Scholes results
    3. Interpretation Python Black & Scholes of results
    4. Black and Scholes Model with Python code
  5. Financial Derivatives: Use Cases
  6. Summary

 

 

Major Insights

  • Python is a highly performant and powerful technology for aspiring finance professionals
  • Derivatives are powered by the Black & Scholes formula which won its inventors the Nobel prize.
  • Black & Scholes is highly utilized in financial firms and insurance companies in financial hubs all over the world including Wall Street and Canary Wharf.
  • You can significantly improve your chances of recruitment and/or promotion by leveraging the synergies between a technological tool like Python and a fundamental financial concept like Black & Scholes (option pricing) Formula.        

 

Introduction to Black and Scholes

The journey of Fischer Black and Myron Scholes, the two co-founders of the Black-Scholes option pricing model, is intertwined with the evolution of modern finance theory and the increasing role of computation in financial modeling. 

Fischer Black (1938-1995) was an American economist and finance scholar born in Washington, D.C. He obtained his Ph.D. in economics from Harvard University in 1964 and worked as an assistant professor at the University of Chicago's Graduate School of Business. 

Myron Scholes (1941-present) is a Canadian-American economist born in Ontario, Canada. He completed his Ph.D. in economics from the University of Chicago in 1969 and later became a professor at the Stanford Graduate School of Business.

The publication of the Black-Scholes model in 1973 coincided with significant advancements in computation and information technology. At that time, mainframe computers were becoming more accessible to researchers and financial institutions.

Initially, the calculations required for the Black-Scholes model were complex and time-consuming, making manual calculations impractical. However, with the increasing availability of computers, the model became more usable and led to a surge in options trading and risk management activities.

As technology continued to advance, personal computers became prevalent in the 1980s, allowing individual traders and investors to use the Black-Scholes model for making financial decisions.

 

Long-Term Capital Management (LTCM):

In 1994, Fischer Black was a founding partner of Long-Term Capital Management (LTCM), a hedge fund that aimed to capitalize on quantitative strategies based on options pricing and other financial models. Myron Scholes joined LTCM as a consultant.

LTCM attracted significant attention due to its highly leveraged positions and complex financial strategies. Initially, the fund experienced remarkable success, but its strategies eventually faced challenges during the Russian financial crisis of 1998.

 

Nobel Prize Recognition:

In 1997, Fischer Black, Myron Scholes, and Robert Merton were jointly awarded the Sveriges Riksbank Prize in Economic Sciences in Memory of Alfred Nobel (commonly known as the Nobel Prize in Economics) for their contributions to option pricing theory. Unfortunately, Fischer Black had passed away in 1995 and was awarded the prize posthumously.

The Nobel committee recognized their groundbreaking work on the Black-Scholes option pricing model, which had revolutionized the understanding of derivatives and had a profound impact on financial markets and risk management practices.

 

The advent of the internet in the 1990s and the subsequent proliferation of online trading platforms further democratized financial markets and made computational tools, including the Black-Scholes model, more accessible to a broader audience.

Today, we have the tools to scrape options data, implement quantitative trading strategies powered by Python and Black and Scholes, deploy machine learning algorithms to gain further insight and access low-cost trading and brokerage service

 

Number of futures and options contracts traded worldwide from 2013 to 2022 (in billions)

The chart above shows the unprecedented surge in number of option and future trading contracts which has cumulatively climbed from 21.5 billion in 2013 to 83.85 billion in 2022, almost a quadruple increase in less than 10 years.

Black & Scholes Formula

We will start developing our models using Python. But first, let’s get familiar with the theoretical aspects of the formula. You don’t have to memorize the advanced mathematical phenomenon here but it can be very beneficial to have an understanding of what kind of input we are feeding to the model and how and why it has an impact in the price calculation of an option.

 

The formula for the Black-Scholes option pricing model is as follows:

 

 

Where:

 

  •     C is the theoretical call option price.
  •     S is the current stock price.
  •     X is the option's strike price.
  •     r is the risk-free interest rate (annualized, continuously compounded).
  •     T is the time to option expiration (expressed in years).
  •     N(d) is the cumulative standard normal distribution function.
  •     d1​ and d2​ are parameters used in the calculation.

 

The two parameters d1​ and d2​ are given by the following formulas:

 

 

  • ln represents the natural logarithm.
  • σ is the volatility of the underlying stock's returns.

 

 

For the put option pricing, we have a similar but different formula that uses the negative values of the normal distribution variables. While mathematical notation can be alienating to some finance students and professionals without a strong mathematics background, everything will become a little more practical when we start plugging in numbers to the Python model.

The Black-Scholes model provides a method to calculate the fair price of options (both call and put options) by taking into account various factors like: 

  • the stock price, 
  • strike price, 
  • time to expiration (or maturity), 
  • risk-free interest rate,
  • volatility. 

However, the formula requires the use of a cumulative standard normal distribution function, which involves complex mathematical calculations. Before the widespread use of computers, these calculations were cumbersome and time-consuming, making it impractical to calculate option prices manually. 

In the next section we will craft a Black and Scholes model using Python step-by-step. We will also discuss the advantages of using a modern programming tool such as Python compared to the more traditional approach such as Spreadsheets and Macros.

 

Black & Scholes: Python Code

Option Examples with Black & Scholes Model                                   

The primary purpose of the Black-Scholes model is to calculate the theoretical value of options. This is achieved by considering factors such as the current stock price, the option's strike price, the time to expiration, the expected volatility of the stock's price, the risk-free interest rate, and the type of option (call or put).

A call option is a financial contract that gives the holder the right, but not the obligation, to buy an underlying asset (such as a stock).

A put option is a financial contract that gives the holder the right, but not the obligation, to sell an underlying asset.

 Call options increase in value while the underlying asset increases in value and put options increase in value while the underlying asset decreases in value. In short, you can think of an option as a lottery ticket, the value of the ticket increases and decreases based on the likeliness of a positive outcome. It can go as low as 0.00001 cents and as high as 100s of dollars based on the likeliness of outcomes at a given time.

Call and put options can be a bit confusing so let’s make a few examples to demonstrate real life scenarios.

OpenBB is a state of the art open-sourced finance terminal built with Python. It only makes sense to use a financial data aggregator powered by Python while building our Black and Scholes model with Python.

 Please note this article is being written in early August 2023. This will be important to observe different option values with different times left to expiry.

 

Example 1: Tesla, Call Option

Data source: OpenBB stocks/options/ -> load TSLA / -> exp 2023-01-19 / chains

 

  • Expiry: 19 Jan 2024
  • Strike: $270
  • Underlying Asset: Tesla Stock
  • Underlying Price: $249.60
  • Option Price: $25.30

 

Let’s discuss the real world example above. We have a call option that costs $25.30. The option expires in approximately 4 months (160 days).

 

Three things can happen on the date of expiry:

 

  1. Tesla stocks trade above $270
  2. Tesla stocks trade at $270
  3. Tesla stocks trade below $270

 

Can you tell which scenarios would be profitable if you bought this option today?

 

Let’s emphasize once again that the call option gives a right to buy the underlying asset at a predefined price (strike). Would you buy Tesla stocks at $270 if Tesla was trading at $250 in the exchange (spot market)?

 

What if Tesla engineers invented an extremely special battery within 4 months and its shares skyrocketed to $2500. Would you now exercise your right to buy Tesla shares at $270 as your option offers?

 

What would be the value of your option if the former scenario where Tesla trades at $250 on the expiry day is true?

 

Let me answer all of those questions in one short summary:

 

The option’s value would be zero in all scenarios except when Tesla shares trade above $270. In any other scenario, option holder simply wouldn’t exercise their right to purchase at $270. (Although not directly comparable, you can think of an option that has expired worthless as a lottery ticket that didn’t win anything. It would be worth absolutely nothing after the prize draw day.) On the other hand, $295.30 (Strike+money paid for option) is the level where option holder would break even (sometimes referred to as the breakeven price). Above this level, option holder would start profiting.

 

Example 2: IBM, Call Options, 

Data source: OpenBB stocks/options/ -> load IBM / -> exp 2023-09-01 / chains

 

  • Expiry: 01 Sep 2023 Expiry
  • Underlying Asset: IBM Stock
  • Underlying Price: $143.30
  • Option Price: Various options will be analyzed.

 

Let’s discuss our next real world example with a few new factors in mind. Firstly, its time to maturity is much lower. From the first week of August to September, approximately 15 business days are remaining before these options expire.

How do you think a much lower time left to maturity will impact the option price calculations? Will the option be cheaper or more expensive? What if we were looking at put options? How would they be affected price-wise?

 

Again, there is a straightforward answer to all of these questions. Understanding the logic behind option pricing can be very helpful in your theoretical mastery as well as practical applications. As the time to maturity approaches, options get cheaper and cheaper every day regardless of them being call options or put options. Ceteris paribus, time passing will lower the value of options. 

 

This makes perfect sense because a lower time window means lower likelihood of big price movements in desired directions. If you have 2 days left before your options expire, you can guess that it’s quite unlikely something huge will happen to the underlying asset in those 2 days. But if your options expire in 2 years, there are so many global and individual factors that might cause massive price differences. Because of this phenomenon, you will observe some options with distant strike prices from underlying asset’s spot price (deep out of money) converging to zero in value as the maturity approaches. Similarly, options will be very expensive when they have very far expiry dates. This effect of the maturity window should always be kept in mind.

 

Let’s look at various options with different strike prices for the factors provided in the beginning of this example.

 

 

 

All options have the same maturity of 01 Sep 2023 with the underlying asset IBM. You can observe how the deep out of money call option has lost almost all of its value and is trading at $0.02. If you purchased this option at such a low price and if IBM stocks rallied to $160 in the next few days your option would likely surpass $3 in value (an approximate 150X return). This is the leverage effect of option returns. But if they expire out of money, then you lose all of the investment as they will be worth zero as discussed in the first example.



Example 3: Microsoft, Put Options, 

Data source: OpenBB stocks/options/ -> load MSFT / -> exp 2025-12-19 / chains

 

  • Expiry: 19 Jan 2025 Expiry
  • Underlying Asset: Microsoft Stock
  • Underlying Price: $322.90
  • Option Price: Various options will be analyzed.

 

Let’s look at real market data of a put option chain based on Microsoft shares. We will check out some extreme cases this time. Also note we have chosen a very distant expiry date which is expected to increase option values whether they are call options or put options.

 

 

Let’s look at the first option. It gives you the right to sell (put option) Microsoft shares at $125. But MSFT is trading at $322.90 and you wouldn’t sell it at $125 since you can sell at the spot market for much higher. Although the option is significantly out of money and it’s likely to expire worthless on 19-12-2025, it is still trading at $2. If the global markets were to collapse, if the tech industry were to suffer significant losses or if Microsoft got involved in a serious law case that put the company’s future in jeopardy, there is a chance this option could be worth much higher than its current $2 trading value.

 

On the other end of the spectrum we see a deep in the money option with a strike price of $510. This option last traded at $174.78. Let’s decode this price a little more and transition to our Black and Scholes model from there. Selling MSFT sales at $510 is a great right to have when Microsoft is trading at $322.90 but it comes at a hefty cost. If we subtract 322.90 from 510 we get $187.1. Options have two types of values, one that comes from the speculative opportunities based on the time left and other factors called option’s time value and the other is its intrinsic value which is the absolute difference between its strike price and the underlying asset price when the option is in the money. Intrinsic value and time value make up the combined price of an option. While intrinsic value is easy to calculate with basic algebra, time value is a lot more complex and can be calculated using the Black and Scholes model.

 

Example 4: Black and Scholes Model with Python code

Now that we have some understanding of Black and Scholes and options as well as different factors that affect their pricing, we will build a simple Black and Scholes model with Python. Although basic, this model can handle so much and has been used for multiple decades at the most prestigious trading firms and banks.

 

Our model will employ a handy science library named scipy and its norm module. Additionally, we will use Python’s native math library and its modules log, sqrt and exp. Finally we will source some financial data using openbb_terminal.sdk library and openbb module in our code.

 

Nvidia is a very exciting stock which represents a company that has been super well-positioned for the AI revolution. Artificial intelligence models require powerful GPU technologies in their training and Nvidia is the main supplier of edge-cutting, AI-optimized hardware to the whole world including tech giants such as Microsoft, Oracle, Google and Amazon.

 

                        Let’s import the libraries which we will use first


from openbb_terminal.sdk import 
openbb
from match import log, sqrt, exp
from scipy.stats import norm

We can then assign input variables for our Black and Scholes model. d1 represents the standardized measure of how far the current stock price is from the strike price, accounting for volatility and time to expiration. 


S = 408.50
K = 430
T = 23/252
r = 0.05
sigma = 78/100

d1 = (log(S/K)+(r+sigma**2/2.)*T)/(sigma*sqrt(T))
d2 = (d1-sigma*sqrt(T))

Finally we can calculate the call and put prices and print them. We will also form the cumulative distribution function of the standard normal distribution and essentially calculate the probability that the option will expire in-the-money. This is a critical part of the option price calculation.

 


Call_price = S*norm.cdf(d1)-X*exp(-r*T)*norm.cdf(d2)
Put_price = X*exp(-r*T)*norm.cdf(-d2)-(S*norm.cdf(-d1))

print(('Call:{}, Put:{}'.format(Call_price, Put_price)))

Call: 30.224401385317407, Put: 49.766570468667

 

We have priced a call option and a put option using Python and the Black and Scholes model. Finance students, researchers and analysts can use similar systems to build much more sophisticated and elaborate finance tools which can deliver lots of value.

 

In the past, I have created a volatility arbitrage model that used a similar model as above and scanned thousands of options to signal price anomalies for the portfolio managers at global banks and hedge funds. While similar methods can be applied in Excel spreadsheets to some extent, it would mean a lot less liberty when it comes to communicating with other systems such as databases, brokerage APIs and machine learning models. Spreadsheets also take a lot longer to process models and they have significant limitations once data gets large. Worry not, as you can see Python is not that scary and you can tap into many useful finance tutorials powered by Python at PiFy.com and earn lots of money and prestige with your desirable quantitative finance skills.

 

Now that we have some results, let’s try to validate those results and see if our model is actually consistent with real world finance data.

 

Validation of Python Black and Scholes results

Data source: OpenBB stocks/options/ -> load NVDA / -> exp 2023-10-20 / chains


df=openbb.stocks.options.chains("NVDA", expiration="2023-10-20")
df=df.loc[df['strike']==430]
print(df)

When we look at the Nvidia option chain at OpenBB Open-source finance terminal, we can find call and put options with 20 Oct 2023 expiry. These options are priced as following: 

 

 

Prices our model calculated were   Call: $30.22 and Put: $49.76.  We can conclude that market data is confirming the accuracy of our model so far. It must be noted that Robert Merton also left his signature in the Black Scholes model by proving the impact of dividend payments. He was in the Nobel prize winning team for the model and hence it’s often referred to as Black-Scholes-Merton model today. In an ideal case it would be beneficial to advance the model with Merton additions to make it more accurate which can be a great next step.

 

Interpretation of Python Black and Scholes results

 

In example 3, we discussed how time to maturity always makes options more valuable. More time means more chances for wild price movements to happen. Volatility has the same impact on options as higher volatility signals higher chances of price swings in the market. We can see that despite relatively low time left to maturity Nvidia options were priced quite high due to their high price volatility.

 

Finally, risk free interest rate affects option prices as well but it’s slightly more complicated. If interest rates are higher, the cost of holding cash (an alternative to investing in the underlying asset) increases. As a result, investors may be more inclined to buy call options to benefit from potential price appreciation of the underlying asset. So interest rates have positive correlation with call options.

 

On the other hand, when interest rates are higher, the opportunity cost of holding the underlying asset increases. The relationship between higher interest rates and the opportunity cost of holding the underlying asset impacts the pricing of put options. Put options provide downside protection – they allow the option holder to sell the underlying asset at a predetermined price (strike price) if the asset's value decreases. When interest rates are higher and the opportunity cost of holding the asset is greater, investors might be more willing to hold the asset itself rather than purchasing put options for protection. This decreased demand for put options can lead to lower option prices.

 

Also note that, risk free rate is usually accepted as the interest rate of the most liquid United States government bond such as yearly interest rate of 10-year US gov bond or 2-year US gov bond. This concept may be challenged in the future since the global economy has transitioned from its previous US dominant position and the US government itself is facing serious issues due to its accumulated debt position. Something to keep in mind in the ever-evolving financial landscape.

 

Financial Derivatives: Use Cases in Finance

Financial derivatives are used in many branches of finance other than speculative option trading. That’s a good reason why an aspiring finance student or a junior finance professional can benefit from mastering Black and Scholes concepts and be able to get a high-paying job in one of the finance fields mentioned below.

 

  • Asset Management: Asset managers use the Black-Scholes model to analyze and value options in their portfolios. By understanding the fair value of options, they can make informed decisions about whether to buy, sell, or hold these positions. This helps asset managers optimize their portfolios’ outcomes and generate returns while managing risk.

 

  • Arbitrage Desks: Arbitrage desks take advantage of price discrepancies between options and their underlying assets. The Black-Scholes model is essential for determining whether an option is mispriced relative to the underlying asset. If an option is deemed undervalued or overvalued based on the model's calculations, arbitrageurs can execute trades to capitalize on the price difference. By using a sophisticated tool such as Python, traders can analyze thousands of options in a few seconds and make sophisticated bets based on those quantitative strategies.

 

  • Insurance: Insurance companies use options and derivatives for managing the risks caused by their insurance exposure from selling insurance policies. The Black-Scholes model aids insurers in valuing these derivatives accurately, allowing them to set appropriate premiums for offering risk protection. It also helps insurers assess the potential impact of market fluctuations on their derivative holdings.

 

  • Risk Management - Equity Position Hedging: Investors and corporations often hold equity positions that are exposed to market fluctuations. Using the Black-Scholes model, they can calculate the cost of hedging these positions with options. By purchasing put options, for instance, they can limit potential losses if the market experiences a downturn, effectively insuring their portfolio against adverse price movements.

 

  • Currency (FX) Exposure: International corporations (for example a global dairy producer or textile manufacturer) with foreign exchange (FX) exposure can use currency options to mitigate the impact of currency fluctuations on their operations. The Black-Scholes model helps these companies assess the cost of implementing currency hedges and the potential outcomes under different market scenarios.

Summary

Decades after its initial publication, Black and Scholes model is still widely used in financial institutions, investment firms, and trading desks today. Its use is facilitated by advanced financial scripts that are coded with Python and similar modern programming languages and platforms that perform complex calculations rapidly, enabling real-time pricing and risk management that give traders the necessary competitive edge.

The complete code and data sets for this project can be found on the PyFi GitHub page.

Do you have a favorite financial asset to test your own Black and Scholes model on? If you do that can be a great opportunity to take your new skills to the next level and don’t forget, practice makes perfect!

 

Written by Umut Sagir, MSc Finance

Back to blog