Add discounted cash flow to fundamental analysis

This commit is contained in:
didier
2020-12-27 23:53:09 +00:00
parent 070d79fbeb
commit d24d60cea2
2 changed files with 45 additions and 2 deletions

View File

@@ -63,6 +63,7 @@ def print_help(s_ticker, s_start, s_interval, b_is_market_open):
#print("- details - ")
print(" profile profile of the company")
print(" rating rating of the company from strong sell to strong buy")
print(" dcf discounted cash flow of the company")
# print("- financial statement -")
print(" income income statements of the company (default: AV)")
print(" balance balance sheet of the company (default: AV)")
@@ -128,7 +129,7 @@ def main():
'sma', 'ema', 'macd', 'vwap', 'stoch', 'rsi', 'adx', 'quote',
'cci', 'aroon', 'bbands', 'ad', 'obv', 'rating', 'profile',
'income', 'balance', 'cash', 'metrics', 'ratios', 'growth',
'enterprise'])
'enterprise', 'dcf'])
# Print first welcome message and help
print("\nWelcome to Didier's Stock Market Bot\n")
@@ -205,11 +206,16 @@ def main():
smfa.enterprise(l_args, s_ticker)
continue
# --------------------------------------------------- RATING --------------------------------------------------
# --------------------------------------------------- RATING ----------------------------------------------------
elif ns_known_args.cmd == 'rating':
smfa.rating(l_args, s_ticker)
continue
# --------------------------------------------- DISCOUNTED CASH FLOW -----------------------------------------------
elif ns_known_args.cmd == 'dcf':
smfa.discounted_cash_flow(l_args, s_ticker)
continue
# ----------------------------------------------- INCOME_STATEMENT -----------------------------------------------
elif ns_known_args.cmd == 'income':
smfa.income_statement(l_args, s_ticker)

View File

@@ -123,6 +123,43 @@ def rating(l_args, s_ticker):
print("")
# ------------------------------------------ DISCOUNTED CASH FLOW ------------------------------------------------------
def discounted_cash_flow(l_args, s_ticker):
parser = argparse.ArgumentParser(prog='dcf',
description=""" """)
parser.add_argument('-n', "--num", action="store", dest="n_num", type=check_positive, default=1, help='Number of latest info')
parser.add_argument('-q', action="store_true", default=False, dest="b_quarter", help='Quarter fundamental data')
try:
(ns_parser, l_unknown_args) = parser.parse_known_args(l_args)
except SystemExit:
print("")
return
if l_unknown_args:
print(f"The following args couldn't be interpreted: {l_unknown_args}")
if ns_parser.n_num == 1:
pd.set_option('display.max_colwidth', -1)
else:
pd.options.display.max_colwidth = 40
try:
if ns_parser.b_quarter:
df_fa = fa.discounted_cash_flow(s_ticker, cfg.API_KEY_FINANCIALMODELINGPREP, period='quarter')
else:
df_fa = fa.discounted_cash_flow(s_ticker, cfg.API_KEY_FINANCIALMODELINGPREP)
df_fa = df_fa.iloc[:, 0:ns_parser.n_num]
df_fa = df_fa.applymap(lambda x: long_number_format(x))
df_fa.index = [''.join(' ' + char if char.isupper() else char.strip() for char in idx).strip() for idx in df_fa.index.tolist()]
df_fa.index = [s_val.capitalize() for s_val in df_fa.index]
print(df_fa)
print("")
except:
print("")
# ---------------------------------------------------- INCOME_STATEMENT ----------------------------------------------------
def income_statement(l_args, s_ticker):
parser = argparse.ArgumentParser(prog='income',