mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Improve overall code menu ordering and comments
This commit is contained in:
@@ -10,14 +10,8 @@
|
||||
using an API request.
|
||||
|
||||
Finviz for data
|
||||
|
||||
Check AlphaVantage for TA as well.
|
||||
Add s_ylabel and s_legend to plot_ta or plot_stock_ta
|
||||
|
||||
Daily Stock vs Intraday 5min Stock
|
||||
Only show menu that allow daily TA or intraday TA,
|
||||
i.e. if daily Stock don't show VWAP bc doesn't make sense!
|
||||
Fix the 'help' params
|
||||
Parse overview stock with pip request
|
||||
Multiple TA with kind stock
|
||||
|
||||
"""
|
||||
|
||||
@@ -59,37 +53,42 @@ def print_help(s_ticker, s_start, s_interval, b_is_market_open):
|
||||
print("\nStock: ?")
|
||||
|
||||
if s_ticker:
|
||||
print("\nFundamental Analysis:")
|
||||
print("- details - ")
|
||||
print("\nFundamental Analysis:") # https://github.com/JerBouma/FundamentalAnalysis
|
||||
print("details:")
|
||||
print(" profile profile of the company [FMP]")
|
||||
print(" rating rating of the company from strong sell to strong buy [FMP]")
|
||||
print(" quote quote of the company [FMP]")
|
||||
print(" enterprise enterprise value of the company over time [FMP]")
|
||||
print(" dcf discounted cash flow of the company over time [FMP]")
|
||||
print("- financial statement -")
|
||||
print("financial statement:")
|
||||
print(" income income statements of the company [default: AV, FMP]")
|
||||
print(" balance balance sheet of the company [default: AV, FMP]")
|
||||
print(" cash cash flow of the company [default: AV, FMP]")
|
||||
print("- ratios -")
|
||||
print(" metrics key metrics of the company")
|
||||
print(" ratios financial ratios of the company")
|
||||
print(" growth financial statement growth of the company")
|
||||
print("ratios:")
|
||||
print(" metrics key metrics of the company [FMP]")
|
||||
print(" ratios financial ratios of the company [FMP]")
|
||||
print(" growth financial statement growth of the company [FMP]")
|
||||
|
||||
print("\nTechnical Analysis:")
|
||||
print(" sma simple moving average")
|
||||
print("\nTechnical Analysis:") # https://github.com/twopirllc/pandas-ta
|
||||
print("overlap:")
|
||||
print(" ema exponential moving average")
|
||||
print(" macd moving average convergence/divergence")
|
||||
print(" stoch stochastic oscillator")
|
||||
print(" rsi relative strength index")
|
||||
print(" adx average directional movement index")
|
||||
print(" cci commodity channel index")
|
||||
print(" aroon aroon indicator")
|
||||
print(" bbands bollinger bands")
|
||||
print(" ad chaikin accumulation/distribution line values")
|
||||
print(" obv on balance volume")
|
||||
print(" sma simple moving average")
|
||||
if s_interval != "1440min":
|
||||
print(" vwap volume weighted average price")
|
||||
|
||||
print("momentum:")
|
||||
print(" cci commodity channel index")
|
||||
print(" macd moving average convergence/divergence")
|
||||
print(" rsi relative strength index")
|
||||
print(" stoch stochastic oscillator")
|
||||
print("trend:")
|
||||
print(" adx average directional movement index")
|
||||
print(" aroon aroon indicator")
|
||||
print("volatility:")
|
||||
print(" bbands bollinger bands")
|
||||
print("volume:")
|
||||
print(" ad chaikin accumulation/distribution line values")
|
||||
print(" obv on balance volume")
|
||||
|
||||
'''
|
||||
print("\nPrediction:")
|
||||
print(" ma")
|
||||
@@ -244,62 +243,55 @@ def main():
|
||||
# -------------------------------------------- TECHNICAL ANALYSIS ----------------------------------------------
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# ---------------------------------------------------- SMA ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'sma':
|
||||
smta.sma(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ---------------------------------------------------- EMA ----------------------------------------------------
|
||||
# -------------------------------------------------- OVERLAP --------------------------------------------------
|
||||
elif ns_known_args.cmd == 'ema':
|
||||
smta.ema(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ---------------------------------------------------- MACD ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'macd':
|
||||
smta.macd(l_args, s_ticker, s_interval, df_stock)
|
||||
elif ns_known_args.cmd == 'sma':
|
||||
smta.sma(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ---------------------------------------------------- VWAP ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'vwap':
|
||||
smta.vwap(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ---------------------------------------------------- STOCH ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'stoch':
|
||||
smta.stoch(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ---------------------------------------------------- RSI ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'rsi':
|
||||
smta.rsi(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ---------------------------------------------------- ADX ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'adx':
|
||||
smta.adx(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ---------------------------------------------------- CCI ----------------------------------------------------
|
||||
# --------------------------------------------------- MOMENTUM ---------------------------------------------------
|
||||
elif ns_known_args.cmd == 'cci':
|
||||
smta.cci(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# --------------------------------------------------- AROON ---------------------------------------------------
|
||||
elif ns_known_args.cmd == 'macd':
|
||||
smta.macd(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
elif ns_known_args.cmd == 'rsi':
|
||||
smta.rsi(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
elif ns_known_args.cmd == 'stoch':
|
||||
smta.stoch(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ---------------------------------------------------- TREND ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'adx':
|
||||
smta.adx(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
elif ns_known_args.cmd == 'aroon':
|
||||
smta.aroon(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# --------------------------------------------------- BBANDS ---------------------------------------------------
|
||||
# -------------------------------------------------- VOLATILITY --------------------------------------------------
|
||||
elif ns_known_args.cmd == 'bbands':
|
||||
smta.bbands(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ----------------------------------------------------- AD -----------------------------------------------------
|
||||
# ---------------------------------------------------- VOLUME ----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'ad':
|
||||
smta.ad(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
# ---------------------------------------------------- OBV -----------------------------------------------------
|
||||
elif ns_known_args.cmd == 'obv':
|
||||
smta.obv(l_args, s_ticker, s_interval, df_stock)
|
||||
continue
|
||||
|
||||
@@ -175,13 +175,21 @@ def discounted_cash_flow(l_args, s_ticker):
|
||||
print(df_fa)
|
||||
print("")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
|
||||
|
||||
# ---------------------------------------------------- INCOME_STATEMENT ----------------------------------------------------
|
||||
def income_statement(l_args, s_ticker):
|
||||
parser = argparse.ArgumentParser(prog='income',
|
||||
description=""" """)
|
||||
description="""Collects a complete income statement over time. This can be either quarterly
|
||||
or annually. The following fields are expected: Accepted date, Cost and expenses, Cost of
|
||||
revenue, Depreciation and amortization, Ebitda, Ebitdaratio, Eps, Epsdiluted, Filling date,
|
||||
Final link, General and administrative expenses, Gross profit, Gross profit ratio, Income
|
||||
before tax, Income before tax ratio, Income tax expense, Interest expense, Link, Net income,
|
||||
Net income ratio, Operating expenses, Operating income, Operating income ratio, Other expenses,
|
||||
Period, Research and development expenses, Revenue, Selling and marketing expenses, Total other
|
||||
income expenses net, Weighted average shs out, Weighted average shs out dil [Default source:
|
||||
Alpha Vantage API; Other possible source: Financial Modeling Prep API]""")
|
||||
|
||||
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')
|
||||
@@ -216,6 +224,14 @@ def income_statement(l_args, s_ticker):
|
||||
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]
|
||||
df_fa.columns.name = "Fiscal Date Ending"
|
||||
print(df_fa.drop(index=['Final link', 'Link']).to_string())
|
||||
|
||||
pd.set_option('display.max_colwidth', -1)
|
||||
print("")
|
||||
print(df_fa.loc['Final link'].to_frame().to_string())
|
||||
print("")
|
||||
print(df_fa.loc['Link'].to_frame().to_string())
|
||||
|
||||
# Use Alpha Vantage API
|
||||
else:
|
||||
fd = FundamentalData(key=cfg.API_KEY_ALPHAVANTAGE, output_format='pandas')
|
||||
@@ -232,17 +248,29 @@ def income_statement(l_args, s_ticker):
|
||||
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]
|
||||
df_fa.columns.name = "Fiscal Date Ending"
|
||||
|
||||
print(df_fa)
|
||||
print(df_fa)
|
||||
print("")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
# ---------------------------------------------------- BALANCE_SHEET ----------------------------------------------------
|
||||
def balance_sheet(l_args, s_ticker):
|
||||
parser = argparse.ArgumentParser(prog='balance',
|
||||
description=""" """)
|
||||
description="""Collects a complete balance sheet statement over time. This can be
|
||||
either quarterly or annually. The following fields are expected: Accepted date,
|
||||
Account payables, Accumulated other comprehensive income loss, Cash and cash
|
||||
equivalents, Cash and short term investments, Common stock, Deferred revenue,
|
||||
Deferred revenue non current, Deferred tax liabilities non current, Filling date,
|
||||
Final link, Goodwill, Goodwill and intangible assets, Intangible assets, Inventory,
|
||||
Link, Long term debt, Long term investments, Net debt, Net receivables, Other assets,
|
||||
Other current assets, Other current liabilities, Other liabilities, Other non current
|
||||
assets, Other non current liabilities, Othertotal stockholders equity, Period, Property
|
||||
plant equipment net, Retained earnings, Short term debt, Short term investments, Tax assets,
|
||||
Tax payables, Total assets, Total current assets, Total current liabilities, Total debt,
|
||||
Total investments, Total liabilities, Total liabilities and stockholders equity, Total
|
||||
non current assets, Total non current liabilities, and Total stockholders equity.
|
||||
[Default source: Alpha Vantage API; Other possible source: Financial Modeling Prep API]""")
|
||||
|
||||
parser.add_argument('-n', "--num", action="store", dest="n_num", type=check_positive, default=1, help='Number of informations')
|
||||
parser.add_argument('-q', action="store_true", default=False, dest="b_quarter", help='Quarter fundamental data')
|
||||
@@ -272,6 +300,13 @@ def balance_sheet(l_args, s_ticker):
|
||||
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]
|
||||
df_fa.columns.name = "Fiscal Date Ending"
|
||||
print(df_fa.drop(index=['Final link', 'Link']).to_string())
|
||||
|
||||
pd.set_option('display.max_colwidth', -1)
|
||||
print("")
|
||||
print(df_fa.loc['Final link'].to_frame().to_string())
|
||||
print("")
|
||||
print(df_fa.loc['Link'].to_frame().to_string())
|
||||
|
||||
# Use Alpha Vantage API
|
||||
else:
|
||||
@@ -289,18 +324,29 @@ def balance_sheet(l_args, s_ticker):
|
||||
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]
|
||||
df_fa.columns.name = "Fiscal Date Ending"
|
||||
print(df_fa)
|
||||
|
||||
print(df_fa)
|
||||
print("")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
# ---------------------------------------------------- CASH_FLOW ----------------------------------------------------
|
||||
def cash_flow(l_args, s_ticker):
|
||||
parser = argparse.ArgumentParser(prog='cash',
|
||||
description=""" """)
|
||||
description="""Collects a complete cash flow statement over time. This can be either
|
||||
quarterly or annually. The following fields are expected: Accepted date, Accounts payables,
|
||||
Accounts receivables, Acquisitions net, Capital expenditure, Cash at beginning of period,
|
||||
Cash at end of period, Change in working capital, Common stock issued, Common stock repurchased,
|
||||
Debt repayment, Deferred income tax, Depreciation and amortization, Dividends paid,
|
||||
Effect of forex changes on cash, Filling date, Final link, Free cash flow, Inventory,
|
||||
Investments in property plant and equipment, Link, Net cash provided by operating activities,
|
||||
Net cash used for investing activites, Net cash used provided by financing activities, Net
|
||||
change in cash, Net income, Operating cash flow, Other financing activites, Other investing
|
||||
activites, Other non cash items, Other working capital, Period, Purchases of investments,
|
||||
Sales maturities of investments, Stock based compensation. [Default source: Alpha Vantage API;
|
||||
Other possible source: Financial Modeling Prep API]""")
|
||||
|
||||
parser.add_argument('-n', "--num", action="store", dest="n_num", type=check_positive, default=1, help='Number of informations')
|
||||
parser.add_argument('-q', action="store_true", default=False, dest="b_quarter", help='Quarter fundamental data')
|
||||
@@ -335,6 +381,13 @@ def cash_flow(l_args, s_ticker):
|
||||
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]
|
||||
df_fa.columns.name = "Fiscal Date Ending"
|
||||
print(df_fa.drop(index=['Final link', 'Link']).to_string())
|
||||
|
||||
pd.set_option('display.max_colwidth', -1)
|
||||
print("")
|
||||
print(df_fa.loc['Final link'].to_frame().to_string())
|
||||
print("")
|
||||
print(df_fa.loc['Link'].to_frame().to_string())
|
||||
# Use Alpha Vantage API
|
||||
else:
|
||||
fd = FundamentalData(key=cfg.API_KEY_ALPHAVANTAGE, output_format='pandas')
|
||||
@@ -351,18 +404,33 @@ def cash_flow(l_args, s_ticker):
|
||||
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]
|
||||
df_fa.columns.name = "Fiscal Date Ending"
|
||||
print(df_fa)
|
||||
|
||||
print(df_fa)
|
||||
print("")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
# ---------------------------------------------------- KEY_METRICS ----------------------------------------------------
|
||||
def key_metrics(l_args, s_ticker):
|
||||
parser = argparse.ArgumentParser(prog='metrics',
|
||||
description=""" """)
|
||||
description="""Lists the key metrics (in total 57 metrics) of a company over time
|
||||
(annual and quarterly). This includes, among other things, Return on Equity (ROE),
|
||||
Working Capital, Current Ratio and Debt to Assets. The following fields are expected:
|
||||
Average inventory, Average payables, Average receivables, Book value per share, Capex
|
||||
per share, Capex to depreciation, Capex to operating cash flow, Capex to revenue, Cash
|
||||
per share, Current ratio, Days of inventory on hand, Days payables outstanding, Days sales
|
||||
outstanding, Debt to assets, Debt to equity, Dividend yield, Earnings yield, Enterprise value,
|
||||
Enterprise value over EBITDA, Ev to free cash flow, Ev to operating cash flow, Ev to sales,
|
||||
Free cash flow per share, Free cash flow yield, Graham net net, Graham number, Income quality,
|
||||
Intangibles to total assets, Interest debt per share, Inventory turnover, Market cap, Net
|
||||
current asset value, Net debt to EBITDA, Net income per share, Operating cash flow per share,
|
||||
Payables turnover, Payout ratio, Pb ratio, Pe ratio, Pfcf ratio, Pocfratio, Price to sales ratio,
|
||||
Ptb ratio, Receivables turnover, Research and ddevelopement to revenue, Return on tangible assets,
|
||||
Revenue per share, Roe, Roic, Sales general and administrative to revenue, Shareholders equity per
|
||||
share, Stock based compensation to revenue, Tangible book value per share, and Working capital.
|
||||
[Source: Financial Modeling Prep API]""")
|
||||
|
||||
parser.add_argument('-n', "--num", action="store", dest="n_num", type=check_positive, default=1, help='Number of informations')
|
||||
parser.add_argument('-q', action="store_true", default=False, dest="b_quarter", help='Quarter fundamental data')
|
||||
@@ -380,7 +448,7 @@ def key_metrics(l_args, s_ticker):
|
||||
if ns_parser.n_num == 1:
|
||||
pd.set_option('display.max_colwidth', -1)
|
||||
else:
|
||||
pd.options.display.max_colwidth = 40
|
||||
pd.options.display.max_colwidth = 50
|
||||
|
||||
if ns_parser.b_quarter:
|
||||
df_fa = fa.key_metrics(s_ticker, cfg.API_KEY_FINANCIALMODELINGPREP, period='quarter')
|
||||
@@ -394,18 +462,35 @@ def key_metrics(l_args, s_ticker):
|
||||
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]
|
||||
df_fa.columns.name = "Fiscal Date Ending"
|
||||
|
||||
df_fa = df_fa.rename(index={"Enterprise value over e b i t d a": "Enterprise value over EBITDA"})
|
||||
df_fa = df_fa.rename(index={"Net debt to e b i t d a": "Net debt to EBITDA"})
|
||||
print(df_fa)
|
||||
print("")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
# ---------------------------------------------------- FINANCIAL_RATIOS ----------------------------------------------------
|
||||
def financial_ratios(l_args, s_ticker):
|
||||
parser = argparse.ArgumentParser(prog='ratios',
|
||||
description=""" """)
|
||||
description="""Includes in-depth ratios (in total 57 ratios) of a company over time
|
||||
(annual and quarterly). This contains, among other things, Price-to-Book Ratio, Payout
|
||||
Ratio and Operating Cycle. The following fields are expected: Asset turnover, Capital
|
||||
expenditure coverage ratio, Cash conversion cycle, Cash flow coverage ratios, Cash flow
|
||||
to debt ratio, Cash per share, Cash ratio, Company equity multiplier, Current ratio,
|
||||
Days of inventory outstanding, Days of payables outstanding, Days of sales outstanding,
|
||||
Debt equity ratio, Debt ratio, Dividend paid and capex coverage ratio, Dividend payout ratio,
|
||||
Dividend yield, Ebit per revenue, Ebt per ebit, Effective tax rate, Enterprise value multiple,
|
||||
Fixed asset turnover, Free cash flow operating cash flow ratio, Free cash flow per share, Gross
|
||||
profit margin, Inventory turnover, Long term debt to capitalization, Net income per EBT, Net
|
||||
profit margin, Operating cash flow per share, Operating cash flow sales ratio, Operating cycle,
|
||||
Operating profit margin, Payables turnover, Payout ratio, Pretax profit margin, Price book value
|
||||
ratio, Price cash flow ratio, Price earnings ratio, Price earnings to growth ratio, Price fair value,
|
||||
Price sales ratio, Price to book ratio, Price to free cash flows ratio, Price to operating cash flows
|
||||
ratio, Price to sales ratio, Quick ratio, Receivables turnover, Return on assets, Return on capital
|
||||
employed, Return on equity, Short term coverage ratios, and Total debt to capitalization.
|
||||
[Source: Financial Modeling Prep API]""")
|
||||
|
||||
parser.add_argument('-n', "--num", action="store", dest="n_num", type=check_positive, default=1, help='Number of informations')
|
||||
parser.add_argument('-q', action="store_true", default=False, dest="b_quarter", help='Quarter fundamental data')
|
||||
@@ -437,18 +522,32 @@ def financial_ratios(l_args, s_ticker):
|
||||
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]
|
||||
df_fa.columns.name = "Fiscal Date Ending"
|
||||
df_fa = df_fa.rename(index={"Net income per e b t": "Net income per EBT"})
|
||||
|
||||
print(df_fa)
|
||||
print("")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
# ---------------------------------------------------- FINANCIAL_STATEMENT_GROWTH ----------------------------------------------------
|
||||
def financial_statement_growth(l_args, s_ticker):
|
||||
parser = argparse.ArgumentParser(prog='growth',
|
||||
description=""" """)
|
||||
description="""Measures the growth of several financial statement items and ratios over time
|
||||
(annual and quarterly). These are, among other things, Revenue Growth (3, 5 and 10 years),
|
||||
inventory growth and operating cash flow growth (3, 5 and 10 years). The following fields
|
||||
are expected: Asset growth, Book valueper share growth, Debt growth, Dividendsper share growth,
|
||||
Ebitgrowth, Epsdiluted growth, Epsgrowth, Five y dividendper share growth per share, Five y net
|
||||
income growth per share, Five y operating c f growth per share, Five y revenue growth per share,
|
||||
Five y shareholders equity growth per share, Free cash flow growth, Gross profit growth, Inventory
|
||||
growth, Net income growth, Operating cash flow growth, Operating income growth, Rdexpense growth,
|
||||
Receivables growth, Revenue growth, Sgaexpenses growth, Ten y dividendper share growth per share,
|
||||
Ten y net income growth per share, Ten y operating c f growth per share, Ten y revenue growth per
|
||||
share, Ten y shareholders equity growth per share, Three y dividendper share growth per share,
|
||||
Three y net income growth per share, Three y operating c f growth per share, Three y revenue growth
|
||||
per share, Three y shareholders equity growth per share, Weighted average shares diluted growth,
|
||||
and Weighted average shares growth [Source: Financial Modeling Prep API]""")
|
||||
|
||||
parser.add_argument('-n', "--num", action="store", dest="n_num", type=check_positive, default=1, help='Number of informations')
|
||||
parser.add_argument('-q', action="store_true", default=False, dest="b_quarter", help='Quarter fundamental data')
|
||||
@@ -466,7 +565,7 @@ def financial_statement_growth(l_args, s_ticker):
|
||||
if ns_parser.n_num == 1:
|
||||
pd.set_option('display.max_colwidth', -1)
|
||||
else:
|
||||
pd.options.display.max_colwidth = 40
|
||||
pd.options.display.max_colwidth = 50
|
||||
|
||||
if ns_parser.b_quarter:
|
||||
df_fa = fa.financial_statement_growth(s_ticker, cfg.API_KEY_FINANCIALMODELINGPREP, period='quarter')
|
||||
@@ -484,6 +583,5 @@ def financial_statement_growth(l_args, s_ticker):
|
||||
print(df_fa)
|
||||
print("")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
@@ -5,44 +5,6 @@ import pandas_ta as ta
|
||||
import config_bot as cfg
|
||||
from stock_market_helper_funcs import *
|
||||
|
||||
|
||||
# ----------------------------------------------------- SMA -----------------------------------------------------
|
||||
def sma(l_args, s_ticker, s_interval, df_stock):
|
||||
parser = argparse.ArgumentParser(prog='sma',
|
||||
description=""" Moving Averages are used to smooth the data in an array to
|
||||
help eliminate noise and identify trends. The Simple Moving Average is literally
|
||||
the simplest form of a moving average. Each output value is the average of the
|
||||
previous n values. In a Simple Moving Average, each value in the time period carries
|
||||
equal weight, and values outside of the time period are not included in the average.
|
||||
This makes it less responsive to recent changes in the data, which can be useful for
|
||||
filtering out those changes. """)
|
||||
|
||||
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=10, help='length')
|
||||
parser.add_argument('-o', "--offset", action="store", dest="n_offset", type=check_positive, default=0, help='offset')
|
||||
|
||||
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}")
|
||||
|
||||
try:
|
||||
# Daily
|
||||
if s_interval == "1440min":
|
||||
df_ta = ta.sma(df_stock['5. adjusted close'], length=ns_parser.n_length, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_ta(df_stock['5. adjusted close'], s_ticker, df_ta, "SMA")
|
||||
# Intraday
|
||||
else:
|
||||
df_ta = ta.sma(df_stock['4. close'], length=ns_parser.n_length, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, "SMA")
|
||||
except:
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
# ----------------------------------------------------- EMA -----------------------------------------------------
|
||||
def ema(l_args, s_ticker, s_interval, df_stock):
|
||||
parser = argparse.ArgumentParser(prog='ema',
|
||||
@@ -77,8 +39,110 @@ def ema(l_args, s_ticker, s_interval, df_stock):
|
||||
df_ta = ta.ema(df_stock['4. close'], length=ns_parser.n_length, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, "EMA")
|
||||
except:
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
# ----------------------------------------------------- SMA -----------------------------------------------------
|
||||
def sma(l_args, s_ticker, s_interval, df_stock):
|
||||
parser = argparse.ArgumentParser(prog='sma',
|
||||
description=""" Moving Averages are used to smooth the data in an array to
|
||||
help eliminate noise and identify trends. The Simple Moving Average is literally
|
||||
the simplest form of a moving average. Each output value is the average of the
|
||||
previous n values. In a Simple Moving Average, each value in the time period carries
|
||||
equal weight, and values outside of the time period are not included in the average.
|
||||
This makes it less responsive to recent changes in the data, which can be useful for
|
||||
filtering out those changes. """)
|
||||
|
||||
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=10, help='length')
|
||||
parser.add_argument('-o', "--offset", action="store", dest="n_offset", type=check_positive, default=0, help='offset')
|
||||
|
||||
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}")
|
||||
|
||||
try:
|
||||
# Daily
|
||||
if s_interval == "1440min":
|
||||
df_ta = ta.sma(df_stock['5. adjusted close'], length=ns_parser.n_length, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_ta(df_stock['5. adjusted close'], s_ticker, df_ta, "SMA")
|
||||
# Intraday
|
||||
else:
|
||||
df_ta = ta.sma(df_stock['4. close'], length=ns_parser.n_length, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, "SMA")
|
||||
except:
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
# ----------------------------------------------------- VWAP -----------------------------------------------------
|
||||
def vwap(l_args, s_ticker, s_interval, df_stock):
|
||||
parser = argparse.ArgumentParser(prog='vwap',
|
||||
description=""" The Volume Weighted Average Price that measures the average typical price
|
||||
by volume. It is typically used with intraday charts to identify general direction. """)
|
||||
|
||||
parser.add_argument('-o', "--offset", action="store", dest="n_offset", type=check_positive, default=0, help='offset')
|
||||
|
||||
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}")
|
||||
|
||||
try:
|
||||
df_ta = ta.vwap(high=df_stock['2. high'], low=df_stock['3. low'], close=df_stock['4. close'],
|
||||
volume=df_stock['5. volume'], offset=ns_parser.n_offset)
|
||||
|
||||
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, "VWAP")
|
||||
except:
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
# ----------------------------------------------------- CCI -----------------------------------------------------
|
||||
def cci(l_args, s_ticker, s_interval, df_stock):
|
||||
parser = argparse.ArgumentParser(prog='cci',
|
||||
description=""" The CCI is designed to detect beginning and ending market trends.
|
||||
The range of 100 to -100 is the normal trading range. CCI values outside of this
|
||||
range indicate overbought or oversold conditions. You can also look for price
|
||||
divergence in the CCI. If the price is making new highs, and the CCI is not,
|
||||
then a price correction is likely. """)
|
||||
|
||||
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=14, help='length')
|
||||
parser.add_argument('-s', "--scalar", action="store", dest="n_scalar", type=check_positive, default=0.015, help='scalar')
|
||||
parser.add_argument('-o', "--offset", action="store", dest="n_offset", type=check_positive, default=0, help='offset')
|
||||
|
||||
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}")
|
||||
|
||||
try:
|
||||
# Daily
|
||||
if s_interval == "1440min":
|
||||
df_ta = ta.cci(high=df_stock['2. high'], low=df_stock['3. low'], close=df_stock['5. adjusted close'],
|
||||
length=ns_parser.n_length, scalar=ns_parser.n_scalar, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['5. adjusted close'], s_ticker, df_ta, "CCI")
|
||||
# Intraday
|
||||
else:
|
||||
df_ta = ta.cci(high=df_stock['2. high'], low=df_stock['3. low'], close=df_stock['4. close'],
|
||||
length=ns_parser.n_length, scalar=ns_parser.n_scalar, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "CCI")
|
||||
except:
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
# ----------------------------------------------------- MACD -----------------------------------------------------
|
||||
@@ -124,16 +188,22 @@ def macd(l_args, s_ticker, s_interval, df_stock):
|
||||
signal=ns_parser.n_signal, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "MACD")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
# ----------------------------------------------------- VWAP -----------------------------------------------------
|
||||
def vwap(l_args, s_ticker, s_interval, df_stock):
|
||||
parser = argparse.ArgumentParser(prog='vwap',
|
||||
description=""" The Volume Weighted Average Price that measures the average typical price
|
||||
by volume. It is typically used with intraday charts to identify general direction. """)
|
||||
# ----------------------------------------------------- RSI -----------------------------------------------------
|
||||
def rsi(l_args, s_ticker, s_interval, df_stock):
|
||||
parser = argparse.ArgumentParser(prog='rsi',
|
||||
description=""" The Relative Strength Index (RSI) calculates a ratio of the
|
||||
recent upward price movements to the absolute price movement. The RSI ranges
|
||||
from 0 to 100. The RSI is interpreted as an overbought/oversold indicator when
|
||||
the value is over 70/below 30. You can also look for divergence with price. If
|
||||
the price is making new highs/lows, and the RSI is not, it indicates a reversal. """)
|
||||
|
||||
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=14, help='length')
|
||||
parser.add_argument('-s', "--scalar", action="store", dest="n_scalar", type=check_positive, default=100, help='scalar')
|
||||
parser.add_argument('-d', "--drift", action="store", dest="n_drift", type=check_positive, default=1, help='drift')
|
||||
parser.add_argument('-o', "--offset", action="store", dest="n_offset", type=check_positive, default=0, help='offset')
|
||||
|
||||
try:
|
||||
@@ -146,12 +216,18 @@ def vwap(l_args, s_ticker, s_interval, df_stock):
|
||||
print(f"The following args couldn't be interpreted: {l_unknown_args}")
|
||||
|
||||
try:
|
||||
df_ta = ta.vwap(high=df_stock['2. high'], low=df_stock['3. low'], close=df_stock['4. close'],
|
||||
volume=df_stock['5. volume'], offset=ns_parser.n_offset)
|
||||
|
||||
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, "VWAP")
|
||||
# Daily
|
||||
if s_interval == "1440min":
|
||||
df_ta = ta.rsi(df_stock['5. adjusted close'], length=ns_parser.n_length, scalar=ns_parser.n_scalar,
|
||||
drift=ns_parser.n_drift, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['5. adjusted close'], s_ticker, df_ta, "RSI")
|
||||
# Intraday
|
||||
else:
|
||||
df_ta = ta.rsi(df_stock['4. close'], length=ns_parser.n_length, scalar=ns_parser.n_scalar,
|
||||
drift=ns_parser.n_drift, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "RSI")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
@@ -194,46 +270,7 @@ def stoch(l_args, s_ticker, s_interval, df_stock):
|
||||
d=ns_parser.n_slowdperiod, smooth_k=ns_parser.n_slowkperiod, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "STOCH")
|
||||
except:
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
# ----------------------------------------------------- RSI -----------------------------------------------------
|
||||
def rsi(l_args, s_ticker, s_interval, df_stock):
|
||||
parser = argparse.ArgumentParser(prog='rsi',
|
||||
description=""" The Relative Strength Index (RSI) calculates a ratio of the
|
||||
recent upward price movements to the absolute price movement. The RSI ranges
|
||||
from 0 to 100. The RSI is interpreted as an overbought/oversold indicator when
|
||||
the value is over 70/below 30. You can also look for divergence with price. If
|
||||
the price is making new highs/lows, and the RSI is not, it indicates a reversal. """)
|
||||
|
||||
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=14, help='length')
|
||||
parser.add_argument('-s', "--scalar", action="store", dest="n_scalar", type=check_positive, default=100, help='scalar')
|
||||
parser.add_argument('-d', "--drift", action="store", dest="n_drift", type=check_positive, default=1, help='drift')
|
||||
parser.add_argument('-o', "--offset", action="store", dest="n_offset", type=check_positive, default=0, help='offset')
|
||||
|
||||
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}")
|
||||
|
||||
try:
|
||||
# Daily
|
||||
if s_interval == "1440min":
|
||||
df_ta = ta.rsi(df_stock['5. adjusted close'], length=ns_parser.n_length, scalar=ns_parser.n_scalar,
|
||||
drift=ns_parser.n_drift, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['5. adjusted close'], s_ticker, df_ta, "RSI")
|
||||
# Intraday
|
||||
else:
|
||||
df_ta = ta.rsi(df_stock['4. close'], length=ns_parser.n_length, scalar=ns_parser.n_scalar,
|
||||
drift=ns_parser.n_drift, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "RSI")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
@@ -271,45 +308,7 @@ def adx(l_args, s_ticker, s_interval, df_stock):
|
||||
scalar=ns_parser.n_scalar, drift=ns_parser.n_drift, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "ADX")
|
||||
except:
|
||||
print("")
|
||||
return
|
||||
|
||||
|
||||
# ----------------------------------------------------- CCI -----------------------------------------------------
|
||||
def cci(l_args, s_ticker, s_interval, df_stock):
|
||||
parser = argparse.ArgumentParser(prog='cci',
|
||||
description=""" The CCI is designed to detect beginning and ending market trends.
|
||||
The range of 100 to -100 is the normal trading range. CCI values outside of this
|
||||
range indicate overbought or oversold conditions. You can also look for price
|
||||
divergence in the CCI. If the price is making new highs, and the CCI is not,
|
||||
then a price correction is likely. """)
|
||||
|
||||
parser.add_argument('-l', "--length", action="store", dest="n_length", type=check_positive, default=14, help='length')
|
||||
parser.add_argument('-s', "--scalar", action="store", dest="n_scalar", type=check_positive, default=0.015, help='scalar')
|
||||
parser.add_argument('-o', "--offset", action="store", dest="n_offset", type=check_positive, default=0, help='offset')
|
||||
|
||||
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}")
|
||||
|
||||
try:
|
||||
# Daily
|
||||
if s_interval == "1440min":
|
||||
df_ta = ta.cci(high=df_stock['2. high'], low=df_stock['3. low'], close=df_stock['5. adjusted close'],
|
||||
length=ns_parser.n_length, scalar=ns_parser.n_scalar, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['5. adjusted close'], s_ticker, df_ta, "CCI")
|
||||
# Intraday
|
||||
else:
|
||||
df_ta = ta.cci(high=df_stock['2. high'], low=df_stock['3. low'], close=df_stock['4. close'],
|
||||
length=ns_parser.n_length, scalar=ns_parser.n_scalar, offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "CCI")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
@@ -350,7 +349,7 @@ def aroon(l_args, s_ticker, s_interval, df_stock):
|
||||
else:
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta.iloc[:,-1], "AROON")
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
@@ -395,7 +394,7 @@ def bbands(l_args, s_ticker, s_interval, df_stock):
|
||||
plot_stock_ta(df_stock['4. close'], s_ticker, df_ta, "BBANDS")
|
||||
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
@@ -452,7 +451,7 @@ def ad(l_args, s_ticker, s_interval, df_stock):
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "AD")
|
||||
|
||||
except:
|
||||
print("")
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
|
||||
@@ -488,5 +487,5 @@ def obv(l_args, s_ticker, s_interval, df_stock):
|
||||
df_ta = ta.ad(close=df_stock['4. close'], volume=df_stock['5. volume'], offset=ns_parser.n_offset).dropna()
|
||||
plot_stock_and_ta(df_stock['4. close'], s_ticker, df_ta, "OBV")
|
||||
except:
|
||||
print("")
|
||||
return
|
||||
print("ERROR!\n")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user