Skip to content

Instantly share code, notes, and snippets.

@shotahorii
Last active May 21, 2017 23:04
Show Gist options
  • Save shotahorii/a375147c1eeb1f6ada0bc06aec0e416a to your computer and use it in GitHub Desktop.
Save shotahorii/a375147c1eeb1f6ada0bc06aec0e416a to your computer and use it in GitHub Desktop.
Getting started with Quandl
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Getting Started with Quandl\n",
"\n",
"- API call limits found here: http://help.quandl.com/article/68-is-there-a-rate-limit-or-speed-limit-for-api-usage\n",
"- Documentation found here: https://docs.quandl.com/docs"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import quandl\n",
"import json"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# set my api key\n",
"with open('./apikey.json') as f: \n",
" quandl.ApiConfig.api_key = json.load(f)['apikey']"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# get historical data of Facebook stock price\n",
"data = quandl.get_table('WIKI/PRICES', ticker='FB', paginate=True)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>ticker</th>\n",
" <th>date</th>\n",
" <th>open</th>\n",
" <th>high</th>\n",
" <th>low</th>\n",
" <th>close</th>\n",
" <th>volume</th>\n",
" <th>ex-dividend</th>\n",
" <th>split_ratio</th>\n",
" <th>adj_open</th>\n",
" <th>adj_high</th>\n",
" <th>adj_low</th>\n",
" <th>adj_close</th>\n",
" <th>adj_volume</th>\n",
" </tr>\n",
" <tr>\n",
" <th>None</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>FB</td>\n",
" <td>2012-05-18</td>\n",
" <td>42.05</td>\n",
" <td>45.00</td>\n",
" <td>38.00</td>\n",
" <td>38.2318</td>\n",
" <td>573576400</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>42.05</td>\n",
" <td>45.00</td>\n",
" <td>38.00</td>\n",
" <td>38.2318</td>\n",
" <td>573576400</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>FB</td>\n",
" <td>2012-05-21</td>\n",
" <td>36.53</td>\n",
" <td>36.66</td>\n",
" <td>33.00</td>\n",
" <td>34.0300</td>\n",
" <td>168192700</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>36.53</td>\n",
" <td>36.66</td>\n",
" <td>33.00</td>\n",
" <td>34.0300</td>\n",
" <td>168192700</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>FB</td>\n",
" <td>2012-05-22</td>\n",
" <td>32.61</td>\n",
" <td>33.59</td>\n",
" <td>30.94</td>\n",
" <td>31.0000</td>\n",
" <td>101786600</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>32.61</td>\n",
" <td>33.59</td>\n",
" <td>30.94</td>\n",
" <td>31.0000</td>\n",
" <td>101786600</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>FB</td>\n",
" <td>2012-05-23</td>\n",
" <td>31.37</td>\n",
" <td>32.50</td>\n",
" <td>31.36</td>\n",
" <td>32.0000</td>\n",
" <td>73600000</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>31.37</td>\n",
" <td>32.50</td>\n",
" <td>31.36</td>\n",
" <td>32.0000</td>\n",
" <td>73600000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>FB</td>\n",
" <td>2012-05-24</td>\n",
" <td>32.95</td>\n",
" <td>33.21</td>\n",
" <td>31.77</td>\n",
" <td>33.0300</td>\n",
" <td>50237200</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>32.95</td>\n",
" <td>33.21</td>\n",
" <td>31.77</td>\n",
" <td>33.0300</td>\n",
" <td>50237200</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ticker date open high low close volume ex-dividend \\\n",
"None \n",
"0 FB 2012-05-18 42.05 45.00 38.00 38.2318 573576400 0 \n",
"1 FB 2012-05-21 36.53 36.66 33.00 34.0300 168192700 0 \n",
"2 FB 2012-05-22 32.61 33.59 30.94 31.0000 101786600 0 \n",
"3 FB 2012-05-23 31.37 32.50 31.36 32.0000 73600000 0 \n",
"4 FB 2012-05-24 32.95 33.21 31.77 33.0300 50237200 0 \n",
"\n",
" split_ratio adj_open adj_high adj_low adj_close adj_volume \n",
"None \n",
"0 1 42.05 45.00 38.00 38.2318 573576400 \n",
"1 1 36.53 36.66 33.00 34.0300 168192700 \n",
"2 1 32.61 33.59 30.94 31.0000 101786600 \n",
"3 1 31.37 32.50 31.36 32.0000 73600000 \n",
"4 1 32.95 33.21 31.77 33.0300 50237200 "
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data.head(5)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment