mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-13 04:41:24 +00:00
Add calendar_earnings from yahoo finance command
This commit is contained in:
@@ -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':
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user