diff --git a/fundamental_analysis/fa_menu.py b/fundamental_analysis/fa_menu.py index 354356bafe8..44c493b0265 100644 --- a/fundamental_analysis/fa_menu.py +++ b/fundamental_analysis/fa_menu.py @@ -49,6 +49,7 @@ def print_fundamental_analysis(s_ticker, s_start, s_interval): print(" info information scope of the company") print(" shrs hareholders of the company") print(" sust sustainability values of the company") + print(" cal calendar earnings and estimates of the company") print("") print("Alpha Vantage API") print(" overview overview of the company") @@ -105,7 +106,7 @@ def fa_menu(s_ticker, s_start, s_interval): fa_parser.add_argument('cmd', choices=['help', 'q', 'quit', # 'screener', # Finviz 'mgmt', # Business Insider - 'info', 'shrs', 'sust',# Yahoo Finance + 'info', 'shrs', 'sust', 'cal', # Yahoo Finance 'income', 'assets', 'liabilities', 'operating', 'investing', 'financing', # MW 'overview', 'key', 'incom', 'balance', 'cash', 'earnings', # AV 'profile', 'quote', 'enterprise', 'dcf', # FMP @@ -176,6 +177,9 @@ def fa_menu(s_ticker, s_start, s_interval): elif ns_known_args.cmd == 'sust': yf_api.sustainability(l_args, s_ticker) + + elif ns_known_args.cmd == 'cal': + yf_api.calendar_earnings(l_args, s_ticker) # ALPHA VANTAGE API elif ns_known_args.cmd == 'overview': diff --git a/fundamental_analysis/yahoo_finance_api.py b/fundamental_analysis/yahoo_finance_api.py index 345b90981fd..a69992d5721 100644 --- a/fundamental_analysis/yahoo_finance_api.py +++ b/fundamental_analysis/yahoo_finance_api.py @@ -155,3 +155,31 @@ def sustainability(l_args, s_ticker): print("") return + +# ---------------------------------------------------- CALENDAR_EARNINGS ---------------------------------------------------- +def calendar_earnings(l_args, s_ticker): + parser = argparse.ArgumentParser(prog='calendar_earnings', + description="""Calendar earnings of the company. Including revenue and earnings estimates + [Source: Yahoo Finance API]""") + + try: + (ns_parser, l_unknown_args) = parser.parse_known_args(l_args) + + if l_unknown_args: + print(f"The following args couldn't be interpreted: {l_unknown_args}\n") + return + + stock = yf.Ticker(s_ticker) + df_calendar = stock.calendar + df_calendar.iloc[0,0] = df_calendar.iloc[0,0].date().strftime("%d/%m/%Y") + df_calendar.iloc[:, 0] = df_calendar.iloc[:, 0].apply(lambda x: long_number_format(x)) + + print(f"Earnings Date: {df_calendar.iloc[:, 0]['Earnings Date']}") + print(f"Earnings Estimate Avg: {df_calendar.iloc[:, 0]['Earnings Average']} [{df_calendar.iloc[:, 0]['Earnings Low']}, {df_calendar.iloc[:, 0]['Earnings High']}]") + print(f"Revenue Estimate Avg: {df_calendar.iloc[:, 0]['Revenue Average']} [{df_calendar.iloc[:, 0]['Revenue Low']}, {df_calendar.iloc[:, 0]['Revenue High']}]") + print("") + + except: + print("") + return +