avatarPiotr Szymanski

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

5966

Abstract

eyword">as</span> pd <span class="hljs-keyword">import</span> seaborn <span class="hljs-keyword">as</span> sns <span class="hljs-keyword">import</span> plotly.graph_objects <span class="hljs-keyword">as</span> go <span class="hljs-keyword">import</span> datetime</pre></div><div id="311a"><pre><span class="hljs-comment">#getting options data for March expiration</span></pre></div><div id="0d58"><pre>VIX= yf<span class="hljs-selector-class">.Ticker</span>(<span class="hljs-string">'^VIX'</span>) VIX<span class="hljs-selector-class">.options</span> option = VIX<span class="hljs-selector-class">.option_chain</span>(VIX<span class="hljs-selector-class">.options</span><span class="hljs-selector-attr">[9]</span>) march_calls = option<span class="hljs-selector-class">.calls</span> march_puts = option.puts</pre></div><div id="0a3a"><pre><span class="hljs-meta">#getting 150 strike out of dataframe</span></pre></div><div id="19fb"><pre>march_calls[march_calls[<span class="hljs-string">'strike'</span>] == <span class="hljs-number">150</span>]</pre></div><div id="b24c"><pre><span class="hljs-comment">#calculating Open Interest ratio for March expiration date </span></pre></div><div id="e9e6"><pre><span class="hljs-attr">march_calls_sum</span> = march_calls[<span class="hljs-string">'openInterest'</span>].sum()</pre></div><div id="d437"><pre><span class="hljs-attr">march_puts_sum</span> = march_puts[<span class="hljs-string">'openInterest'</span>].sum()</pre></div><div id="d571"><pre><span class="hljs-function"><span class="hljs-title">round</span><span class="hljs-params">(march_puts_sum / march_calls_sum, <span class="hljs-number">2</span>)</span></span></pre></div><div id="465e"><pre><span class="hljs-comment">#obtaining maximum Open Interest for puts and call for March expiration date</span></pre></div><div id="8a15"><pre>march_calls[march_calls.openInterest == march_calls[<span class="hljs-string">'openInterest'</span>].max()]</pre></div><div id="d64b"><pre>march_puts[march_puts.openInterest == march_puts[<span class="hljs-string">'openInterest'</span>].max()]</pre></div><div id="a50e"><pre>#getting <span class="hljs-built_in">data</span> for <span class="hljs-literal">all</span> VIX expiration dates </pre></div><div id="e3b9"><pre><span class="hljs-meta">#calls: </span></pre></div><div id="8543"><pre>calls_bucket = <span class="hljs-selector-attr">[]</span> <span class="hljs-keyword">for</span> <span class="hljs-selector-tag">i</span> <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(VIX.options)): option = VIX<span class="hljs-selector-class">.option_chain</span>(VIX<span class="hljs-selector-class">.options</span><span class="hljs-selector-attr">[i]</span>) calls_bucket<span class="hljs-selector-class">.append</span>(option.calls)</pre></div><div id="bec4"><pre><span class="hljs-attr">df_calls</span> = pd.concat(calls_bucket)</pre></div><div id="a415"><pre><span class="hljs-meta">#puts: </span></pre></div><div id="8945"><pre>puts_bucket = <span class="hljs-selector-attr">[]</span> <span class="hljs-keyword">for</span> <span class="hljs-selector-tag">i</span> <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(VIX.options)): option = VIX<span class="hljs-selector-class">.option_chain</span>(VIX<span class="hljs-selector-class">.options</span><span class="hljs-selector-attr">[i]</span>) puts_bucket<span class="hljs-selector-class">.append</span>(option.puts)</pre></div><div id="97a0"><pre><span class="hljs-attr">df_puts</span> = pd.concat(puts_bucket)</pre></div><div id="3091"><pre><span class="hljs-comment">#calculating Open Interest across all expiration dates </span></pre></div><div id="ffe1"><pre>vix_calls_sum = df_calls<span class="hljs-selector-attr">[<span class="hljs-string">'openInterest'</span>]</span><span class="hljs-selector-class">.sum</span>() vix_puts_sum = df_puts<span class="hljs-selector-attr">[<span class="hljs-string">'openInterest'</span>]</span><span class="hljs-selector-class">.sum</span>() <span class="hljs-function"><span class="hljs-title">round</span><span class="hljs-params">(vix_puts_sum/vix_calls_sum, <span class="hljs-number">2</span>)</span></span></pre></div><div id="227f"><pre><span class="hljs-comment">#Generating the VIX Performance chart </span></pre></div><div id="9452"><pre><span class="hljs-attr">df</span> = yf.download(<span class="hljs-string">'^VIX'</span>)</pre></div><div id="277e"><pre>fig = go.Figure<span class="hljs-params">(<span class="hljs-attr">data</span>=[go.Scatter(<span class="hljs-attr">x</span>=df.index, <span class="hljs-attr">y</span>=df['Close'], <span class="hljs-attr">name</span> = 'VIX', <span class="hljs-attr">line</span> = dict(<span class="hljs-attr">color</span> = 'blue', <span class="hljs-attr">width</span> =1)</span>)])</pre></div><div id="e20f"><pre><span class="hljs-attr">mean_stock_price</span> = df[<span class="hljs-string">'Close'</span>].mean()</pre></div><div id="62c1"><pre>fig.add_hline(y=mean_stock_price, <span class="hljs-keyword">line</span> = dict(<span class="hljs-keyword">color</span> = <span class="hljs-string">'red'</span>, <span class="hljs-keyword">width</span> =<span class="hljs-number">2</span>),line_dash = <span class="hljs-string">'dot'</span>)</pre></div><div id="7aff"><pre><span class="hljs-attribute">fig</span>.add_annotation(x=datetime.datetime(<span class="hljs-number">1995</span>,<span class="hljs-number">1</span>,<span class="hljs-number">1</span>).timestamp() * <span class="hljs-number">1000</span>, y=<span class="hljs-number">83</span>,text=f<span class="hljs-string">"Average VIX Level: {round(mean_stock_price, 0)}"</span>, showarrow=False,font=dict(size=<span class="hljs-number">20</span>, color=<span class="hljs-string">"black"</span>, family=<s

