February 27, 2020

A Look at VIX :2020-10-19

Get Some VIX data

NB: I originally wrote this on February 27, 2020 so there is commentary surrounding that date. It was done on the quick for curiosity. I will update it by recompiling it with new data and will update the commentary noting when it took place.

Chicago Board Of Exchange (CBOE) makes data available regularly. To judge the currency of the data, I have tailed it below after converting the dates to a valid date format.

library(tidyverse)
VIX <- read.csv(url("http://www.cboe.com/publish/scheduledtask/mktdata/datahouse/vixcurrent.csv"), skip = 1)
VIX$Dates <- as.Date(VIX$Date,
  format = "%m/%d/%Y")
tail(VIX)
##            Date VIX.Open VIX.High VIX.Low VIX.Close      Dates
## 4223 10/09/2020    26.20    26.22   24.03     25.00 2020-10-09
## 4224 10/12/2020    25.65    25.65   24.14     25.07 2020-10-12
## 4225 10/13/2020    25.67    26.93   25.16     26.07 2020-10-13
## 4226 10/14/2020    25.72    27.23   25.53     26.40 2020-10-14
## 4227 10/15/2020    27.10    29.06   26.82     26.97 2020-10-15
## 4228 10/16/2020    27.16    27.46   26.19     27.41 2020-10-16

The data was straightforward to get a hold of. Now let me plot it. I want to do this with a candlestick plot – a way of displaying intra-day volatility. There’s so much data that the views aren’t great.

library(plotly)
# create the candlestick plot
fig <- VIX  %>% plot_ly(x = ~Dates, type="candlestick",
          open = ~VIX.Open, close = ~VIX.Close,
          high = ~VIX.High, low = ~VIX.Low) 
fig <- fig %>% layout(title = "A Historical Look at VIX")
library(widgetframe)
# Need a frameWidget to render the underlying plotly object
htmlwidgets::saveWidget(
  widgetframe::frameableWidget(fig), here:::here('static/img/widgets/vixfig.html'))

As an overall it has been worse, but keep in mind, that big blip happened TODAY! What does it look like in perspective [keeping in mind that the futures are currently just under 40] since 2012?

fig2 <- VIX %>% filter(Dates > as.Date("01/01/2012", format = "%m/%d/%Y")) %>% plot_ly(x = ~Dates, type="candlestick",
          open = ~VIX.Open, close = ~VIX.Close,
          high = ~VIX.High, low = ~VIX.Low) 
fig2 <- fig2 %>% layout(title = "VIX Since 2012")
htmlwidgets::saveWidget(
  widgetframe::frameableWidget(fig2), here:::here('static/img/widgets/vixfig2.html'))

Day to Day Changes?

I will touch the file about daily to track the evolution.

library(hrbrthemes); library(viridis)
VIX <- VIX %>% mutate(Percent.Change = (VIX.Close - lag(VIX.Close)) / lag(VIX.Close)) 
p <- ggplot(VIX, aes(x=Dates, y=Percent.Change, size=Percent.Change/10, color=Percent.Change)) + 
  geom_point(alpha=0.5, shape=21, inherit.aes = TRUE) +
  scale_size_continuous(range=c(0.05,2), guide=FALSE) +
  geom_line() + 
  geom_smooth(color="orange", method="loess", span=0.05, se=FALSE) + 
  geom_vline(xintercept = as.Date("02/27/2020", format = "%m/%d/%Y"), color="red", alpha=0.2, linetype = "dotted") + 
  geom_vline(xintercept = as.Date("09/12/2008", format = "%m/%d/%Y"), color="red", alpha=0.4) +
  geom_label(data = data.frame(x = as.Date("2008-02-12"),
    y = 0.75, label = "Lehman Brothers"),mapping = aes(x = x, y = y, label = label), size = 3.86605783866058, angle = 0L, lineheight = 1L, hjust = 0.5, vjust = 0.5, colour = "red", family = "sans", fontface = "plain", label.padding = structure(0.25, class = "unit", valid.unit = 3L, unit = "lines"), label.size = 0.25, label.r = structure(0.15, class = "unit", valid.unit = 3L, unit = "lines"), inherit.aes = FALSE, show.legend = FALSE) + 
  scale_color_viridis_c(guide=FALSE) +
  scale_fill_viridis_c(guide=FALSE) +
    theme_ipsum()
fig3 <- ggplotly(p)
htmlwidgets::saveWidget(
  widgetframe::frameableWidget(fig3), here:::here('static/img/widgets/vixfig3.html'))

NB: This commentary was in mid-March. This doesn’t look good. The smooth on a small span is uncomfortably headed upward and today will shock it like no previous day in a very long while.