https://www.flickr.com/photos/atlelundhaug/39118797465/in/photolist-22AN4Bg-aWDpB2-f3WZBw-VPZLnc-iWWRPz-aWDo2k-pGjGsw-24nMW3E-6ScMxN-244Vr-8Pr8QZ-MSWXV-6jKP95-4r4jjT-rfbsd-eiAYoT-V7UbQp-H1RyMz-d6SLGs-o7r332-6s1kqQ-7qiGef-6gJvtw-8ZXvCq-6kQ5ya-9NeFek-9AhqzX-7DKz6W-6vNQ7V-oqhMJp-pwPUH-djniVi-5PbdG7-hVGTw-du4XY-6uDW1L-6fj9dT-73afAm-mThGCZ-4rWKGp-bwtpth-boMAtT-37ZafX-oWA3P7-4L3VKa-8FDyyD-qCPS6i-6d5139-uwSXC-nemH1/

Load market data from Quandl

In the previous articles, we loaded market data from CSV files, the drawback is that we’d need to redownload the CSV file every day to get latest data. Why not get them directly from the source ? Quandl is a website aggregating market data from various sources: Yahoo Finance, CBOE, LIFFE among others.

Fortunately for us, Quandl has an API in Python which let you access its data. First of all, you’ll need to get your personal API key here, here is a basic code snippet:

import quandl

quandl.ApiConfig.api_key = 'YOUR_API_KEY'
VIXCode = "CHRIS/CBOE_VX1"

VX1 = quandl.get(VIXCode)

The quandl.get() method returns a Pandas data frame with the dates in the index and open/high/low/close data, this depends on the data source, you may get more information like volume etc.

In conclusion now you can directly work with that data frame, you can merge it with other data, apply some calculations and use it as an input in a machine learning algorithm. The main advantage is that you’ll always get the latest data, no need to redownload a file.