A sample code to show how to get historical data for VIX
How to Get VIX Historical Data
This sample code demonstrates how to retrieve VIX historical data from Interactive Brokers if you have a VIX subscription at IB. Learn how to use IBridgePy to access volatility index data for your trading strategies.
The function of superSymbol ( ) is to define the security.
data.history ( ) has the same signature as the same function at Quantopian.
def initialize(context): context.sec=superSymbol(secType='IND',symbol='VIX',currency='USD', exchange='SMART', primaryExchange='CBOE') def handle_data(context, data): print (data.history(context.sec, ['open', 'high', 'low', 'close'], 5, '1d')) end()
The following shows how to get historical VIX data obtained on Aug 28th 2017
open high low close 2017-08-22 12.60 12.94 11.35 11.35 2017-08-23 11.51 12.59 11.39 12.25 2017-08-24 12.06 12.83 11.55 12.23 2017-08-25 12.20 12.45 11.10 11.28 2017-08-28 11.51 11.77 10.56 10.56
