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

This commit is contained in:
Yuri Victorovich 2022-12-25 13:40:18 -08:00
parent fa34f289d7
commit d3b17e1ff9
5 changed files with 65 additions and 0 deletions

View File

@ -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

View File

@ -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>

View File

@ -0,0 +1,3 @@
TIMESTAMP = 1672003808
SHA256 (finviz-1.4.5.tar.gz) = 524a975a1d2c410d33468e63227e79f23199e303b613eb53ca9308477a743634
SIZE (finviz-1.4.5.tar.gz) = 17467

View File

@ -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)

View File

@ -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.