-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (21 loc) · 715 Bytes
/
main.py
File metadata and controls
27 lines (21 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import itertools
import yahoo
folder = 'historical'
def range_dict(dictionary, begin, end):
return dict(itertools.islice(dictionary.iteritems(), begin, end+1))
def __saveQuotesIfNotExists(symbol, quotes):
file = open("%s/%s_quotes.csv"%(folder,symbol),"w")
file.write(quotes)
file.close()
symbols = yahoo.getAllSymbols()
symbols = list(symbols)
tot = len(symbols)
print "starting saving historical data for %s symbols"%tot
#symbols = itertools.islice(symbols, 0, 100)
i = 1
for s in symbols:
symbol = s['symbol']
print "(%s/%s)saving historical data for %s"%(i,tot,symbol)
quotes = yahoo.getHistoricalQuotesAsCSV(symbol)
__saveQuotesIfNotExists(symbol, quotes)
i = i + 1