8000 Change Finance Options signatures and deprecate year/month parameters by gliptak · Pull Request #3822 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Change Finance Options signatures and deprecate year/month parameters #3822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 22, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added tests for Options
  • Loading branch information
gliptak committed Jun 22, 2013
commit f5977321d873ebbdf652dbc7337df3665d64da4b
72 changes: 72 additions & 0 deletions pandas/io/tests/test_yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,78 @@ def test_get_data(self):
t= np.array(pan)
assert np.issubdtype(t.dtype, np.floating)

@network
def test_options(self):
try:
import lxml
except ImportError:
raise nose.SkipTest
try:
# aapl has monthlies
aapl = web.Options('aapl', 'yahoo')
today = datetime.today()
year = today.year
month = today.month+1
if (month>12):
year = year +1
month = 1
expiry=datetime(year, month, 1)
(calls, puts) = aapl.get_options_data(expiry=expiry)
assert len(calls)>1
assert len(puts)>1
(calls, puts) = aapl.get_near_stock_price(call=True, put=True, expiry=expiry)
assert len(calls)==5
assert len(puts)==5
calls = aapl.get_call_data(expiry=expiry)
assert len(calls)>1
puts = aapl.get_put_data(expiry=expiry)
assert len(puts)>1
except IOError:
try:
urllib2.urlopen('http://www.google.com')
except IOError:
raise nose.SkipTest
else:
raise

@network
def test_options_warnings(self):
try:
import lxml
except ImportError:
raise nose.SkipTest
try:
import warnings
with warnings.catch_warnings(record=True) as w:
warnings.resetwarnings()
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
# aapl has monthlies
aapl = web.Options('aapl')
today = datetime.today()
year = today.year
month = today.month+1
if (month>12):
year = year +1
month = 1
(calls, puts) = aapl.get_options_data(month=month, year=year)
(calls, puts) = aapl.get_near_stock_price(call=True, put=True, month=month, year=year)
calls = aapl.get_call_data(month=month, year=year)
puts = aapl.get_put_data(month=month, year=year)
print(w)
assert len(w) == 5
assert "deprecated" in str(w[0].message)
assert "deprecated" in str(w[1].message)
assert "deprecated" in str(w[2].message)
assert "deprecated" in str(w[3].message)
assert "deprecated" in str(w[4].message)
except IOError:
try:
urllib2.urlopen('http://www.google.com')
except IOError:
raise nose.SkipTest
else:
raise

if __name__ == '__main__':
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
Expand Down
0