@@ -132,23 +132,23 @@ def get_quote_yahoo(symbols):
132132 return DataFrame (data , index = idx )
133133
134134
135- def _get_hist_yahoo (name = None , start = None , end = None , retry_count = 3 ,
135+ def _get_hist_yahoo (sym = None , start = None , end = None , retry_count = 3 ,
136136 pause = 0 ):
137137 """
138138 Get historical data for the given name from yahoo.
139139 Date format is datetime
140140
141141 Returns a DataFrame.
142142 """
143- if (name is None ):
143+ if (sym is None ):
144144 warnings .warn ("Need to provide a name." )
145145 return None
146146
147147 start , end = _sanitize_dates (start , end )
148148
149149 yahoo_URL = 'http://ichart.yahoo.com/table.csv?'
150150
151- url = yahoo_URL + 's=%s' % name + \
151+ url = yahoo_URL + 's=%s' % sym + \
152152 '&a=%s' % (start .month - 1 ) + \
153153 '&b=%s' % start .day + \
154154 '&c=%s' % start .year + \
@@ -203,17 +203,18 @@ def _calc_return_index(price_df):
203203 return ret_index
204204
205205
206- def get_components_yahoo (idx_sym = '^DJI' ):
206+ def get_components_yahoo (idx_sym ):
207207 """
208- Returns DataFrame containing list of component information for index
209- represented in idx_sym from yahoo. Includes component symbol
208+ Returns DataFrame containing list of component information for
209+ index represented in idx_sym from yahoo. Includes component symbol
210210 (ticker), exchange, and name.
211211
212212 Parameters
213213 ----------
214214 idx_sym : str
215- Index symbol, default '^DJI' (Dow Jones Industrial Average)
215+ Stock index symbol
216216 Examples:
217+ '^DJI' (Dow Jones Industrial Average)
217218 '^NYA' (NYSE Composite)
218219 '^IXIC' (NASDAQ Composite)
219220
@@ -256,44 +257,48 @@ def get_components_yahoo(idx_sym='^DJI'):
256257 return idx_df
257258
258259
259- def get_data_yahoo (symbols = None , start = None , end = None , adjust_price = False ,
260- ret_index = False , chunk = 25 , pause = 0 , ** kwargs ):
260+ def get_data_yahoo (symbols = None , start = None , end = None , retry_count = 3 , pause = 0 ,
261+ adjust_price = False , ret_index = False , chunksize = 25 , ** kwargs ):
261262 """
262263 Returns DataFrame/Panel of historical stock prices from symbols, over date
263264 range, start to end. To avoid being penalized by Yahoo! Finance servers,
264265 pauses between downloading 'chunks' of symbols can be specified.
265266
266267 Parameters
267268 ----------
268- symbols : string, list-like object (list, tupel, Series), DataFrame
269+ symbols : string, list-like object (list, tupel, Series), or DataFrame
269270 Single stock symbol (ticker), list-like object of symbols or
270- DataFrame with index containing of stock symbols
271+ DataFrame with index containing stock symbols.
271272 start : string, (defaults to '1/1/2010')
272273 Starting date, timestamp. Parses many different kind of date
273274 representations (e.g., 'JAN-01-2010', '1/1/10', 'Jan, 1, 1980')
274- end : string, (defaults to today)
275+ end : string, (defaults to today)
275276 Ending date, timestamp. Same format as starting date.
277+ retry_count : int, default 3
278+ Number of times to retry query request.
279+ pause : int, default 0
280+ Time, in seconds, to pause between consecutive queries of chunks. If
281+ single value given for symbol, represents the pause between retries.
276282 adjust_price : bool, default False
277- Adjust all prices in hist_data ('Open', 'High', 'Low', 'Close') via
278- 'Adj Close' price. Adds 'Adj_Ratio' column and drops 'Adj Close'.
279- ret_index: bool, default False
280- Include a simple return index 'Ret_Index' in hist_data.
281- chunk : int, default 25
283+ If True, adjusts all prices in hist_data ('Open', 'High', 'Low', 'Close')
284+ based on 'Adj Close' price. Adds 'Adj_Ratio' column and drops
285+ 'Adj Close'.
286+ ret_index : bool, default False
287+ If True, includes a simple return index 'Ret_Index' in hist_data.
288+ chunksize : int, default 25
282289 Number of symbols to download consecutively before intiating pause.
283- pause : int, default 0
284- Time, in seconds, to pause between consecutive chunks.
285- **kwargs: additional arguments to pass to _get_hist_yahoo
286290
287291 Returns
288292 -------
289293 hist_data : DataFrame (str) or Panel (list-like object, DataFrame)
290294 """
295+
291296 def dl_mult_symbols (symbols ):
292297 stocks = {}
293- for sym_group in _in_chunks (symbols , chunk ):
298+ for sym_group in _in_chunks (symbols , chunksize ):
294299 for sym in sym_group :
295300 try :
296- stocks [sym ] = _get_hist_yahoo (name = sym , start = start ,
301+ stocks [sym ] = _get_hist_yahoo (sym , start = start ,
297302 end = end , ** kwargs )
298303 except :
299304 warnings .warn ('Error with sym: ' + sym + '... skipping.' )
@@ -302,11 +307,16 @@ def dl_mult_symbols(symbols):
302307
303308 return Panel (stocks ).swapaxes ('items' , 'minor' )
304309
305- #If a scalar (single symbol, e.g. 'GOOG')
310+ if 'name' in kwargs :
311+ warnings .warn ("Arg 'name' is deprecated, please use 'symbols' instead." ,
312+ FutureWarning )
313+ symbols = kwargs ['name' ]
314+
315+ #If a single symbol, (e.g., 'GOOG')
306316 if isinstance (symbols , (str , int )):
307317 sym = symbols
308- hist_data = _get_hist_yahoo (sym , start = start , end = end , ** kwargs )
309- #Multiple symbols
318+ hist_data = _get_hist_yahoo (sym , start = start , end = end )
319+ #Or multiple symbols, (e.g., ['GOOG', 'AAPL', 'MSFT'])
310320 elif isinstance (symbols , DataFrame ):
311321 try :
312322 hist_data = dl_mult_symbols (Series (symbols .index ))
0 commit comments