Add top losers

This commit is contained in:
didier
2021-03-14 20:24:55 +00:00
parent 207a32ce5e
commit 9502ab599b
2 changed files with 35 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ def print_discovery():
print(" map S&P500 index stocks map [Finviz]")
print(" sectors show sectors performance [Alpha Vantage]")
print(" gainers show latest top gainers [Yahoo Finance]")
print(" losers show latest top losers [Yahoo Finance]")
print(" orders orders by Fidelity Customers [Fidelity]")
print(" ark_orders orders by ARK Investment Management LLC")
print(" up_earnings upcoming earnings release dates [Seeking Alpha]")
@@ -56,6 +57,7 @@ def disc_menu():
"map",
"sectors",
"gainers",
"losers",
"spacs",
"orders",
"ark_orders",
@@ -111,6 +113,9 @@ def disc_menu():
elif ns_known_args.cmd == "gainers":
yahoo_finance_api.gainers(l_args)
elif ns_known_args.cmd == "losers":
yahoo_finance_api.losers(l_args)
elif ns_known_args.cmd == "spachero":
spachero_api.spachero(l_args)

View File

@@ -7,7 +7,7 @@ def gainers(l_args):
parser = argparse.ArgumentParser(
add_help=False,
prog="gainers",
description="Print up to 25 top ticker gainers in terminal. [Source: Yahoo Finance]",
description="Print up to 25 top ticker gainers. [Source: Yahoo Finance]",
)
parser.add_argument(
@@ -30,3 +30,32 @@ def gainers(l_args):
)[0]
print(df_gainers.head(ns_parser.n_gainers).to_string(index=False))
print("")
def losers(l_args):
parser = argparse.ArgumentParser(
add_help=False,
prog="losers",
description="Print up to 25 top ticker losers. [Source: Yahoo Finance]",
)
parser.add_argument(
"-n",
"--num",
action="store",
dest="n_losers",
type=int,
default=5,
choices=range(1, 25),
help="Number of the top losers stocks to retrieve.",
)
ns_parser = parse_known_args_and_warn(parser, l_args)
if not ns_parser:
return
df_losers = pd.read_html(
"https://finance.yahoo.com/screener/predefined/day_losers"
)[0]
print(df_losers.head(ns_parser.n_losers).to_string(index=False))
print("")