Unofficial Python API for FinViz
To download the latest version from GitHub:
$ git clone https://github.com/mariostoev/finviz.gitThen, run the setup.py file from the project directory
$ sudo python setup.py installAlternatively, you can download and install the latest release on PyPi using:
$ pip install finvizFinViz 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.
Important Information
Any quotes data displayed on finviz.com is delayed by 15 minutes for NASDAQ, and 20 minutes for NYSE and AMEX. This API should NOT be used for live trading, it's main purpuse is financial analysis, research and data scraping.
Before using the Screener class, you have to manually go to the website's screener and enter your desired settings. The URL will automatically change every time you add a new setting. After you're done the URL will look something like this:
?v=111&s=ta_newhigh&f=cap_largeover,exch_nasd,fa_fpe_o10&o=-ticker&t=ZM are the extra parameters provided to the screener. Those parameters are a list of key/value pairs separated with the & symbol. Some keys have a clear intent - f=cap_largeover,exch_nasd,fa_fpe_o10 are filters, o=-ticker is order and t=ZM are tickers - yet, some are ambiguous like v=111, which stands for the type of table.
To make matters easier inside the code you won't refer to tables by their number tag, but instead you will use their full name (ex. table=Performance).
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()
# Create a SQLite database
stock_list.to_sqlite("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)