Options

pan class="hljs-string">"Courier New, monospace"</span>))</pre></div><div id="1ecb"><pre><span class="hljs-attribute">fig</span>.add_annotation(x=datetime.datetime(<span class="hljs-number">2008</span>,<span class="hljs-number">10</span>,<span class="hljs-number">1</span>).timestamp() * <span class="hljs-number">1000</span>, y=<span class="hljs-number">81</span>,text=<span class="hljs-string">"Great Recession"</span>,showarrow=True, arrowhead=<span class="hljs-number">2</span>,arrowwidth=<span class="hljs-number">2</span>,arrowsize=<span class="hljs-number">1</span>, font=dict(size=<span class="hljs-number">20</span>, color=<span class="hljs-string">"red"</span>, family=<span class="hljs-string">"Courier New, monospace"</span>))</pre></div><div id="6f06"><pre><span class="hljs-attribute">fig</span>.add_annotation(x=datetime.datetime(<span class="hljs-number">2020</span>,<span class="hljs-number">3</span>,<span class="hljs-number">1</span>).timestamp() * <span class="hljs-number">1000</span>, y=<span class="hljs-number">83</span>,text=<span class="hljs-string">"COVID-19 Pandemic"</span>,showarrow=True, arrowhead=<span class="hljs-number">2</span>,arrowwidth=<span class="hljs-number">2</span>,arrowsize=<span class="hljs-number">1</span>, font=dict(size=<span class="hljs-number">20</span>, color=<span class="hljs-string">"red"</span>, family=<span class="hljs-string">"Courier New, monospace"</span>))</pre></div><div id="b3aa"><pre><span class="hljs-attribute">fig</span>.add_annotation(x=datetime.datetime(<span class="hljs-number">2001</span>,<span class="hljs-number">9</span>,<span class="hljs-number">1</span>).timestamp() * <span class="hljs-number">1000</span>, y=<span class="hljs-number">45</span>,text=<span class="hljs-string">"9/11 Attack"</span>,showarrow=True, arrowhead=<span class="hljs-number">2</span>,arrowwidth=<span class="hljs-number">2</span>,arrowsize=<span class="hljs-number">1</span>, font=dict(size=<span class="hljs-number">20</span>, color=<span class="hljs-string">"red"</span>, family=<span class="hljs-string">"Courier New, monospace"</span>))</pre></div><div id="6ca2"><pre><span class="hljs-attribute">fig</span>.add_annotation(x=datetime.datetime(<span class="hljs-number">2011</span>,<span class="hljs-number">8</span>,<span class="hljs-number">1</span>).timestamp() * <span class="hljs-number">1000</span>, y=<span class="hljs-number">45</span>,text=<span class="hljs-string">"US Debt Ceiling Crisis"</span>, showarrow=True, arrowhead=<span class="hljs-number">2</span>,arrowwidth=<span class="hljs-number">2</span>,arrowsize=<span class="hljs-number">1</span>, align=<span class="hljs-string">"left"</span>, yanchor='bottom', font=dict(size=<span class="hljs-number">20</span>, color=<span class="hljs-string">"red"</span>, family=<span class="hljs-string">"Courier New, monospace"</span>))</pre></div><div id="6689"><pre><span class="hljs-attribute">fig</span>.add_annotation(x=datetime.datetime(<span class="hljs-number">2018</span>,<span class="hljs-number">5</span>,<span class="hljs-number">1</span>).timestamp() * <span class="hljs-number">1000</span>, y=<span class="hljs-number">40</span>,text=<span class="hljs-string">"US-China Trade Tensions"</span>,showarrow=True,arrowhead=<span class="hljs-number">7</span>, ax=<span class="hljs-number">0</span>,ay=-<span class="hljs-number">150</span>,font=dict(size=<span class="hljs-number">15</span>, color=<span class="hljs-string">"red"</span>, family=<span class="hljs-string">"Courier New, monospace"</span>))</pre></div><div id="5a01"><pre><span class="hljs-attribute">fig</span>.add_annotation(x=datetime.datetime(<span class="hljs-number">2015</span>,<span class="hljs-number">9</span>,<span class="hljs-number">1</span>).timestamp() * <span class="hljs-number">1000</span>, y=<span class="hljs-number">42</span>,text=<span class="hljs-string">"China's slowdown"</span>,showarrow=True, arrowhead=<span class="hljs-number">7</span>,ax=<span class="hljs-number">0</span>, font=dict(size=<span class="hljs-number">15</span>, color=<span class="hljs-string">"red"</span>, family=<span class="hljs-string">"Courier New, monospace"</span>))</pre></div><div id="2ecc"><pre><span class="hljs-attribute">fig</span>.add_annotation(x=datetime.datetime(<span class="hljs-number">1998</span>,<span class="hljs-number">8</span>,<span class="hljs-number">1</span>).timestamp() * <span class="hljs-number">1000</span>, y=<span class="hljs-number">45</span>,text=<span class="hljs-string">"Global Recession Fears"</span>,showarrow=True,arrowhead=<span class="hljs-number">7</span>,ax=<span class="hljs-number">0</span>, ay=-<span class="hljs-number">150</span>,font=dict(size=<span class="hljs-number">15</span>, color=<span class="hljs-string">"red"</span>, family=<span class="hljs-string">"Courier New, monospace"</span>))</pre></div><div id="eaee"><pre>fig.update_yaxes(<span class="hljs-attribute">title_text</span>=<span class="hljs-string">"Level"</span>)</pre></div><div id="0606"><pre>fig.update_xaxes(<span class="hljs-attribute">title_text</span>=<span class="hljs-string">"Date"</span>)</pre></div><div id="cbf8"><pre>fig.update_layout(<span class="hljs-attribute">title</span>=<span class="hljs-string">"VIX Performance"</span>)</pre></div><div id="8282"><pre>fig.update_layout(<span class="hljs-attribute">height</span>=900, <span class="hljs-attribute">width</span>=1500,</pre></div><div id="7fc1"><pre><span class="hljs-attr">showlegend</span>=<span class="hljs-literal">False</span>)</pre></div><div id="a88a"><pre>fig.<span class="hljs-keyword">show</span>()</pre></div><p id="b8e3">Subscribe to DDIntel <a href="https://ddintel.datadriveninvestor.com/">Here</a>.</p><p id="f23d">Visit our website here: <a href="https://www.datadriveninvestor.com/">https://www.datadriveninvestor.com</a></p><p id="6ef3">Join our network here: <a href="https://datadriveninvestor.com/collaborate">https://datadriveninvestor.com/collaborate</a></p></article></body>

