Metadata-Version: 2.5
Name: finvizfinance
Version: 1.7.0
Summary: Finviz Finance. Information downloader.
Project-URL: Homepage, https://github.com/lit26/finvizfinance
Project-URL: Documentation, https://finvizfinance.readthedocs.io/en/latest/
Project-URL: Repository, https://github.com/lit26/finvizfinance
Project-URL: Issues, https://github.com/lit26/finvizfinance/issues
Project-URL: Changelog, https://github.com/lit26/finvizfinance/blob/master/CHANGELOG.md
Author-email: Tianning Li <ltianningli@gmail.com>
License: MIT License
        
        Copyright (c) 2020 Tianning Li
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: finance,finviz,investment,screener,stock
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: beautifulsoup4>=4.9
Requires-Dist: lxml>=4.6
Requires-Dist: pandas>=1.5
Requires-Dist: requests>=2.32.0
Provides-Extra: dev
Requires-Dist: coverage>=7.5; extra == 'dev'
Requires-Dist: docutils>=0.20; extra == 'dev'
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pre-commit>=3.5; extra == 'dev'
Requires-Dist: pytest-mock; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'dev'
Requires-Dist: sphinx>=7.2; extra == 'dev'
Requires-Dist: xlsxwriter>=3.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: docutils>=0.20; extra == 'docs'
Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'docs'
Requires-Dist: sphinx>=7.2; extra == 'docs'
Provides-Extra: excel
Requires-Dist: xlsxwriter>=3.0; extra == 'excel'
Provides-Extra: test
Requires-Dist: pytest-mock; extra == 'test'
Requires-Dist: pytest>=7.0; extra == 'test'
Requires-Dist: xlsxwriter>=3.0; extra == 'test'
Description-Content-Type: text/markdown

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/finvizfinance)
![PyPI](https://img.shields.io/pypi/v/finvizfinance)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/finvizfinance)
![PyPI - License](https://img.shields.io/pypi/l/finvizfinance?color=gre)
![Read the Docs](https://img.shields.io/readthedocs/finvizfinance)
[![Downloads](https://pepy.tech/badge/finvizfinance)](https://pepy.tech/project/finvizfinance)
[![CodeFactor](https://www.codefactor.io/repository/github/lit26/finvizfinance/badge/master)](https://www.codefactor.io/repository/github/lit26/finvizfinance/overview/master)
[![Donate PayPal](https://img.shields.io/badge/Donate%20%24-PayPal-brightgreen.svg)](https://www.paypal.me/TIANNINGL/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

# finvizfinance

finvizfinance is a package which collects financial information from FinViz website. The package provides the information of the following:

- Stock charts, fundamental & technical information, insider information and stock news
- Forex charts and performance
- Crypto charts and performance

Screener and Group provide dataframes for comparing stocks according to different filters and trading signals.

Docs: https://finvizfinance.readthedocs.io/en/latest/

### Downloads

To download the latest version from GitHub:

```
$ git clone https://github.com/lit26/finvizfinance.git
```

Or install from PyPi:

```
$ pip install finvizfinance
```

### Quote

Getting information (fundament, description, outer rating, stock news, inside trader) of an individual stock.

```python
from finvizfinance.quote import finvizfinance

stock = finvizfinance('tsla')
```

#### Chart

```python
stock.ticker_charts()
```

#### Fundament

```python
stock_fundament = stock.ticker_fundament()

# result
# stock_fundament = {'Company': 'Tesla, Inc.', 'Sector': 'Consumer Cyclical',
# 'Industry': 'Auto Manufacturers', 'Country': 'USA', 'Index': '-', 'P/E': '849.57',
# 'EPS (ttm)': '1.94', 'Insider Own': '0.10%', 'Shs Outstand': '186.00M',
# 'Perf Week': '13.63%', 'Market Cap': '302.10B', 'Forward P/E': '106.17',
# ...}
```

#### Description

```python
stock_description = stock.ticker_description()

# stock_description
# stock_description = 'Tesla, Inc. designs, develops, manufactures, ...'
```
#### Peer

```python
stock_peer = stock.ticker_peer()

# stock_peer
# stock_peer = ['LI', 'XPEV', 'NIO', 'RIVN', 'LCID', 'TM', 'HMC', 'GM', 'STLA', 'F']
```
#### ETF Holders

```python
stock_etf_holders = stock.ticker_etf_holders()

# stock_etf_holders
# stock_etf_holders = ['VTI', 'VOO', 'IVV', 'SPY', 'VUG', 'QQQ', 'VGT', 'IWF', 'XLK', 'SPLG']
```

#### Outer Ratings

```python
outer_ratings_df = stock.ticker_outer_ratings()
```

![Outer Ratings example](asset/outer_rating.png)

#### Options Chain

```python
options_df = stock.ticker_options()  # nearest expiry
options_df = stock.ticker_options(expiry="2026-12-18")
expiries = stock.info["option_expiries"]
```

#### Stock News

```python
news_df = stock.ticker_news()
```

![stock news example](asset/stock_news.png)

#### Inside Trader

```python
inside_trader_df = stock.ticker_inside_trader()
```

![insider trader example](asset/insider_trader.png)

### News

Getting recent financial news from finviz.

```python
from finvizfinance.news import News

fnews = News()
all_news = fnews.get_news()
```

Finviz News include 'news' and 'blogs'.

```python
all_news['news'].head()
```

![news example](asset/news_news.png)

```python
all_news['blogs'].head()
```

![news example](asset/news_blogs.png)

### Insider

Getting insider trading information.

```python
from finvizfinance.insider import Insider

finsider = Insider(option='top owner trade')
# option: latest, top week, top owner trade
# default: latest

insider_trader = finsider.get_insider()
```

![insider example](asset/insider.png)

### Screener (Overview, Valuation, Financial, Ownership, Performance, Technical)

Getting multiple tickers' information according to the filters.

#### Example: Overview

```python
from finvizfinance.screener.overview import Overview

foverview = Overview()
filters_dict = {'Index':'S&P 500','Sector':'Basic Materials'}
foverview.set_filter(filters_dict=filters_dict)
df = foverview.screener_view()
df.head()
```

![insider example](asset/screen_overview.png)

#### Example: From a finviz URL

Instead of translating each criterion into a filters dict by hand, paste the URL
finviz puts in your address bar as you click filters in its UI. `screener.from_url`
reads the view (`v`) and reconstructs the filters (`f`), signal (`s`) and ticker
(`t`), returning the matching screener object:

```python
from finvizfinance import screener

foverview = screener.from_url(
    "https://finviz.com/screener.ashx?v=111&f=idx_sp500,sh_avgvol_o500"
)
df = foverview.screener_view()
df.head()
```

Sort order, pagination and custom columns are `screener_view()` arguments, so
they are ignored in the URL. Any filter/signal/view code that finvizfinance does
not recognize raises a `ValueError` naming the code, rather than silently
dropping it and returning the wrong stocks.

Filters set on an instance stay on it between calls, so one screener object can
be reused. `screener_view()` returns an empty `DataFrame` when a view has no
matches — never `None` — and `Ticker.screener_view()` returns an empty list; a
long run blocked mid-way keeps what it already fetched on `err.partial` and can
be resumed with `select_page=err.next_page`.

### Screener (Ticker)

Getting list of tickers according to the filters.

### Calendar

Getting the economic calendar (release datetime, impact, actual/expected/prior).

```python
from finvizfinance.calendar import Calendar

fcalendar = Calendar()
df = fcalendar.calendar()
df.head()
```

### Earnings

Partitioning tickers by their earnings dates for a period.

```python
from finvizfinance.earnings import Earnings

# period: This Week (default), Next Week, Previous Week, This Month
fearnings = Earnings(period='This Week')

# mode: financial (default), overview, valuation, ownership, performance, technical
days = fearnings.partition_days(mode='financial')

# optionally export the partitioned tables
fearnings.output_csv('earning_days')
# Excel export needs the optional extra: pip install finvizfinance[excel]
fearnings.output_excel('earning_days.xlsx')
```

### Future

Getting futures performance.

```python
from finvizfinance.future import Future

ffuture = Future()
# timeframe: D (default), W, M, Q, HY, Y
df = ffuture.performance(timeframe='D')
df.head()
```

### Misc (Proxy)

Optional proxy can be used for getting information from FinViz website. Accessible from finvizfinance
it's an extension of requests library proxies

```python
from finvizfinance.util import set_proxy

proxies={'http': 'http://127.0.0.1:8080'}
set_proxy(proxies)
```

`set_proxy`, `set_timeout` and `set_session` apply to the calling thread or
async task only — a web app can configure each request handler differently
without the settings bleeding into other callers. Threads that were given no
session get their own default one, since `requests.Session` is not thread-safe.

That also means a thread-pool worker starts with an empty context: a `set_proxy`
or `set_session` call made in the parent thread is **not** visible inside
`ThreadPoolExecutor` workers, and they fall back to a default session with the
default timeout. Configure inside the worker, or carry the context over:

```python
import contextvars
from concurrent.futures import ThreadPoolExecutor

from finvizfinance.util import set_proxy

set_proxy({"https": "http://127.0.0.1:8080"})
ctx = contextvars.copy_context()

with ThreadPoolExecutor() as pool:
    list(pool.map(lambda t: ctx.copy().run(scrape, t), tickers))
```

A session shared across workers also needs a big enough connection pool
(`HTTPAdapter(pool_maxsize=...)`), because `requests` defaults to 10.

### Credit

Developed by Tianning Li. Feel free to give comments or suggestions.
