@@ -21,7 +21,6 @@ class TestYahoo(object):
21
21
22
22
@classmethod
23
23
def setup_class (cls ):
24
- pytest .skip ('Skip all Yahoo! tests.' )
25
24
pytest .importorskip ("lxml" )
26
25
27
26
@skip_on_exception (RemoteDataError )
@@ -30,7 +29,8 @@ def test_yahoo(self):
30
29
start = datetime (2010 , 1 , 1 )
31
30
end = datetime (2013 , 1 , 25 )
32
31
33
- assert web .DataReader ('F' , 'yahoo' , start , end )['Close' ][- 1 ] == 13.68
32
+ assert round (web .DataReader ('F' , 'yahoo' , start , end )['Close' ][- 1 ],
33
+ 2 ) == 13.68
34
34
35
35
def test_yahoo_fails (self ):
36
36
start = datetime (2010 , 1 , 1 )
@@ -39,13 +39,15 @@ def test_yahoo_fails(self):
39
39
with pytest .raises (Exception ):
40
40
web .DataReader ('NON EXISTENT TICKER' , 'yahoo' , start , end )
41
41
42
+ @pytest .mark .skip ('Yahoo quotes deprecated' )
42
43
def test_get_quote_series (self ):
43
44
try :
44
45
df = web .get_quote_yahoo (pd .Series (['GOOG' , 'AAPL' , 'GOOG' ]))
45
46
except ConnectionError :
46
47
pytest .xfail (reason = XFAIL_REASON )
47
48
tm .assert_series_equal (df .iloc [0 ], df .iloc [2 ])
48
49
50
+ @pytest .mark .skip ('Yahoo quotes deprecated' )
49
51
def test_get_quote_string (self ):
50
52
_yahoo_codes .update ({'MarketCap' : 'j1' })
51
53
try :
@@ -55,13 +57,15 @@ def test_get_quote_string(self):
55
57
56
58
assert not pd .isnull (df ['MarketCap' ][0 ])
57
59
60
+ @pytest .mark .skip ('Yahoo quotes deprecated' )
58
61
def test_get_quote_stringlist (self ):
59
62
try :
60
63
df = web .get_quote_yahoo (['GOOG' , 'AAPL' , 'GOOG' ])
61
64
except ConnectionError :
62
65
pytest .xfail (reason = XFAIL_REASON )
63
66
tm .assert_series_equal (df .iloc [0 ], df .iloc [2 ])
64
67
68
+ @pytest .mark .skip ('Yahoo quotes deprecated' )
65
69
def test_get_quote_comma_name (self ):
66
70
_yahoo_codes .update ({'name' : 'n' })
67
71
try :
@@ -113,6 +117,10 @@ def test_get_data_single_symbol(self):
113
117
# just test that we succeed
114
118
web .get_data_yahoo ('GOOG' )
115
119
120
+ @skip_on_exception (RemoteDataError )
121
+ def test_data_with_no_actions (self ):
122
+ web .get_data_yahoo ('TSLA' )
123
+
116
124
@skip_on_exception (RemoteDataError )
117
125
def test_get_data_adjust_price (self ):
118
126
goog = web .get_data_yahoo ('GOOG' )
@@ -165,11 +173,11 @@ def test_get_data_null_as_missing_data(self, adj_pr):
165
173
def test_get_data_multiple_symbols_two_dates (self ):
166
174
pan = web .get_data_yahoo (['GE' , 'MSFT' , 'INTC' ], 'JAN-01-12' ,
167
175
'JAN-31-12' )
168
- result = pan .Close ['01-18-12' ].T
176
+ result = pan .Close . loc ['01-18-12' ].T
169
177
assert result .size == 3
170
178
171
179
# sanity checking
172
- assert result .dtypes . all () == np .floating
180
+ assert result .dtypes == np .floating
173
181
174
182
expected = np .array ([[18.99 , 28.4 , 25.18 ],
175
183
[18.58 , 28.31 , 25.13 ],
@@ -179,7 +187,6 @@ def test_get_data_multiple_symbols_two_dates(self):
179
187
result = df [(df .index >= 'Jan-15-12' ) & (df .index <= 'Jan-20-12' )]
180
188
assert expected .shape == result .shape
181
189
182
- @pytest .mark .xfail (reason = "failing after #355" )
183
190
def test_get_date_ret_index (self ):
184
191
pan = web .get_data_yahoo (['GE' , 'INTC' , 'IBM' ], '1977' , '1987' ,
185
192
ret_index = True )
@@ -193,7 +200,6 @@ def test_get_date_ret_index(self):
193
200
# sanity checking
194
201
assert np .issubdtype (pan .values .dtype , np .floating )
195
202
196
- @pytest .mark .xfail (reason = "failing after #355" )
197
203
def test_get_data_yahoo_actions (self ):
198
204
start = datetime (1990 , 1 , 1 )
199
205
end = datetime (2000 , 4 , 5 )
@@ -228,7 +234,6 @@ def test_yahoo_reader_class(self):
228
234
r = YahooDailyReader ('GOOG' , session = session )
229
235
assert r .session is session
230
236
231
- @pytest .mark .xfail (reason = "failing after #355" )
232
237
def test_yahoo_DataReader (self ):
233
238
start = datetime (2010 , 1 , 1 )
234
239
end = datetime (2015 , 5 , 9 )
@@ -241,6 +246,22 @@ def test_yahoo_DataReader(self):
241
246
'2013-08-08' , '2013-05-09' ,
242
247
'2013-02-07' , '2012-11-07' ,
243
248
'2012-08-09' ])
249
+
250
+ exp = pd .DataFrame ({'action' : ['DIVIDEND' , 'DIVIDEND' , 'DIVIDEND' ,
251
+ 'DIVIDEND' , 'SPLIT' , 'DIVIDEND' ,
252
+ 'DIVIDEND' , 'DIVIDEND' ,
253
+ 'DIVIDEND' , 'DIVIDEND' , 'DIVIDEND' ,
254
+ 'DIVIDEND' , 'DIVIDEND' ],
255
+ 'value' : [0.52 , 0.47 , 0.47 , 0.47 , 0.14285714 ,
256
+ 3.29 , 3.05 , 3.05 , 3.05 ,
257
+ 3.05 , 2.65 , 2.65 , 2.65 ]},
258
+ index = exp_idx )
259
+ exp .index .name = 'Date'
260
+ tm .assert_frame_equal (result .reindex_like (exp ).round (5 ), exp .round (5 ))
261
+
262
+ result = web .get_data_yahoo_actions ('AAPL' , start , end ,
263
+ adjust_dividends = True )
264
+
244
265
exp = pd .DataFrame ({'action' : ['DIVIDEND' , 'DIVIDEND' , 'DIVIDEND' ,
245
266
'DIVIDEND' , 'SPLIT' , 'DIVIDEND' ,
246
267
'DIVIDEND' , 'DIVIDEND' ,
@@ -251,13 +272,11 @@ def test_yahoo_DataReader(self):
251
272
0.43571 , 0.37857 , 0.37857 , 0.37857 ]},
252
273
index = exp_idx )
253
274
exp .index .name = 'Date'
254
-
255
- tm .assert_frame_equal (result .reindex_like (exp ), exp )
275
+ tm .assert_frame_equal (result .reindex_like (exp ).round (5 ), exp .round (5 ))
256
276
257
277
@skip_on_exception (RemoteDataError )
258
278
def test_yahoo_DataReader_multi (self ):
259
279
start = datetime (2010 , 1 , 1 )
260
280
end = datetime (2015 , 5 , 9 )
261
-
262
281
result = web .DataReader (['AAPL' , 'F' ], 'yahoo-actions' , start , end )
263
282
assert isinstance (result , pd .Panel )
0 commit comments