Someone believes that the VIX index will reach 150 by March 2023.

A mysterious trader buys 50,000 VIX call options with a 150 strike expiring in March 2023. Quick study in Python.

Photo by krakenimages on Unsplash

Someone out there believes that the worst is yet to come in the financial markets. An unknown trader purchased 50,000 contracts of VIX call options with a strike of 150, expiring late March 2023, shortly before the market closed on October 6th. Supposedly, each contract at the time of purchase was worth 50 cents, hence the trader spent 2.5 million dollars (50,000 contracts x 100 x .50).

Here it is, please refer to the ‘openInterest’ column.

Sometimes called “fear”, the VIX is the most widely referenced measure of expected near-term stock market volatility. It tracks how much investors are currently willing to pay for volatility in a particular market over the coming 30 trading days, using a weighted average of options contract prices from the S&P 500 index. In other words, VIX is used to help gauge investor sentiment and determine how nervous they are about that asset’s future price movements.

Open Interest refers to a number of contracts that are currently held by traders or investors.

Is it possible for the VIX to reach 150 by the end of March 2023? Well, first, let’s see how the VIX has historically behaved during times of peak volatility and how the majority of traders/investors perceives risk today.

The chart below depicts the historical VIX performance since its inception, as well as the events that resulted in a significant increase in its level. As we can see, the highest point reached by VIX was 82 during the pandemic in 2020, which is comparable to the Great Recession (as a result of the subprime mortgage crisis).

