@@ -246,35 +246,24 @@ def _get_hist_google(sym=None, start=None, end=None, retry_count=3,
246
246
247
247
start , end = _sanitize_dates (start , end )
248
248
249
- yahoo_URL = 'http://ichart.yahoo.com/table.csv?'
250
-
251
- url = yahoo_URL + 's=%s' % sym + \
252
- '&a=%s' % (start .month - 1 ) + \
253
- '&b=%s' % start .day + \
254
- '&c=%s' % start .year + \
255
- '&d=%s' % (end .month - 1 ) + \
256
- '&e=%s' % end .day + \
257
- '&f=%s' % end .year + \
258
- '&g=d' + \
259
- '&ignore=.csv'
249
+ google_URL = 'http://www.google.com/finance/historical?'
260
250
251
+ # www.google.com/finance/historical?q=GOOG&startdate=Jun+9%2C+2011&enddate=Jun+8%2C+2013&output=csv
252
+ url = google_URL + urllib .urlencode ({"q" : sym , \
253
+ "startdate" : start .strftime ('%b %d, %Y' ), \
254
+ "enddate" : end .strftime ('%b %d, %Y' ), "output" : "csv" })
261
255
for _ in range (retry_count ):
262
256
resp = urllib2 .urlopen (url )
263
257
if resp .code == 200 :
264
258
lines = resp .read ()
265
259
rs = read_csv (StringIO (bytes_to_str (lines )), index_col = 0 ,
266
260
parse_dates = True )[::- 1 ]
267
261
268
- # Yahoo! Finance sometimes does this awesome thing where they
269
- # return 2 rows for the most recent business day
270
- if len (rs ) > 2 and rs .index [- 1 ] == rs .index [- 2 ]: # pragma: no cover
271
- rs = rs [:- 1 ]
272
-
273
262
return rs
274
263
275
264
time .sleep (pause )
276
265
277
- raise Exception ("after %d tries, Yahoo did not "
266
+ raise Exception ("after %d tries, Google did not "
278
267
"return a 200 for url %s" % (pause , url ))
279
268
280
269
@@ -448,11 +437,10 @@ def dl_mult_symbols(symbols):
448
437
return hist_data
449
438
450
439
def get_data_google (symbols = None , start = None , end = None , retry_count = 3 , pause = 0 ,
451
- adjust_price = False , ret_index = False , chunksize = 25 ,
452
- ** kwargs ):
440
+ chunksize = 25 , ** kwargs ):
453
441
"""
454
442
Returns DataFrame/Panel of historical stock prices from symbols, over date
455
- range, start to end. To avoid being penalized by Yahoo! Finance servers,
443
+ range, start to end. To avoid being penalized by Google Finance servers,
456
444
pauses between downloading 'chunks' of symbols can be specified.
457
445
458
446
Parameters
@@ -470,12 +458,6 @@ def get_data_google(symbols=None, start=None, end=None, retry_count=3, pause=0,
470
458
pause : int, default 0
471
459
Time, in seconds, to pause between consecutive queries of chunks. If
472
460
single value given for symbol, represents the pause between retries.
473
- adjust_price : bool, default False
474
- If True, adjusts all prices in hist_data ('Open', 'High', 'Low', 'Close')
475
- based on 'Adj Close' price. Adds 'Adj_Ratio' column and drops
476
- 'Adj Close'.
477
- ret_index : bool, default False
478
- If True, includes a simple return index 'Ret_Index' in hist_data.
479
461
chunksize : int, default 25
480
462
Number of symbols to download consecutively before intiating pause.
481
463
@@ -519,11 +501,6 @@ def dl_mult_symbols(symbols):
519
501
except TypeError :
520
502
hist_data = dl_mult_symbols (Series (symbols ))
521
503
522
- if (ret_index ):
523
- hist_data ['Ret_Index' ] = _calc_return_index (hist_data ['Adj Close' ])
524
- if (adjust_price ):
525
- hist_data = _adjust_prices (hist_data )
526
-
527
504
return hist_data
528
505
529
506
def get_data_fred (name = None , start = dt .datetime (2010 , 1 , 1 ),
0 commit comments