From 532c9d10f8fec37868e68c36331cd0dd3a2afe0b Mon Sep 17 00:00:00 2001 From: Spencer Lyon Date: Wed, 13 Feb 2013 16:14:26 -0700 Subject: [PATCH 1/2] BUG: Fixed bug in Options.get_forward_data for calls case --- pandas/io/data.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/io/data.py b/pandas/io/data.py index 3bf177b47b9d6..fb3ea7ba9b669 100644 --- a/pandas/io/data.py +++ b/pandas/io/data.py @@ -230,7 +230,6 @@ def _parse_options_data(table): rows = table.findall('.//tr') header = _unpack(rows[0], kind='th') data = [_unpack(r) for r in rows[1:]] - # Use ',' as a thousands separator as we're pulling from the US site. return TextParser(data, names=header, na_values=['N/A'], thousands=',').get_chunk() @@ -683,11 +682,11 @@ def get_forward_data(self, months, call=True, put=False, near=False, if put: all_puts = DataFrame() for mon in range(months): + m2 = in_months[mon] + y2 = in_years[mon] try: # This catches cases when there isn't data for a month if not near: try: # Try to access the ivar if already instantiated - m2 = in_months[mon] - y2 = in_years[mon] m1 = m2 if len(str(m2)) == 2 else '0' + str(m2) name = 'puts' + str(m1) + str(y2)[2:] @@ -699,7 +698,8 @@ def get_forward_data(self, months, call=True, put=False, near=False, else: put_frame = self.get_near_stock_price(call=False, put=True, - above_below=above_below) + above_below=above_below, + month=m2, year=y2) # Add column with expiry data to this frame. tick = str(put_frame.Symbol[0]) From c9220574b53c432ac4a29a4cef21d50212ad645a Mon Sep 17 00:00:00 2001 From: Spencer Lyon Date: Wed, 13 Feb 2013 16:29:46 -0700 Subject: [PATCH 2/2] ENH: added notes about Options updates to what's new for v0.11 --- doc/source/v0.11.0.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/source/v0.11.0.txt b/doc/source/v0.11.0.txt index d2648cbdb5a44..84bb6dd7c68a2 100644 --- a/doc/source/v0.11.0.txt +++ b/doc/source/v0.11.0.txt @@ -88,6 +88,12 @@ New features **Enhancements** - In ``HDFStore``, provide dotted attribute access to ``get`` from stores (e.g. store.df == store['df']) + - In ``pd.io.data.Options``, + + Fix bug when trying to fetch data for the current month when already past expiry. + + Now using lxml to scrape html instead of BeautifulSoup (lxml was faster). + + New instance variables for calls and puts are automatically created when a method that creates them is called. This works for current month where the instance variables are simply ``calls`` and ``puts``. Also works for future expiry months and save the instance variable as ``callsMMYY`` or ``putsMMYY``, where ``MMYY`` are, respectively, the month and year of the option's expiry. + + ``Options.get_near_stock_price`` now allows the user to specify the month for which to get relevant options data. + + ``Options.get_forward_data`` now has optional kwargs ``near`` and ``above_below``. This allows the user to specify if they would like to only return forward looking data for options near the current stock price. This just obtains the data from Options.get_near_stock_price instead of Options.get_xxx_data(). **Bug Fixes**