diff --git a/ROADMAP.md b/ROADMAP.md index cfadc363bc9..ee364bea04a 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -257,7 +257,12 @@ ___ **NEXT** --- +## ETF +* [x] Add ETF data (@jmaslek) [PR #??]() +**NEXT** + +--- ## Backend **NEXT** diff --git a/gamestonk_terminal/README.md b/gamestonk_terminal/README.md index 7a16eb56def..7274f6bfdbb 100644 --- a/gamestonk_terminal/README.md +++ b/gamestonk_terminal/README.md @@ -22,6 +22,7 @@ * [Backtesting](#Backtesting-) * [Resource Collection](#Resource-Collection-) * [Government](#Government-) +* [ETF](#ETF-) ## Main @@ -469,3 +470,12 @@ with ticker provided | `house` | house trades on the ticker   + +## ETF [»](etf/README.md) +command|description +---|---- +`web`|open webbroswer to stockanalysis.com +`search`|search for ETFs matching an input +`overview`|get ETF overview +`holdings`|show ETF holdings +`compare`|compare multiple ETFs overview diff --git a/gamestonk_terminal/etf/README.md b/gamestonk_terminal/etf/README.md index d998f368a1a..e2fd6a6894c 100644 --- a/gamestonk_terminal/etf/README.md +++ b/gamestonk_terminal/etf/README.md @@ -1,19 +1,19 @@ # ETF -Menu for Exchange Traded Funds. +Menu for Exchange Traded Funds. Data is currently scraped from StockAnalysis.com/etf * [web](#web) * open webbroswer to stockanalysis.com * [search](#search) - * search for ETFS matching an input + * search for ETFs matching an input * [overview](#overview) * get ETF overview * [holdings](#holdings) * show ETF holdings * [compare](#compare) * compare multiple ETFs overview - + ## web ```python usage: web @@ -25,7 +25,86 @@ Opens StockAnalysis.com/etf. This site shows all avalaiable ETFs (currently > 2 usage: search [-n --name] ``` Search for ETFs matching -* -n/--name : Name to search for. Can be a company or other +* -n/--name : Name to search for. Can be a company or other search term +Example Usage: Search for all ETFs that deal with AI +```python +(✨) (etf)> search artificial intelligence +BOTZ - Global X Robotics & Artificial Intelligence ETF +IRBO - iShares Robotics and Artificial Intelligence ETF +ROBT - First Trust Nasdaq Artificial Intelligence and Robotics ETF +THNQ - ROBO Global Artificial Intelligence ETF +UBOT - Daily Robotics, Artificial Intelligence & Automation Index Bull 3X Shares +``` +Note that this searches for exact strings in the ETF name. Searching for SPY will return nothing. +## overview +```python +usage: overview [-n --name] +``` +* -n/--name : ETF to get data for +Returns the overview of the ETF. Shows Last Price, Assets, Net Asset Value (NAV), Expense Ratio, PE Ratio, 5Year Beta, Total Dividend and Dividend Yield. + +Example will be a single column from the [compare](#compare) example. + +## holdings +```python +usage: overview [-n --name] [-l --limit] +``` +* -n/--name : Name of ETF to get data for. +* -l/--limit : Number of assets to show. Max 200. Defaults to 20. + +Returns the top holdings in the ETF. Shows percentage and total shares held. + +Example: +``` +(✨) (etf)> holdings spy -l 5 +╒════╤══════════╤════════════╤═════════════╕ +│ │ Ticker │ % of ETF │ Shares │ +╞════╪══════════╪════════════╪═════════════╡ +│ 0 │ AAPL │ 5.66% │ 162,078,640 │ +├────┼──────────┼────────────┼─────────────┤ +│ 1 │ MSFT │ 5.26% │ 77,463,250 │ +├────┼──────────┼────────────┼─────────────┤ +│ 2 │ AMZN │ 3.89% │ 4,396,091 │ +├────┼──────────┼────────────┼─────────────┤ +│ 3 │ FB │ 2.11% │ 24,705,450 │ +├────┼──────────┼────────────┼─────────────┤ +│ 4 │ GOOGL │ 1.93% │ 3,088,769 │ +╘════╧══════════╧════════════╧═════════════╛ +``` + +## compare +```python +usage: compare [-n --names] +``` +* -n/--names : ETFs to compare. Input as comma separated (ETF1,ETF2,..) + +Campares the overview of different ETFs. Unknown tickers show nan + +Example: + +``` +(✨) (etf)> compare spy,qqq,voo,DOGE +DOGE not found +╒════════════════╤══════════╤══════════╤══════════╤════════╕ +│ │ SPY │ QQQ │ VOO │ DOGE │ +╞════════════════╪══════════╪══════════╪══════════╪════════╡ +│ Last Price │ $414.94 │ $327.01 │ $381.47 │ nan │ +├────────────────┼──────────┼──────────┼──────────┼────────┤ +│ Assets │ $352.93B │ $153.76B │ $219.80B │ nan │ +├────────────────┼──────────┼──────────┼──────────┼────────┤ +│ NAV │ $410.85 │ $322.66 │ $377.68 │ nan │ +├────────────────┼──────────┼──────────┼──────────┼────────┤ +│ Expense Ratio │ 0.09% │ 0.20% │ 0.03% │ nan │ +├────────────────┼──────────┼──────────┼──────────┼────────┤ +│ PE Ratio │ 25.16 │ 35.32 │ 27.60 │ nan │ +├────────────────┼──────────┼──────────┼──────────┼────────┤ +│ Beta (5Y) │ 0.99 │ 1.04 │ 0.99 │ nan │ +├────────────────┼──────────┼──────────┼──────────┼────────┤ +│ Dividend (ttm) │ $5.56 │ $1.77 │ $5.39 │ nan │ +├────────────────┼──────────┼──────────┼──────────┼────────┤ +│ Dividend Yield │ 1.35% │ 0.55% │ 1.43% │ nan │ +╘════════════════╧══════════╧══════════╧══════════╧════════╛ +``` diff --git a/gamestonk_terminal/etf/stockanalysis_model.py b/gamestonk_terminal/etf/stockanalysis_model.py index fb1088f6e6f..a76a36e7ddc 100644 --- a/gamestonk_terminal/etf/stockanalysis_model.py +++ b/gamestonk_terminal/etf/stockanalysis_model.py @@ -23,10 +23,10 @@ for link in all_links: etf_names.append(link.text.split("-")[1].strip(" ")) -def limit_number_of_holdings(num: int) -> int: - if num > 200: +def limit_number_of_holdings(num: str) -> int: + if int(num) > 200: raise argparse.ArgumentTypeError("Asking for too many holdings") - return num + return int(num) def open_web(): @@ -54,16 +54,17 @@ def name_search(other_args: List[str]): if "-" not in other_args[0]: other_args.insert(0, "-n") - ns_parser = parse_known_args_and_warn(parser, other_args) + ns_parser = parse_known_args_and_warn(parser, other_args[:2]) if not ns_parser: return "" - matching_etfs = [ etf_symbols[idx] + " - " + etf for idx, etf in enumerate(etf_names) - if ns_parser.name.lower() in etf.lower() + if " ".join(other_args[1:]).lower() in etf.lower() ] print(*matching_etfs, sep="\n") + if len(matching_etfs) == 0: + print("No matches found") print("") return ""