Hi,
I am trying to do some research using VIX and SPY data but I am having trouble combining the data into a single dataframe, particularly because the time index for VIX includes some sort of time in addition to the date, unlike SPY. I am importing the VIX data like so:
vix = qb.AddData(CBOE, "VIX", Resolution.Daily).Symbol
which obviously differs from the "AddEquity()" method that I use for SPY so perhaps I should not be mixing methods like that.
What I am curious about is if I should be obtaining VIX data in a different way or if I need to change the multi-index dataframe into a single-index dataframe so that the two data sets use the same index. The latter makes me feel like I will be manipulating data in a way Quantconnect did not intend. Any advice would be appreciated.
EDIT: I cant figure out how to attach the research notebook so below is the code (sorry):
from QuantConnect.Data.Custom.CBOE import *
import matplotlib.pyplot as plt
import pandas as pd
qb = QuantBook()
vix = qb.AddData(CBOE, "VIX", Resolution.Daily).Symbol
vix_hist = qb.History([vix], 252)
spy = qb.AddEquity("SPY", Resolution.Daily).Symbol
spy_hist = qb.History([spy], 252)
df = qb.History(qb.Securities.Keys, timedelta(days=252), Resolution.Daily)
df['close'].unstack(level=0).tail()