mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-12 20:31:18 +00:00
Add shareholders command from yahoo finance
This commit is contained in:
@@ -35,7 +35,7 @@ def print_fundamental_analysis(s_ticker, s_start, s_interval):
|
||||
print(" quit quit to abandon program")
|
||||
print("")
|
||||
print(" screener screen info about the company [Finviz]")
|
||||
print(" management management team of the company [Business Insider]")
|
||||
print(" mgmt management team of the company [Business Insider]")
|
||||
print("")
|
||||
print("Market Watch API")
|
||||
print(" income income statement of the company")
|
||||
@@ -47,6 +47,7 @@ def print_fundamental_analysis(s_ticker, s_start, s_interval):
|
||||
print("")
|
||||
print("Yahoo Finance API")
|
||||
print(" info information scope of the company")
|
||||
print(" shrs hareholders of the company")
|
||||
print("")
|
||||
print("Alpha Vantage API")
|
||||
print(" overview overview of the company")
|
||||
@@ -102,8 +103,8 @@ def fa_menu(s_ticker, s_start, s_interval):
|
||||
fa_parser = argparse.ArgumentParser(prog='fundamental_analysis', add_help=False)
|
||||
fa_parser.add_argument('cmd', choices=['help', 'q', 'quit', #
|
||||
'screener', # Finviz
|
||||
'management', # Business Insider
|
||||
'info', # Yahoo Finance
|
||||
'mgmt', # Business Insider
|
||||
'info', 'shrs', # Yahoo Finance
|
||||
'income', 'assets', 'liabilities', 'operating', 'investing', 'financing', # MW
|
||||
'overview', 'key', 'incom', 'balance', 'cash', 'earnings', # AV
|
||||
'profile', 'quote', 'enterprise', 'dcf', # FMP
|
||||
@@ -139,7 +140,7 @@ def fa_menu(s_ticker, s_start, s_interval):
|
||||
return True
|
||||
|
||||
# BUSINESS INSIDER API
|
||||
elif ns_known_args.cmd == 'management':
|
||||
elif ns_known_args.cmd == 'mgmt':
|
||||
bi_api.management(l_args, s_ticker)
|
||||
|
||||
# FINVIZ API
|
||||
@@ -169,6 +170,9 @@ def fa_menu(s_ticker, s_start, s_interval):
|
||||
elif ns_known_args.cmd == 'info':
|
||||
yf_api.info(l_args, s_ticker)
|
||||
|
||||
elif ns_known_args.cmd == 'shrs':
|
||||
yf_api.shareholders(l_args, s_ticker)
|
||||
|
||||
# ALPHA VANTAGE API
|
||||
elif ns_known_args.cmd == 'overview':
|
||||
av_api.overview(l_args, s_ticker)
|
||||
|
||||
@@ -64,3 +64,52 @@ def info(l_args, s_ticker):
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
|
||||
# ---------------------------------------------------- SHAREHOLDERS ----------------------------------------------------
|
||||
def shareholders(l_args, s_ticker):
|
||||
parser = argparse.ArgumentParser(prog='shareholders',
|
||||
description="""Major, institutional and mutualfunds shareholders [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)
|
||||
pd.set_option('display.max_colwidth', -1)
|
||||
|
||||
# Major holders
|
||||
print("Major holders")
|
||||
df_major_holders = stock.major_holders
|
||||
df_major_holders[1] = df_major_holders[1].apply(lambda x: x.replace('%', 'Percentage'))
|
||||
print(df_major_holders.to_string(index=False, header=False))
|
||||
print("")
|
||||
|
||||
# Institutional holders
|
||||
print("Institutional holders")
|
||||
df_institutional_shareholders = stock.institutional_holders
|
||||
df_institutional_shareholders.columns = df_institutional_shareholders.columns.str.replace('% Out','Stake')
|
||||
df_institutional_shareholders['Shares'] = df_institutional_shareholders['Shares'].apply(lambda x: long_number_format(x))
|
||||
df_institutional_shareholders['Value'] = df_institutional_shareholders['Value'].apply(lambda x: long_number_format(x))
|
||||
df_institutional_shareholders['Stake'] = df_institutional_shareholders['Stake'].apply(lambda x: str("{:.2f}".format(100*x))+' %')
|
||||
print(df_institutional_shareholders.to_string(index=False))
|
||||
print("")
|
||||
|
||||
# Mutualfunds holders
|
||||
print("Mutualfunds holders")
|
||||
df_mutualfund_shareholders = stock.mutualfund_holders
|
||||
df_mutualfund_shareholders.columns = df_mutualfund_shareholders.columns.str.replace('% Out','Stake')
|
||||
df_mutualfund_shareholders['Shares'] = df_mutualfund_shareholders['Shares'].apply(lambda x: long_number_format(x))
|
||||
df_mutualfund_shareholders['Value'] = df_mutualfund_shareholders['Value'].apply(lambda x: long_number_format(x))
|
||||
df_mutualfund_shareholders['Stake'] = df_mutualfund_shareholders['Stake'].apply(lambda x: str("{:.2f}".format(100*x))+' %')
|
||||
print(df_mutualfund_shareholders.to_string(index=False))
|
||||
|
||||
print("")
|
||||
|
||||
except:
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user