ENH: Provide better defaults for load_from_yahoo.

Set the default end date to current date, so that trading on
'fresh' data is the default case.

Set the default begin date at 1/1/1990, since that is when the
treasury benchmark data is first available.
This commit is contained in:
Ben McCann
2013-04-04 12:18:19 -07:00
committed by Eddie Hebert
parent 58af62f18d
commit dc11534d54
+19 -18
View File
@@ -15,7 +15,7 @@
"""
Factory functions to prepare useful data for tests.
Factory functions to prepare useful data.
"""
import pytz
import random
@@ -334,28 +334,29 @@ def _load_raw_yahoo_data(indexes=None, stocks=None, start=None, end=None):
http://wesmckinney.com/files/20111017/notebook_output.pdf
"""
if indexes is None:
indexes = {'SPX': '^GSPC'}
if stocks is None:
stocks = ['AAPL', 'GE', 'IBM', 'MSFT', 'XOM', 'AA', 'JNJ', 'PEP', 'KO']
if start is None:
start = pd.datetime(1993, 1, 1, 0, 0, 0, 0, pytz.utc)
if end is None:
end = pd.datetime(2002, 1, 1, 0, 0, 0, 0, pytz.utc)
assert indexes is not None or stocks is not None, """
must specify stocks or indexes"""
assert start < end, "start date is later than end date."
if start is None:
start = pd.datetime(1990, 1, 1, 0, 0, 0, 0, pytz.utc)
if not start is None and not end is None:
assert start < end, "start date is later than end date."
data = OrderedDict()
for stock in stocks:
print stock
stkd = DataReader(stock, 'yahoo', start, end).sort_index()
data[stock] = stkd
if stocks is not None:
for stock in stocks:
print stock
stkd = DataReader(stock, 'yahoo', start, end).sort_index()
data[stock] = stkd
if indexes is not None:
for name, ticker in indexes.iteritems():
print name
stkd = DataReader(ticker, 'yahoo', start, end).sort_index()
data[name] = stkd
for name, ticker in indexes.iteritems():
print name
stkd = DataReader(ticker, 'yahoo', start, end).sort_index()
data[name] = stkd
return data