Skip to content

Instantly share code, notes, and snippets.

@Kazanskyi
Created June 7, 2022 20:44
Show Gist options
  • Save Kazanskyi/ebfec4f03cf69ea483f55c9d4acd1f9b to your computer and use it in GitHub Desktop.
Save Kazanskyi/ebfec4f03cf69ea483f55c9d4acd1f9b to your computer and use it in GitHub Desktop.
VIX volatility data
import pandas as pd
import datetime
from datetime import date
def get_vix(last_date = date.today(), historical_days = 1450):
historical_date = last_date-datetime.timedelta(days=historical_days)
url="https://cdn.cboe.com/api/global/us_indices/daily_prices/VIX_History.csv"
response=pd.read_csv(url)
response["DATE"]=pd.to_datetime(response["DATE"])
response.rename(columns = {"DATE":"date"}, inplace = True)
response.set_index(["date"], inplace = True)
response = response[historical_date:last_date]["HIGH"]
response = response.rename("VIX_high")
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment