Created
June 7, 2022 20:44
-
-
Save Kazanskyi/ebfec4f03cf69ea483f55c9d4acd1f9b to your computer and use it in GitHub Desktop.
VIX volatility data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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