git: d3b17e1ff9e5 - main - finance/py-finviz: New port: Unofficial API for FinViz.com

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Mon, 26 Dec 2022 02:35:02 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d3b17e1ff9e5a0594dc98f9336151be8534732c4

commit d3b17e1ff9e5a0594dc98f9336151be8534732c4
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2022-12-25 21:40:18 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2022-12-26 02:34:58 +0000

    finance/py-finviz: New port: Unofficial API for FinViz.com
---
 finance/Makefile                |  1 +
 finance/py-finviz/Makefile      | 37 +++++++++++++++++++++++++++++++++++++
 finance/py-finviz/distinfo      |  3 +++
 finance/py-finviz/files/test.py | 20 ++++++++++++++++++++
 finance/py-finviz/pkg-descr     |  4 ++++
 5 files changed, 65 insertions(+)

diff --git a/finance/Makefile b/finance/Makefile
index 7c07b49e5443..1bd0e52291c2 100644
--- a/finance/Makefile
+++ b/finance/Makefile
@@ -101,6 +101,7 @@
     SUBDIR += py-ebaysdk
     SUBDIR += py-financedatabase
     SUBDIR += py-finnhub-python
+    SUBDIR += py-finviz
     SUBDIR += py-finvizfinance
     SUBDIR += py-fundamentalanalysis
     SUBDIR += py-investiny
diff --git a/finance/py-finviz/Makefile b/finance/py-finviz/Makefile
new file mode 100644
index 000000000000..c6a4982caf34
--- /dev/null
+++ b/finance/py-finviz/Makefile
@@ -0,0 +1,37 @@
+PORTNAME=	finviz
+DISTVERSION=	1.4.5
+CATEGORIES=	finance python
+MASTER_SITES=	CHEESESHOP
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Unofficial API for FinViz.com
+WWW=		https://github.com/mariostoev/finviz
+
+LICENSE=	MIT
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+PY_DEPENDS=	${PYTHON_PKGNAMEPREFIX}aiohttp>=3.7.4:www/py-aiohttp@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}beautifulsoup>=4.9.3:www/py-beautifulsoup@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}cssselect>=1.1.0:www/py-cssselect@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}lxml>=4.6.3:devel/py-lxml@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}requests>=2.25.1:www/py-requests@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}tenacity>=7.0.0:devel/py-tenacity@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}tqdm>=4.61.1:misc/py-tqdm@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}urllib3>=1.26.5:net/py-urllib3@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}user_agent>=0.1.9:www/py-user_agent@${PY_FLAVOR}
+BUILD_DEPENDS=	${PY_DEPENDS}
+RUN_DEPENDS=	${PY_DEPENDS}
+
+USES=		python:3.6+
+USE_PYTHON=	distutils autoplist pytest
+
+NO_ARCH=	yes
+
+TEST_ENV=	${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
+
+do-test:
+	@${SETENV} ${TEST_ENV} ${PYTHON_CMD} ${FILESDIR}/test.py
+
+.include <bsd.port.mk>
diff --git a/finance/py-finviz/distinfo b/finance/py-finviz/distinfo
new file mode 100644
index 000000000000..f041ec83069e
--- /dev/null
+++ b/finance/py-finviz/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1672003808
+SHA256 (finviz-1.4.5.tar.gz) = 524a975a1d2c410d33468e63227e79f23199e303b613eb53ca9308477a743634
+SIZE (finviz-1.4.5.tar.gz) = 17467
diff --git a/finance/py-finviz/files/test.py b/finance/py-finviz/files/test.py
new file mode 100644
index 000000000000..d7dc97f18e60
--- /dev/null
+++ b/finance/py-finviz/files/test.py
@@ -0,0 +1,20 @@
+from finviz.screener import Screener
+
+filters = ['exch_nasd', 'idx_sp500']  # Shows companies in NASDAQ which are in the S&P500
+stock_list = Screener(filters=filters, table='Performance', order='price')  # Get the performance table and sort it by price ascending
+
+# Export the screener results to .csv
+stock_list.to_csv("/tmp/stock.csv")
+
+# Create a SQLite database
+stock_list.to_sqlite("/tmp/stock.sqlite3")
+
+for stock in stock_list[9:19]:  # Loop through 10th - 20th stocks
+    print(stock['Ticker'], stock['Price']) # Print symbol and price
+
+# Add more filters
+stock_list.add(filters=['fa_div_high'])  # Show stocks with high dividend yield
+# or just stock_list(filters=['fa_div_high'])
+
+# Print the table into the console
+print(stock_list)
diff --git a/finance/py-finviz/pkg-descr b/finance/py-finviz/pkg-descr
new file mode 100644
index 000000000000..2bfa2256a888
--- /dev/null
+++ b/finance/py-finviz/pkg-descr
@@ -0,0 +1,4 @@
+FinViz aims to make market information accessible and provides a lot of data in
+visual snapshots, allowing traders and investors to quickly find the stock,
+future or forex pair they are looking for. The site provides advanced screeners,
+market maps, analysis, comparative tools, and charts.