Merge pull request #171 from DidierRLopes/add-losers

Add losers command on discovery menu
This commit is contained in:
DidierRLopes
2021-03-15 08:28:47 +00:00
committed by GitHub
5 changed files with 73 additions and 6 deletions

View File

@@ -11,6 +11,7 @@
* [Prediction Techniques](#Prediction-Techniques)
* [Reports](#Reports)
* [Comparison Analysis](#Comparison-Analysis)
* [Exploratory Data Analysis](#Exploratory-Data-Analysis)
* [Portfolio Analysis](#Portfolio-Analysis)
* [Credit Analysis](#Credit-Analysis)
* [Cryptocurrencies](#Cryptocurrencies)
@@ -25,7 +26,7 @@
### Short term
- [ ] Top Losers (@didier)
- [x] Top Losers (@didier) - [PR #171](https://github.com/DidierRLopes/GamestonkTerminal/pull/171)
- [x] ARK orders (@aia) - [PR #140](https://github.com/DidierRLopes/GamestonkTerminal/pull/140)
### Long term
@@ -60,7 +61,7 @@
### Short term
- [ ] Rearrange FA menu to have AV and FMP as submenus (@didier)
- [x] Rearrange FA menu to have AV and FMP as submenus (@didier) - [PR #166](https://github.com/DidierRLopes/GamestonkTerminal/pull/166)
### Long term
@@ -105,17 +106,27 @@
---
## ComparisonAnalysis
## Comparison Analysis
### Short term
* [X] Add multi-ticker historical data comparison (@didier) - [PR #141](https://github.com/DidierRLopes/GamestonkTerminal/pull/141)
* [x] Add multi-ticker historical data comparison (@didier) - [PR #141](https://github.com/DidierRLopes/GamestonkTerminal/pull/141)
* [ ] Add multi-ticker financials comparison (@didier)
### Long term
---
## Exploratory Data Analysis
### Short term
* [ ] Statistical techniques applied to a stock share price (e.g. decompose seasonality, trend, level, auto-correlation, cusum, ...) (@didier)
* [ ] Hypothesis tests (e.g. Kurtosis, Jarques-Bera, ARCH, ADF, ...) (@didier)
### Long term
---
## Portfolio Analysis
@@ -164,7 +175,7 @@
### Short term
- [x] Add terminal flair (@aia) - [PR #131](https://github.com/DidierRLopes/GamestonkTerminal/pull/131)
- [ ] Prompt-toolkit (@ricleal) - [PR #142](https://github.com/DidierRLopes/GamestonkTerminal/)
- [x] Prompt-toolkit (@ricleal) - [PR #142](https://github.com/DidierRLopes/GamestonkTerminal/pull/142)
### Long term

View File

@@ -8,6 +8,8 @@ This menu aims to discover new stocks, and the usage of the following commands a
* show sectors performance [Alpha Vantage]
* [gainers](#gainers)
* show latest top gainers [Yahoo Finance]
* [losers](#losers)
* show latest top losers [Yahoo Finance]
* [orders](#orders)
* orders by Fidelity Customers [Fidelity]
* [ark_orders](#ark_orders)
@@ -60,6 +62,18 @@ Print up to 25 top ticker gainers in terminal. [Source: Yahoo Finance]
<img width="935" alt="Captura de ecrã 2021-02-20, às 11 46 09" src="https://user-images.githubusercontent.com/25267873/108594319-46b99c00-7371-11eb-877e-ef75d3ba472b.png">
## losers <a name="losers"></a>
```shell
usage: losers [-n {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}]
```
Print up to 25 top ticker losers in terminal. [Source: Yahoo Finance]
* -n : Number of the top losers stocks to retrieve. Default 5.
<img width="993" alt="Captura de ecrã 2021-03-14, às 20 23 21" src="https://user-images.githubusercontent.com/25267873/111083099-a421b280-8503-11eb-9bb0-c728ce1e313f.png">
## orders <a name="orders"></a>
```shell

View File

@@ -41,6 +41,10 @@ def get_ark_orders() -> DataFrame:
parsed_json = json.loads(parsed_script.string)
df_orders = pd.json_normalize(parsed_json["props"]["pageProps"]["arkTrades"])
if df_orders.empty:
return pd.DataFrame()
df_orders.drop(
[
"everything",
@@ -116,6 +120,10 @@ def ark_orders(l_args):
df_orders = get_ark_orders()
if df_orders.empty:
print("The ARK orders aren't anavilable at the moment.\n")
return
pd.set_option("mode.chained_assignment", None)
df_orders = add_order_total(df_orders.head(ns_parser.n_num))

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("")