-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
ENH: Added method to pandas.data.Options to download all option data for... #5602
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…for a ticker. Also added a few helper functions. These functions could be applied to refactor some of the other methods. ENH: In Options.get_all_data: Now checking for any option tag (instead of just mini) Changed expiry to datetime from string. Added tests for tick functions. BUG: Fixed no sign in change column of option download. BUG: Fix bugs in Options class Dealt with situation of calculating expiry when symbol contains a hyphen Fixed bug in finding current expiry month. BUG: Fixed Options.get_forward_data expiry date Method assumed expiry date is the same for all option in a given month. Not the case for options with weekly's. Also breaks with options that have tags. BUG: Fixed Option bug that didn't allow LEAP DL in January. Option class was checking only the month to determine if the requested month was the current month. Changed to check year and month. Now allows downloads of next years LEAPS's in January. ENH: Added option tag and underlying price to option data output. Factored out URL parsing and error checking from individual methods. ENH: Refactor of Option class in io.data. Consistently returns multi-index data frame. Improves speed of downloading combination of calls and puts by only accessing yahoo once per expiry month. CLN: Fix out of date docstrings in io.data.Options Moved _parse_row_values definition into _unpack. CLN: Consistent capitalization in output data. CLN: Remove Tag, leave Root in data frame output. CLN: Remove unnecessary _tag_from_root method. BUG: Fix different capitalizations of Rootexp in _process_data. TST: Update tests for pandas.data.Options TST: Remove test for helper function that no longer exists. TST: Fix option test for change in output TST: Changes io.data.Options tests to self.assertTrue TST: Change tests raise nose.SkipTests on remote data errors TST: Change nose.SkipTest on RemoteDataError instead of IndexError ENH: Added quote time to outputs of data.Options. DOC: Added documentation for io.data.Options DOC: Added documentation of data.Options output. DOC: Updated docstrings on data.io.Options DOC: Added experimental tags to io.data.Options docstrings/documentation. BUG: Bug fixes, added tests, cleanups on documentation TST: Fix test_data Options tests. TST: Add test yahoo finance option pages. DOC: Update example to show slicing. TST: Remove test for long for python 3 compatibility. BUG: Fix quote time scraper TST: Changed the error raised by no tables in data.Options Tests were failing if the scraper got the webpage but there weren't any tables in it. Changed from IndexError to RemoteDataError so that nose would skip it on failure. DOC: Moved reference to new Options method to v0.14.1.txt DOC: Updated release at 0.14.1.txt for io.data.Options
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,43 @@ Yahoo! Finance | |
f=web.DataReader("F", 'yahoo', start, end) | ||
f.ix['2010-01-04'] | ||
|
||
.. _remote_data.yahoo_Options: | ||
|
||
Yahoo! Finance Options | ||
---------------------- | ||
***Experimental*** | ||
|
||
The Options class allows the download of options data from Yahoo! Finance. | ||
|
||
The ''get_all_data'' method downloads and caches option data for all expiry months | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use backticks ```` instead of |
||
and provides a formatted ''DataFrame'' with a hierarchical index, so its easy to get | ||
to the specific option you want. | ||
|
||
.. ipython:: python | ||
|
||
from pandas.io.data import Options | ||
aapl = Options('aapl', 'yahoo') | ||
data = aapl.get_all_data() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fails here (on conversions you need to protect with a try/except) in general. you prob need to wrap all of the float conversions with a ',' replacement (or better yet, don't convert them individually), let them be object dtype.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ya, I had this issue in my code on the weekend. I did the replace - I'll push the update and add a test tonight. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you suggest you do on ValueError here? Raise or return the string with an appended '-'? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, you can try to replace the commas, then convert; on failure I would make it |
||
data.head() | ||
|
||
#Show the $600 strike puts at all expiry dates: | ||
data.loc[(600, slice(None), 'put'),:].head() | ||
|
||
#Show the volume traded of $600 strike puts at all expiry dates: | ||
data.loc[(600, slice(None), 'put'),'Vol'].head() | ||
|
||
If you don't want to download all the data, more specific requests can be made. | ||
|
||
.. ipython:: python | ||
|
||
import datetime | ||
expiry = datetime.date(2016, 1, 1) | ||
data = aapl.get_call_data(expiry=expiry) | ||
data.head() | ||
|
||
Note that if you call ''get_all_data'' first, this second call will happen much faster, as the data is cached. | ||
|
||
|
||
.. _remote_data.google: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this works but I think that you need an example of how to slice this, because of this unless the Symbol is included in the index, then you can't slice it This works
but simply slicing will not (though using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That code doesn't work for me, I get: 'MultiIndex Slicing requires the index to be fully lexsorted tuple len (3), lexsort depth (0)' What about data.loc[(330,slice(None), 'call')]? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need to do a |
||
|
||
Google Finance | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to v0.14.1.txt (or removed if it is already there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, its in v0.14.1.txt, I will remove it here.