The VIX was nowhere near this high during the current challenging global economic conditions caused by COVID, the Russia-Ukraine conflict, supply chain disruptions, high inflation, fears of a global recession, and risks of financial market dislocation. Perhaps we can say that the VIX index may have gone into hibernation during these severe market declines.

According to below data, the majority of open interest in the late March expiration is concentrated in the 75.0 Call contract, which is exactly halfway between the prediction of the mysterious trade. Most traders base their predictions on the historical level of VIX, which peaked slightly above 80 during previous volatile events.

The put/call open interest ratio for the March expiration date is 0.14, indicating a pessimistic long-term sentiment. The ratio suggests that traders are buying more calls than puts, speculating that the VIX will remain elevated.

If we look at the overall put/call open interest ratio across all expiration dates, it equals to 0.35. Slightly higher but still fairly pessimistic.

And which strikes currently have the most open interest across all expiration dates?

Call Strike with highest open interest
Put Strike with highest open interest

Interestingly, many traders believe that the VIX will reach a 50-level by November 16th, indicating that the VIX is about to wake up. Others believe that in less than two weeks, the VIX will fall to 25 strike by October 19th, implying that the VIX will continue to hibernate. At the time of writing, the VIX is trading around the 31-point mark. We should also mention that some of these positions may have been part of strategy trades in which both sides (put and call) were traded — skewing the open interest ratio between put and call in this comparison.

So, will the enigmatic trader be correct? Although it seems unlikely, anything is possible in the financial markets. In the past, there have been some extreme anomalies that everyone thought would never happen.

It is extremely likely that this trade was a part of some hedging strategy.

Thank you for reading.

Disclaimer: The information contained in this blog post is strictly for educational and entertainment purposes only. This is also not an investment advice. All views expressed in this blog are my own and do not represent the opinions of any entity whatsoever with which I have been, am now, or will be affiliated.

