class TestNoneRequested(unittest.TestCase): def setUp(self): self.symbol = 'AAPL' self.reader = YahooSummaryReader(self.symbol, include_all=False) self.expected_got_str = 'Expected {} to be None. Got type: {}' def test_all_properties_none(self): with self.assertRaises(ValueError): self.reader.read()
def get_yahoo_balance_sheet(symbols, include_quarterly=True, include_historical=False): return YahooSummaryReader( symbols, include_balance_sheet_history=include_historical, include_balance_sheet_history_quarterly=include_quarterly).read()
def get_yahoo_ownership(symbols, include_funds=True, include_institutions=True): return YahooSummaryReader( symbols, include_fund_ownership=include_funds, include_institution_ownership=include_institutions).read()
def get_yahoo_insiders(symbols, include_insiders=True, include_insider_transactions=True): return YahooSummaryReader( symbols, include_insider_holders=include_insiders, include_insider_transactions=include_insider_transactions).read()
def get_yahoo_major_holders(symbols, include_major_holders=True, include_breakdown=False): return YahooSummaryReader( symbols, include_major_direct_holders=include_major_holders, include_major_direct_holders_breakdown=include_breakdown).read()
def get_yahoo_income_statement(symbols, include_quarterly=True, include_historical=False): return YahooSummaryReader( symbols, include_income_statement_history=include_historical, include_income_statement_history_quarterly=include_quarterly).read()
def test_sec_filings_request(self): summary = YahooSummaryReader(self.symbol, include_sec_filings=True).read() check_property = 'sec_filings' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.sec_filings)
def test_sector_trend_request(self): summary = YahooSummaryReader(self.symbol, include_sector_trend=True).read() check_property = 'sector_trend' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.sector_trend)
def test_fund_ownership_request(self): summary = YahooSummaryReader(self.symbol, include_fund_ownership=True).read() check_property = 'fund_ownership' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.fund_ownership)
def test_insider_holders_request(self): summary = YahooSummaryReader(self.symbol, include_insider_holders=True).read() check_property = 'insider_holders' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.insider_holders)
def test_financial_data_request(self): summary = YahooSummaryReader(self.symbol, include_financial_data=True).read() check_property = 'financial_data' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.financial_data)
def test_earnings_history_request(self): summary = YahooSummaryReader(self.symbol, include_earnings_history=True).read() check_property = 'earnings_history' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.earnings_history)
def test_net_share_purchase_activity_request(self): summary = YahooSummaryReader( self.symbol, include_net_share_purchase_activity=True).read() check_property = 'net_share_purchase_activity' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.net_share_purchase_activity)
def test_upgrade_downgrade_history_request(self): summary = YahooSummaryReader( self.symbol, include_upgrade_downgrade_history=True).read() check_property = 'upgrade_downgrade_history' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.upgrade_downgrade_history)
def test_major_direct_holders_breakdown_request(self): summary = YahooSummaryReader( self.symbol, include_major_direct_holders_breakdown=True).read() check_property = 'major_direct_holders_breakdown' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.major_direct_holders_breakdown)
def test_default_key_statistics_request(self): summary = YahooSummaryReader( self.symbol, include_default_key_statistics=True).read() check_property = 'default_key_statistics' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.default_key_statistics)
def test_balance_sheet_history_quarterly_request(self): summary = YahooSummaryReader( self.symbol, include_balance_sheet_history_quarterly=True).read() check_property = 'balance_sheet_history_quarterly' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.balance_sheet_history_quarterly)
def test_income_statement_history_request(self): summary = YahooSummaryReader( self.symbol, include_income_statement_history=True).read() check_property = 'income_statement_history' self.check_none_values(summary, [check_property]) self.check_non_none_values(check_property, summary.income_statement_history)
def test_cash_flow_statement_history_quarterly_request(self): summary = YahooSummaryReader( self.symbol, include_cash_flow_statement_history_quarterly=True).read() check_property = 'cash_flow_statement_history_quarterly' self.check_none_values(summary, [check_property]) self.check_non_none_values( check_property, summary.cash_flow_statement_history_quarterly)
def setUp(self): self.symbol = 'AAPL' self.expected_got_str = 'Expected {} to be None. Got type: {}' temp_summary = YahooSummaryReader(self.symbol, include_all=True).read() self.dont_check_properties = [ prop for prop in dir(temp_summary) if prop.startswith("__") or prop.startswith("_") ] self.dont_check_properties += ['symbol', 'exception', 'SummaryObject']
def test_asset_profile_request(self): summary = YahooSummaryReader(self.symbol, include_asset_profile=True).read() check_property1 = 'profile' check_property2 = 'company_officers' self.check_none_values(summary, [check_property1, check_property2]) self.check_non_none_values(check_property1, summary.profile) self.check_non_none_values(check_property2, summary.company_officers)
def get_yahoo_trends(symbols, include_recommendation=True, include_industry=False, include_index=False, include_sector=False): return YahooSummaryReader( symbols, include_recommendation_trend=include_recommendation, include_industry_trend=include_industry, include_index_trend=include_index, include_sector_trend=include_sector).read()
def test_index_trend_request(self): summary = YahooSummaryReader(self.symbol, include_index_trend=True).read() check_property1 = 'index_trend_info' check_property2 = 'index_trend_estimate' self.check_none_values(summary, [check_property1, check_property2]) self.check_non_none_values(check_property1, summary.index_trend_info) self.check_non_none_values(check_property2, summary.index_trend_estimate)
def test_calendar_events_request(self): summary = YahooSummaryReader(self.symbol, include_calendar_events=True).read() check_property1 = 'calendar_events_earnings' check_property2 = 'calendar_events_dividends' self.check_none_values(summary, [check_property1, check_property2]) self.check_non_none_values(check_property1, summary.calendar_events_earnings) self.check_non_none_values(check_property2, summary.calendar_events_dividends)
def test_include_earnings_request(self): summary = YahooSummaryReader(self.symbol, include_earnings=True).read() check_property1 = 'earnings_estimates' check_property2 = 'earnings_estimates_quarterly' check_property3 = 'financials_quarterly' check_property4 = 'financials_yearly' self.check_none_values(summary, [ check_property1, check_property2, check_property3, check_property4 ]) self.check_non_none_values(check_property1, summary.earnings_estimates) self.check_non_none_values(check_property2, summary.earnings_estimates_quarterly) self.check_non_none_values(check_property3, summary.financials_quarterly) self.check_non_none_values(check_property4, summary.financials_yearly)
def get_yahoo_key_statistics(symbols): return YahooSummaryReader(symbols, include_default_key_statistics=True).read()
def get_yahoo_financial(symbols): return YahooSummaryReader(symbols, include_financial_data=True).read()
def get_yahoo_earnings(symbols, include_historical=False, include_trend=False): return YahooSummaryReader(symbols, include_earnings=True, include_earnings_history=include_historical, include_earnings_trend=include_trend).read()
def get_yahoo_profile(symbols): return YahooSummaryReader(symbols, include_asset_profile=True).read()
def get_yahoo_summary(symbols): return YahooSummaryReader(symbols).read()