def setUpClass(cls): super(TestYahooOptions, cls).setUpClass() _skip_if_no_lxml() # aapl has monthlies cls.aapl = web.Options('aapl', 'yahoo') today = datetime.today() year = today.year month = today.month + 1 if month > 12: year = year + 1 month = 1 cls.expiry = datetime(year, month, 1) cls.dirpath = tm.get_data_path() cls.html1 = os.path.join(cls.dirpath, 'yahoo_options1.html') cls.html2 = os.path.join(cls.dirpath, 'yahoo_options2.html') cls.root1 = cls.aapl._parse_url(cls.html1) cls.root2 = cls.aapl._parse_url(cls.html2) cls.tables1 = cls.aapl._parse_option_page_from_yahoo(cls.root1) cls.unprocessed_data1 = web._parse_options_data(cls.tables1[cls.aapl._TABLE_LOC['puts']]) cls.data1 = cls.aapl._process_data(cls.unprocessed_data1, 'put')
def setUpClass(cls): super(TestYahooOptions, cls).setUpClass() _skip_if_no_lxml() # aapl has monthlies cls.aapl = web.Options('aapl', 'yahoo') today = datetime.today() year = today.year month = today.month + 1 if month > 12: year = year + 1 month = 1 cls.expiry = datetime(year, month, 1) cls.dirpath = tm.get_data_path() cls.html1 = os.path.join(cls.dirpath, 'yahoo_options1.html') cls.html2 = os.path.join(cls.dirpath, 'yahoo_options2.html') cls.root1 = cls.aapl._parse_url(cls.html1) cls.root2 = cls.aapl._parse_url(cls.html2) cls.tables1 = cls.aapl._parse_option_page_from_yahoo(cls.root1) cls.unprocessed_data1 = web._parse_options_data( cls.tables1[cls.aapl._TABLE_LOC['puts']]) cls.data1 = cls.aapl._process_data(cls.unprocessed_data1, 'put')
def test_sample_page_chg_float(self): #Tests that numeric columns with comma's are appropriately dealt with tables = self.root1.xpath('.//table') data = web._parse_options_data(tables[self.aapl._TABLE_LOC['puts']]) option_data = self.aapl._process_data(data) self.assertEqual(option_data['Chg'].dtype, 'float64')