Add ETF Report functionality from The Passive Investor (#857)

* Add ETF report functionalty from The Passive Investor

* Add documentation about ETF Report

* Add thepassiveinvestor to the requirements

* Correct accidental typo

* Rename report to pir

* Change report to pir and some minor changes

* Update thepassiveinvestor to 1.0.9
This commit is contained in:
Jeroen Bouma
2021-10-25 23:35:54 +02:00
committed by GitHub
parent 61ccd504af
commit 3401f157e5
7 changed files with 5933 additions and 5799 deletions

View File

@@ -3,10 +3,12 @@ __docformat__ = "numpy"
import argparse
import os
from datetime import datetime
from typing import List
import matplotlib.pyplot as plt
from prompt_toolkit.completion import NestedCompleter
from thepassiveinvestor import create_ETF_report
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.etf import screener_view, stockanalysis_view, wsj_view
@@ -41,6 +43,7 @@ class ETFController:
"gainers",
"decliners",
"active",
"pir",
]
CHOICES += CHOICES_COMMANDS
@@ -73,6 +76,9 @@ Wall St. Journal:
gainers show top gainers
decliners show top decliners
active show most active
The Passive Investor:
pir create ETF report of multiple tickers
"""
print(help_str)
@@ -364,6 +370,57 @@ Wall St. Journal:
"""Process gainers command"""
wsj_view.show_top_mover("active", other_args)
def call_pir(self, other_args):
"""Process pir command"""
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="pir",
description="Create a ETF Report of the selected ETFs",
)
parser.add_argument(
"-e",
"--etfs",
type=str,
dest="names",
help="Symbols to create a report for",
required="-h" not in other_args,
)
parser.add_argument(
"--filename",
default=f"ETF_report_{datetime.now().strftime('%Y%m%d_%H%M%S')}",
dest="filename",
help="Filename of the ETF report",
)
parser.add_argument(
"--folder",
default=os.path.dirname(os.path.abspath(__file__)).replace(
"gamestonk_terminal", "exports"
),
dest="folder",
help="Folder where the ETF report will be saved",
)
try:
if other_args:
if "-" not in other_args[0]:
other_args.insert(0, "-e")
ns_parser = parse_known_args_and_warn(parser, other_args)
if not ns_parser:
return
etf_list = ns_parser.names.upper().split(",")
create_ETF_report(
etf_list, filename=ns_parser.filename, folder=ns_parser.folder
)
print(
f"Created ETF report as {ns_parser.filename} in folder {ns_parser.folder} \n"
)
except Exception as e:
print(e, "\n")
def menu():
etf_controller = ETFController()

11441
poetry.lock generated vendored

File diff suppressed because it is too large Load Diff

223
pyproject.toml vendored
View File

@@ -1,111 +1,112 @@
# https://python-poetry.org/docs/dependency-specification/
[tool.poetry]
name = "GamestonkTerminal"
version = "0.1.0"
description = ""
authors = ["Didier Rodrigues Lopes"]
packages = [
{ include = "gamestonk_terminal" },
]
[tool.poetry.scripts]
gst = 'terminal:terminal'
[tool.poetry.dependencies]
python = "^3.7"
pandas = "^1.1.5,<1.2"
iso8601 = "^0.1.14"
FundamentalAnalysis = "^0.2.6"
requests = "^2.25.1"
alpha-vantage = "^2.3.1"
finviz = "^1.3.4"
bs4 = "^0.0.1"
rapidfuzz = "^1.1.1"
yfinance = "^0.1.63"
pandas-ta = "^0.2.23b0"
prettytable = "^2.0.0"
psaw = "^0.0.12"
praw = "^7.1.4"
Quandl = "^3.6.0"
pytrends = "^4.7.3"
timeseries-cv = "0.1.4"
matplotlib = "^3.3.3"
plotly = "^4.14.3"
colorama = "^0.4.4"
papermill = "^2.3.2"
pmdarima = "1.8.3"
holidays = "^0.10"
prompt-toolkit = "^3.0.16"
jupyter = "^1.0.0"
jupyterlab = "^3.1.10"
mplfinance = "^0.12.7-alpha.7"
seaborn = "^0.11.0"
scipy = "~1.5.4"
fredapi = "^0.4.3"
screeninfo = "^0.6.7"
numpy = "~1.19.5,<1.20"
pyrsistent = "~0.14.11"
regex = "~2020.11.13"
robin-stocks = "^2.0.3"
termcolor = "^1.1.0"
alpaca-trade-api = "^1.0.1"
pyally = "^1.1.2"
pycoingecko = "^1.4.0"
detecta = "^0.0.5"
tradingview-ta = "^3.2.3"
finvizfinance = "^0.9.3"
Pillow = "^8.2.0"
statsmodels = "^0.12.2"
tabulate = "^0.8.9"
pyportfolioopt = "^1.4.1"
selenium = "^3.141.0"
python-coinmarketcap = "^0.2"
oandapyV20 = "^0.6.3"
valinvest = "^0.0.2"
bt = "^0.2.9"
python-binance = "^1.0.1"
pyupgrade = "2.18.2"
cvxpy = "1.1.12"
jupyter-client = "6.1.12"
vaderSentiment = "3.3.2"
degiro-connector = "1.0.0"
mypy = "^0.901"
GitPython = "^3.1.17"
fear-greed-index = "^0.1.3"
pyEX = "^0.5.0"
charset-normalizer = "2.0.1"
sentiment-investor = "^2.0.0"
fred = "^3.1"
openpyxl = "3.0.7"
vcrpy = "^4.1.1"
coverage = "^5.5"
tensorflow = {version = "2.6.0", optional = true}
jsonschema = "3.2.0"
[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
pylint = "^2.7.2"
flake8 = "^3.9.0"
mypy = "^0.901"
mock = "^4.0.3"
codespell = "^2.0.0"
pyupgrade = "^2.11.0"
Sphinx = "4.1.1"
black = "21.7b0"
[tool.poetry.extras]
prediction = ["tensorflow"]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
# Notes for developers:
# 1. numpy >= 1.20.0 sometimes has issues with tensorflow=2.4.1
# 2. The following packages dropped support for python<3.7:
# pandas >= 1.2.0
# numpy >= 1.20.0
# scipy >= 1.6.0
# 3. The following often cause poetry to misbehave:
# pyrsistent >= 0.17
# regex >= 2021
# https://python-poetry.org/docs/dependency-specification/
[tool.poetry]
name = "GamestonkTerminal"
version = "0.1.0"
description = ""
authors = ["Didier Rodrigues Lopes"]
packages = [
{ include = "gamestonk_terminal" },
]
[tool.poetry.scripts]
gst = 'terminal:terminal'
[tool.poetry.dependencies]
python = "^3.7"
pandas = "^1.1.5,<1.2"
iso8601 = "^0.1.14"
FundamentalAnalysis = "^0.2.6"
requests = "^2.25.1"
alpha-vantage = "^2.3.1"
finviz = "^1.3.4"
bs4 = "^0.0.1"
rapidfuzz = "^1.1.1"
yfinance = "^0.1.63"
pandas-ta = "^0.2.23b0"
prettytable = "^2.0.0"
psaw = "^0.0.12"
praw = "^7.1.4"
Quandl = "^3.6.0"
pytrends = "^4.7.3"
timeseries-cv = "0.1.4"
matplotlib = "^3.3.3"
plotly = "^4.14.3"
colorama = "^0.4.4"
papermill = "^2.3.2"
pmdarima = "1.8.3"
holidays = "^0.10"
prompt-toolkit = "^3.0.16"
jupyter = "^1.0.0"
jupyterlab = "^3.1.10"
mplfinance = "^0.12.7-alpha.7"
seaborn = "^0.11.0"
scipy = "~1.5.4"
fredapi = "^0.4.3"
screeninfo = "^0.6.7"
numpy = "~1.19.5,<1.20"
pyrsistent = "~0.14.11"
regex = "~2020.11.13"
robin-stocks = "^2.0.3"
termcolor = "^1.1.0"
alpaca-trade-api = "^1.0.1"
pyally = "^1.1.2"
pycoingecko = "^1.4.0"
detecta = "^0.0.5"
tradingview-ta = "^3.2.3"
finvizfinance = "^0.9.3"
Pillow = "^8.2.0"
statsmodels = "^0.12.2"
tabulate = "^0.8.9"
pyportfolioopt = "^1.4.1"
selenium = "^3.141.0"
python-coinmarketcap = "^0.2"
oandapyV20 = "^0.6.3"
valinvest = "^0.0.2"
bt = "^0.2.9"
python-binance = "^1.0.1"
pyupgrade = "2.18.2"
cvxpy = "1.1.12"
jupyter-client = "6.1.12"
vaderSentiment = "3.3.2"
degiro-connector = "1.0.0"
mypy = "^0.901"
GitPython = "^3.1.17"
fear-greed-index = "^0.1.3"
pyEX = "^0.5.0"
charset-normalizer = "2.0.1"
sentiment-investor = "^2.0.0"
fred = "^3.1"
openpyxl = "3.0.7"
vcrpy = "^4.1.1"
coverage = "^5.5"
tensorflow = {version = "2.6.0", optional = true}
jsonschema = "3.2.0"
thepassiveinvestor = "1.0.9"
[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
pylint = "^2.7.2"
flake8 = "^3.9.0"
mypy = "^0.901"
mock = "^4.0.3"
codespell = "^2.0.0"
pyupgrade = "^2.11.0"
Sphinx = "4.1.1"
black = "21.7b0"
[tool.poetry.extras]
prediction = ["tensorflow"]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
# Notes for developers:
# 1. numpy >= 1.20.0 sometimes has issues with tensorflow=2.4.1
# 2. The following packages dropped support for python<3.7:
# pandas >= 1.2.0
# numpy >= 1.20.0
# scipy >= 1.6.0
# 3. The following often cause poetry to misbehave:
# pyrsistent >= 0.17
# regex >= 2021

View File

@@ -221,6 +221,7 @@ termcolor==1.1.0
terminado==0.12.1; python_version >= "3.6"
testpath==0.5.0; python_version >= "3.7"
textwrap3==0.9.2; python_version >= "3.6"
thepassiveinvestor==1.0.9; python_version >= "3.7"
threadpoolctl==3.0.0; python_version >= "3.7"
timeseries-cv==0.1.4; python_version >= "3.6" and python_version < "4.0"
tokenize-rt==4.1.0; python_full_version >= "3.6.1"

1
requirements.txt vendored
View File

@@ -198,6 +198,7 @@ termcolor==1.1.0
terminado==0.12.1; python_version >= "3.6"
testpath==0.5.0; python_version >= "3.7"
textwrap3==0.9.2; python_version >= "3.6"
thepassiveinvestor==1.0.9; python_version >= "3.7"
threadpoolctl==3.0.0; python_version >= "3.7"
timeseries-cv==0.1.4; python_version >= "3.6" and python_version < "4.0"
tokenize-rt==4.1.0; python_full_version >= "3.6.1"

7
website/content/etf/pir/_index.md vendored Normal file
View File

@@ -0,0 +1,7 @@
```
usage: pir -e NAMES [--filename FILENAME] [--folder FOLDER] [-h]
```
Creates an ETF Excel report based on the number of tickers entered.
* -e: tickers separated by a comma
* --filename: name of the file
* --folder: the paths where you wish to save the file

View File

@@ -616,6 +616,8 @@ main:
ref: "/etf/decliners"
- name: active
ref: "/etf/active"
- name: pir
ref: "/etf/pir"
- name: portfolio
ref: "/portfolio"
sub: