From 6981ef3f14853c0954b19d3fd10d0a2734b59383 Mon Sep 17 00:00:00 2001 From: Spencer Lyon Date: Sat, 16 Feb 2013 14:45:57 -0700 Subject: [PATCH] DOC: Added note about changes in Options class to 'what's new' version 0.11 BUG: Also correcting a bug in Options.get_forward_data for puts. Signed-off-by: Spencer Lyon --- doc/source/v0.11.0.txt | 21 ++++++++++++++++++++- pandas/io/data.py | 8 ++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/doc/source/v0.11.0.txt b/doc/source/v0.11.0.txt index 0162ee85ac518..1716f2d4d1413 100644 --- a/doc/source/v0.11.0.txt +++ b/doc/source/v0.11.0.txt @@ -107,7 +107,7 @@ While float dtypes are unchanged. Datetimes Conversion ~~~~~~~~~~~~~~~~~~~~ -Datetime64[ns] columns in a DataFrame (or a Series) allow the use of ``np.nan`` to indicate a nan value, +Datetime64[ns] columns in a DataFrame (or a Series) allow the use of ``np.nan`` to indicate a nan value, in addition to the traditional ``NaT``, or not-a-time. This allows convenient nan setting in a generic way. Furthermore ``datetime64[ns]`` columns are created by default, when passed datetimelike objects (*this change was introduced in 0.10.1*) (GH2809_, GH2810_) @@ -159,6 +159,25 @@ New features p.reindex(items=['ItemA']).squeeze() p.reindex(items=['ItemA'],minor=['B']).squeeze() + - 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** See the `full release notes diff --git a/pandas/io/data.py b/pandas/io/data.py index 3e4e833b0d463..9a0fee7349b20 100644 --- a/pandas/io/data.py +++ b/pandas/io/data.py @@ -870,12 +870,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:] put_frame = self.__getattribute__(name) @@ -886,7 +885,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])