#PYTHON CODE 
#importing all libraries
pip install yfinance
import yfinance as yf
import pandas as pd
import seaborn as sns
import plotly.graph_objects as go
import datetime
#getting options data for March expiration
VIX= yf.Ticker('^VIX')
VIX.options
option = VIX.option_chain(VIX.options[9])
march_calls = option.calls
march_puts = option.puts
#getting 150 strike out of dataframe
march_calls[march_calls['strike'] == 150]
#calculating Open Interest ratio for March expiration date 
march_calls_sum = march_calls['openInterest'].sum()
march_puts_sum = march_puts['openInterest'].sum()
round(march_puts_sum / march_calls_sum, 2)
#obtaining maximum Open Interest for puts and call for March expiration date
march_calls[march_calls.openInterest == march_calls['openInterest'].max()]
march_puts[march_puts.openInterest == march_puts['openInterest'].max()]
#getting data for all VIX expiration dates 
#calls: 
calls_bucket = []
for i in range(0, len(VIX.options)):
    option = VIX.option_chain(VIX.options[i])
    calls_bucket.append(option.calls)
df_calls = pd.concat(calls_bucket)
#puts: 
puts_bucket = []
for i in range(0, len(VIX.options)):
    option = VIX.option_chain(VIX.options[i])
    puts_bucket.append(option.puts)
df_puts = pd.concat(puts_bucket)
#calculating Open Interest across all expiration dates 
vix_calls_sum = df_calls['openInterest'].sum()
vix_puts_sum = df_puts['openInterest'].sum()
round(vix_puts_sum/vix_calls_sum, 2)
#Generating the VIX Performance chart 
df = yf.download('^VIX')
fig = go.Figure(data=[go.Scatter(x=df.index, y=df['Close'], name = 'VIX', line = dict(color = 'blue', width =1))])
mean_stock_price = df['Close'].mean()
fig.add_hline(y=mean_stock_price, line = dict(color = 'red', width =2),line_dash = 'dot')
fig.add_annotation(x=datetime.datetime(1995,1,1).timestamp() * 1000, y=83,text=f"Average VIX Level: {round(mean_stock_price, 0)}", showarrow=False,font=dict(size=20, color="black", family="Courier New, monospace"))
fig.add_annotation(x=datetime.datetime(2008,10,1).timestamp() * 1000, y=81,text="Great Recession",showarrow=True, arrowhead=2,arrowwidth=2,arrowsize=1, font=dict(size=20, color="red", family="Courier New, monospace"))
fig.add_annotation(x=datetime.datetime(2020,3,1).timestamp() * 1000, y=83,text="COVID-19 Pandemic",showarrow=True, arrowhead=2,arrowwidth=2,arrowsize=1, font=dict(size=20, color="red", family="Courier New, monospace"))
fig.add_annotation(x=datetime.datetime(2001,9,1).timestamp() * 1000, y=45,text="9/11 Attack",showarrow=True, arrowhead=2,arrowwidth=2,arrowsize=1, font=dict(size=20, color="red", family="Courier New, monospace"))
fig.add_annotation(x=datetime.datetime(2011,8,1).timestamp() * 1000, y=45,text="US Debt Ceiling Crisis", showarrow=True, arrowhead=2,arrowwidth=2,arrowsize=1, align="left", yanchor='bottom', font=dict(size=20, color="red", family="Courier New, monospace"))
fig.add_annotation(x=datetime.datetime(2018,5,1).timestamp() * 1000, y=40,text="US-China Trade Tensions",showarrow=True,arrowhead=7, ax=0,ay=-150,font=dict(size=15, color="red", family="Courier New, monospace"))
fig.add_annotation(x=datetime.datetime(2015,9,1).timestamp() * 1000, y=42,text="China's slowdown",showarrow=True, arrowhead=7,ax=0, font=dict(size=15, color="red", family="Courier New, monospace"))
fig.add_annotation(x=datetime.datetime(1998,8,1).timestamp() * 1000, y=45,text="Global Recession Fears",showarrow=True,arrowhead=7,ax=0, ay=-150,font=dict(size=15, color="red", family="Courier New, monospace"))
fig.update_yaxes(title_text="Level")
fig.update_xaxes(title_text="Date")
fig.update_layout(title="VIX Performance")
fig.update_layout(height=900, width=1500,
showlegend=False)
fig.show()

Subscribe to DDIntel Here.

Visit our website here: https://www.datadriveninvestor.com

Join our network here: https://datadriveninvestor.com/collaborate

Python
Trading
Finance
Stock Market
Data
Recommended from ReadMedium