Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 04f3788

Browse files
Quandl stock data pull script
1 parent ef1c723 commit 04f3788

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎Tutorials/Quandl Script.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# import needed libraries
2+
import quandl
3+
import pandas as pd
4+
5+
# add quandl API key for unrestricted
6+
quandl.ApiConfig.api_key = 'INSERT YOU API KEY HERE'
7+
8+
# get the table for daily stock prices and,
9+
# filter the table for selected tickers, columns within a time range
10+
# set paginate to True because Quandl limits tables API to 10,000 rows per call
11+
data = quandl.get_table('WIKI/PRICES', ticker = ['AAPL', 'MSFT', 'WMT'],
12+
qopts = { 'columns': ['ticker', 'date', 'adj_close'] },
13+
date = { 'gte': '2015年12月31日', 'lte': '2016年12月31日' },
14+
paginate=True)
15+
16+
# create a new dataframe with 'date' column as index
17+
new = data.set_index('date')
18+
19+
# use pandas pivot function to sort adj_close by tickers
20+
clean_data = new.pivot(columns='ticker')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /