papermill on screener list

This commit is contained in:
DJ
2021-04-29 20:04:26 -06:00
parent 4adfc54f66
commit c594e17d0c
5 changed files with 80 additions and 14 deletions

1
.gitignore vendored
View File

@@ -8,5 +8,6 @@ __pycache__/
env/
venv/
notebooks/reports/*
reports/*
!notebooks/reports/.gitkeep
.python-version

View File

@@ -83,10 +83,10 @@ class ForexController:
" reddit search reddit for posts about the loaded instrument"
)
print(
" eda > exploratory data analysis, e.g.: decompose, cusum, residuals analysis"
" > eda exploratory data analysis, e.g.: decompose, cusum, residuals analysis"
)
print(
" ba > behavioural analysis, from: reddit, stocktwits, twitter, google"
" > ba behavioural analysis, from: reddit, stocktwits, twitter, google"
)
print("")

View File

@@ -10,7 +10,7 @@ import papermill as pm
from gamestonk_terminal import config_terminal as cfg
def due_diligence(other_args: List[str]):
def due_diligence(other_args: List[str], show=True):
"""Due Diligence report
Parameters
@@ -35,12 +35,15 @@ def due_diligence(other_args: List[str]):
help="Stock ticker",
)
if other_args:
if "-" not in other_args[0]:
other_args.insert(0, "-t")
try:
(ns_parser, unknown_args) = parser.parse_known_args(other_args)
except SystemExit:
print("")
return
if unknown_args:
print(f"The following args couldn't be interpreted: {unknown_args}")
@@ -66,7 +69,8 @@ def due_diligence(other_args: List[str]):
print("")
return
webbrowser.open(
f"http://localhost:{cfg.PAPERMILL_NOTEBOOK_REPORT_PORT}/notebooks/{analysis_notebook}"
)
if show:
webbrowser.open(
f"http://localhost:{cfg.PAPERMILL_NOTEBOOK_REPORT_PORT}/notebooks/{analysis_notebook}"
)
print("")

View File

@@ -68,7 +68,7 @@ View historical price of stocks. [Source: Yahoo Finance]
## overview <a name="overview"></a>
```text
usage: overview [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-a]
usage: overview [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-aem]
```
Prints screener data of the companies that meet the pre-set filtering. Some of the fields shown are: Sector, Industry, Market Cap, Volume. Note that when the signal parameter (-s) is specified, the preset is disregarded. [Source: Finviz]
@@ -77,6 +77,8 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
* -s : Signal type. Default: None. When specified (see list available in [signals](#signals)), the preset is disregarded.
* -l : Limit of stocks to output. Default: 200.
* -a : Set order of stocks shown to Ascended. Default: Descended.
* -e : Export list to a file.
* -m : Run papermill dd on the tickers in the returned list.
<img width="934" alt="overview" src="https://user-images.githubusercontent.com/25267873/113618972-4854d000-9650-11eb-9482-d1054a7d0451.png">
@@ -84,7 +86,7 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
## valuation <a name="valuation"></a>
```text
usage: valuation [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-a]
usage: valuation [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-aem]
```
Prints screener data of the companies that meet the pre-set filtering. Some of the fields shown are: P/E, PEG, P/S, P/B, EPS this Y. Note that when the signal parameter (-s) is specified, the preset is disregarded. [Source: Finviz]
@@ -93,6 +95,11 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
* -s : Signal type. Default: None. When specified (see list available in [signals](#signals)), the preset is disregarded.
* -l : Limit of stocks to output. Default: 200.
* -a : Set order of stocks shown to Ascended. Default: Descended.
* -e : Export list to a file.
* -m : Run papermill dd on the tickers in the returned list.
<img width="934" alt="overview" src="https://user-images.githubusercontent.com/25267873/113618972-4854d000-9650-11eb-9482-d1054a7d0451.png">
<img width="989" alt="valuation" src="https://user-images.githubusercontent.com/25267873/113618970-47bc3980-9650-11eb-8f3d-1b3609bb71ef.png">
@@ -100,7 +107,7 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
## financial <a name="financial"></a>
```text
usage: financial [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-a]
usage: financial [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-aem]
```
Prints screener data of the companies that meet the pre-set filtering. Some of the fields shown are: Dividend, ROA, ROE, ROI, Earnings. Note that when the signal parameter (-s) is specified, the preset is disregarded. [Source: Finviz]
@@ -109,6 +116,11 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
* -s : Signal type. Default: None. When specified (see list available in [signals](#signals)), the preset is disregarded.
* -l : Limit of stocks to output. Default: 200.
* -a : Set order of stocks shown to Ascended. Default: Descended.
* -e : Export list to a file.
* -m : Run papermill dd on the tickers in the returned list.
<img width="934" alt="overview" src="https://user-images.githubusercontent.com/25267873/113618972-4854d000-9650-11eb-9482-d1054a7d0451.png">
<img width="995" alt="financial" src="https://user-images.githubusercontent.com/25267873/113618977-4985fd00-9650-11eb-976c-913232f5eb2f.png">
@@ -116,7 +128,7 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
## ownership <a name="ownership"></a>
```text
usage: ownership [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-a]
usage: ownership [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-aem]
```
Prints screener data of the companies that meet the pre-set filtering. Some of the fields shown are: Float, Insider Own, Short Ratio. Note that when the signal parameter (-s) is specified, the preset is disregarded. [Source: Finviz]
@@ -125,6 +137,11 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
* -s : Signal type. Default: None. When specified (see list available in [signals](#signals)), the preset is disregarded.
* -l : Limit of stocks to output. Default: 200.
* -a : Set order of stocks shown to Ascended. Default: Descended.
* -e : Export list to a file.
* -m : Run papermill dd on the tickers in the returned list.
<img width="934" alt="overview" src="https://user-images.githubusercontent.com/25267873/113618972-4854d000-9650-11eb-9482-d1054a7d0451.png">
<img width="1017" alt="ownership" src="https://user-images.githubusercontent.com/25267873/113618974-48ed6680-9650-11eb-99ec-fe584ebfa274.png">
@@ -132,7 +149,7 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
## performance <a name="performance"></a>
```text
usage: performance [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-a]
usage: performance [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-aem]
```
Prints screener data of the companies that meet the pre-set filtering. Some of the fields shown are: Perf Week, Perf YTD, Volatility M. Note that when the signal parameter (-s) is specified, the preset is disregarded. [Source: Finviz]
@@ -141,6 +158,11 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
* -s : Signal type. Default: None. When specified (see list available in [signals](#signals)), the preset is disregarded.
* -l : Limit of stocks to output. Default: 200.
* -a : Set order of stocks shown to Ascended. Default: Descended.
* -e : Export list to a file.
* -m : Run papermill dd on the tickers in the returned list.
<img width="934" alt="overview" src="https://user-images.githubusercontent.com/25267873/113618972-4854d000-9650-11eb-9482-d1054a7d0451.png">
<img width="1016" alt="performance" src="https://user-images.githubusercontent.com/25267873/113618973-48ed6680-9650-11eb-8894-0c9ace262bfa.png">
@@ -148,7 +170,7 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
## technical <a name="technical"></a>
```text
usage: technical [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-a]
usage: technical [-p {template,sexy_year,...}] [-s {top_gainers,top_losers,...}] [-l LIMIT] [-aem]
```
Prints screener data of the companies that meet the pre-set filtering. Some of the fields shown are: Beta, SMA50, 52W Low, RSI, Change. Note that when the signal parameter (-s) is specified, the preset is disregarded. [Source: Finviz]
@@ -157,6 +179,11 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
* -s : Signal type. Default: None. When specified (see list available in [signals](#signals)), the preset is disregarded.
* -l : Limit of stocks to output. Default: 200.
* -a : Set order of stocks shown to Ascended. Default: Descended.
* -e : Export list to a file.
* -m : Run papermill dd on the tickers in the returned list.
<img width="934" alt="overview" src="https://user-images.githubusercontent.com/25267873/113618972-4854d000-9650-11eb-9482-d1054a7d0451.png">
<img width="749" alt="technical" src="https://user-images.githubusercontent.com/25267873/113619656-2b6ccc80-9651-11eb-92c2-87d7e51ef22d.png">
@@ -165,9 +192,14 @@ Prints screener data of the companies that meet the pre-set filtering. Some of t
Example:
```text
technical -s oversold
technical -s oversold [-em]
```
* -e : Export list to a file.
* -m : Run papermill dd on the tickers in the returned list.
<img width="934" alt="overview" src="https://user-images.githubusercontent.com/25267873/113618972-4854d000-9650-11eb-9482-d1054a7d0451.png">
<img width="1007" alt="technical_oversold flag" src="https://user-images.githubusercontent.com/25267873/113618975-48ed6680-9650-11eb-805f-00a656f97e9a.png">

View File

@@ -6,6 +6,8 @@ from typing import List
import os
import configparser
import pandas as pd
from datetime import datetime
from gamestonk_terminal.papermill import due_diligence_view
from finvizfinance.screener import (
technical,
overview,
@@ -198,6 +200,20 @@ def screener(other_args: List[str], loaded_preset: str, data_type: str):
dest="ascend",
help="Set order to Ascend, the default is Descend",
)
parser.add_argument(
"-e",
"--export",
action="store_true",
dest="exportFile",
help="Save list as a text file",
)
parser.add_argument(
"-m",
"--mill",
action="store_true",
dest="mill",
help="Run papermill on list",
)
try:
ns_parser = parse_known_args_and_warn(parser, other_args)
@@ -215,6 +231,19 @@ def screener(other_args: List[str], loaded_preset: str, data_type: str):
if isinstance(df_screen, pd.DataFrame):
print(df_screen.to_string())
print("")
if ns_parser.exportFile:
now = datetime.now()
if not os.path.exists("reports/screener"):
os.makedirs("reports/screener")
with open(
f"reports/screener/{ns_parser.signal}-{now.strftime('%Y-%m-%d_%H:%M:%S')}",
"w",
) as file:
file.write(df_screen.to_string(index=False) + "\n")
if ns_parser.mill:
for i in range(len(df_screen)):
ticker = [df_screen.iat[i, 0]]
due_diligence_view.due_diligence(ticker, show=False)
return list(df_screen["Ticker"].values)
else:
print("")