Know Your Options
Option Trading Strategies in Python
An investment portfolio includes different securities such as stocks, bonds, commodities and currencies. Another type of investment are the options. Options are a choice to trade in the underlying security. When you trade in stock options, you dont buy or sell the stocks. You just buy or sell the option to buy or sell the stocks at a fixed price on a certain fixed date. In the year 1973 the Chicago Board of Options Exchange (CBOE) was formed. In the same year, Fisher Black and Myron Scholes devised a mathematical formula that could calculate the price of an option using specified variables. This had a major impact on option trading. Today the average daily traded volume of option contracts are nearly 15 million. Options are more complex than other financial instruments and can be very risky, expecially if you dont know what you are doing. In this articel we will start to have a look the basic concepts of options: call and put. We will start with the option buyer and seller payoff and the volatility which has a strong impact on options. The Black-Scholes formula will help us understand the pricing of an option. We have a closer look at the mathematics behind the formula and then apply it to real option data to get the greeks.
1. Payoff Functions
Payoff functions are key to understanding the profit (and loss) that we’ll receive upon purchasing an option or options. They are typically designed so that you can view the strike price on the purchased (or sold) option, as a function of the underlyings price.
1.1. Call
Buying a call option gives you the right, but not the obligation to buy the underlying security at the given strike price, within a specific time period. A call option payoff at expiration depends on where the underlying price is relative to the call option strike price.
What do you observe?
- The loss to the call option buyer is restricted to the extent of the premium he has paid.
- The profit from this call option seems to increase linearly as and when the stock price starts to move above the strike price. Therefore, the higher the spot price goes from the strike price, the higher is the profit.
- Though the call option is supposed to make a profit when the spot price moves above the strike price, the call option buyer first needs to recover the premium he has paid.
The option buyer makes the profit, the option seller will lose the exact same amount and vice-versa.The call option seller payoff looks like a mirror image of the call option buyer payoff.
1.2. Put
Buying a put option gives you the right, but not the obligation to sell the underlying security at the given strike price, within a specific time period. A put option payoff at expiration depends on where the underlying price is relative to the put option strike price.
What do you observe?
- The loss to the put option buyer is restricted to the extent of the premium he has paid.
- The profit from this put option seems to increase linearly as and when the stock starts to move below the strike price. Therefore, the higher the spot price goes from the strike price, the higher is the profit.
- Though the put option is supposed to make a profit when the spot price moves below the strike price, the put option buyer first needs to recover the premium he has paid.
Again the call option seller payoff looks like a mirror image of the call option buyer payoff.
2. Volatility
Options prices depend crucially on estimated future volatility of the underlying asset. Volatility can either be historical or implied.
2.1. Historical vs. Implied Volatility
While the historical volatility shows the past volatility of the stock price, the implied volatility (IV) measures the market’s expected best guess of future volatility of the underlying.
Many times the volatility changes with changes in the strike price — the higher the difference between strike and the underlying price, the higher the volatility. This phenomenon is called the Volatility Smile (refer to the chart below)
3. Option Analysis
To set up a virtual environment and run a Jupyter-Notebook I recommend you use Anaconda.
- https://docs.anaconda.com/anaconda/install/windows/
- https://docs.anaconda.com/anaconda/install/mac-os/
- https://docs.anaconda.com/anaconda/install/linux/
3.1. Black-Scholes-Merton Model
Is a financial instrument to determine the price of vanilla Europrean options. To determine the price of vanilla Europrean options we use the Black-Scholes-Metron formula.
The Black-Scholes-Merton Formula for a Vanilla Call Option:
With:
- S the spot price of the asset at time t.
- T the maturity of the option. Time to maturity is defined as T−t.
- K the strike price of the option.
- r the risk-free interest rate, assumed to be constant between t and T.
- sigma the volatility of underlying asset.
- N the normal distribution.
3.2. The Greeks
The greeks are the partial-derivatives of the Black-Scholes equation with respect to each variable. Greeks are closed-form formulas that represent the sensitivity of the option to the different underlying parameters.
3.2.1. Delta
Delta is the option´s sensitivity to small changes in the underlying price.
Delta Mathematical Proof
According to:
We have:
Finally:
3.2.2. Gamma
Gamma is the Delta’s sensitivity to small changes in the underlying price.
Gamma Mathematical Proof
3.2.3. Theta
Theta is the option’s sensitivity to small changes in time to expiry.
Theta Mathematical Proof
3.3. Options Data
Basic Definitions:
ITM (In-The-Money): An option is ITM if it is currently worth exercising today i.e. for a call option the current underlying’s price is greater than the strike price (vice versa for a put).
OTM (Out-Of-The-Money): An option is OTM if it is currently not worth exercising today.
Underlying: This refers to the asset which underlies the derivative contract.
To calculate the greeks we use the QuantLib modul.
Now we get the call and put options for Apple.
Lets filter the call and put options.
3.3.1. Options Volatility Smile
The Black-Scholes-Merton model assumes that the underlying volatility (𝜎) is constant over the life of the option and stays unaffected by changes in the underlying stock price levels. Many times the volatility changes with changes in the strike price. The higher the difference between strike and the underlying price, the higher the volatility. This phenomenon is called the Volatility smile.
3.3.2. Visualize Options Data
4. Analyse Multiple Options
4.1. The Bid-Ask Spread
4.1.1. Bid-Ask Spread Percentage
Sources:
- https://quantlib-python-docs.readthedocs.io/en/latest/instruments.html#vanilla-options
- http://samples.leanpub.com/quantlibpythoncookbook-sample.pdf
- https://i.investopedia.com/inv/pdf/tutorials/OptionVolatility.pdf
- https://clinthoward.github.io/portfolio/2017/04/16/BlackScholesGreeks/
- https://github.com/yhilpisch/dawp/blob/master/python36/B_DAWP_Chs_5_6_7.ipynb
- https://github.com/borisbanushev/anomaliesinoptions/blob/master/anomaly_inoptions.ipynb
- https://quantra.quantinsti.com/startCourseDetails?cid=57§ion_no=1&unit_no=1#course_type=paid&unit_type=Video
- https://www.blackarbs.com/blog/exploring-our-scraped-options-database/8/7/2017
- https://colab.research.google.com/drive/1NSCsxBvhIZuZu6aHcP3qLPEciBokmuWO?usp=sharing
- http://www.smileofthales.com/computation/option-greeks-python-math-proof/