Skip to main content

Retrieves financial quotes from the web

Project description

pipeline status coverage report

FinQuotes

FinQuotes is a small Python library to be used as a facade to fetch financial data from public sources through a single, consistent interface. It adapts various interface to a consistent one described below allowing one to quickly switch between service.

It supports close snapshots, historical OHLCV, distributions (dividends), splits, and security metadata across multiple providers (Yahoo Finance, yfinance, yahooquery, Stooq, Morningstar, Quandl).

  • Python: 3.11–3.13
  • License: GPL-3.0

Features

  • Unified API and CLI for multiple data sources
  • Normalized data models: Price, Distribution, Split, Security
  • Deterministic CSV output for easy piping and testing
  • Robust network options: retry, timeout, max retries
  • Pluggable sources via lightweight “feed” builders

Install

python -m pip install --upgrade pip
python -m pip install finquotes

Optional extras:

  • Types only: python -m pip install 'finquotes[types]'
  • Dev/test: python -m pip install -e '.[develop,test,types]'

Quick start (Python)

Use typed builder helpers for clarity, or build_feed with a FeedType.

import finquotes as fq

# Historical OHLCV (yfinance)
hfeed = fq.build_historical_feed("finquotes.yfinance", auto_adjust=True)
for p in hfeed.fetch_hist_prices("MSFT", begin_date=fq.today(), end_date=fq.today()):
	assert p.open is not None and p.high is not None and p.low is not None

# Distributions & splits (yahooquery)
qhist = fq.build_historical_feed("finquotes.yahooquery")
for d in qhist.fetch_hist_dists("BIL", begin_date=fq.today(), end_date=fq.today()):
	print(d)
for s in qhist.fetch_hist_splits("AAPL", begin_date=fq.today(), end_date=fq.today()):
	print(s)

Network parameters (timeout, max_retries, retry_delay, and provider-specific args) can be passed to feed builders as keyword arguments.

API keys

Some providers require an API key (e.g., Quandl). FinQuotes looks for keys in:

  1. Environment variable: FINQUOTES_<PROVIDER>_API_KEY (e.g. FINQUOTES_QUANDL_API_KEY)
  2. File: ~/.finquotes/api_keys.txt with lines like:
finquotes.quandl=<YOUR_KEY>

On Windows the file path expands to %USERPROFILE%\.finquotes\api_keys.txt.

You can also pass --api-key on the CLI or api_key="..." to feed builders where applicable.

Data model at a glance

  • Price(symbol, date|datetime, close[, open, high, low, volume, source])
  • Distribution(symbol, ex_date, amount[, pay_date])
  • Split(symbol, ex_date, new_quantity, old_quantity) and Split.from_ratio(...)
  • Security(symbol, name[, type, currency, exchange, country, sector, industry, source, source_id])

Instances print to CSV for easy piping; attributes are typed (Decimal for prices) and validated by a helper (PriceValidator).

Tips & caveats

  • Some providers adjust historical series (e.g., Stooq distributions are adjusted); check source notes before using for cash-flow analysis.
  • Yahoo-derived OHLC fields may be dividend-adjusted; see in-code comments where noted.
  • Timezone defaults to America/New_York for timestamp parsing.

Development

Set up a local environment once:

python -m venv venv
. .\venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e '.[develop,test,types]'

Run tests:

pytest -q

Pre-commit hooks:

pre-commit install
pre-commit run --all-files

Publishing (maintainers)

cz bump -ch    # bump version, update files, create tag
git push --tags
# build & upload using your preferred toolchain
python -m build          # or: python -m setup sdist
python -m twine upload dist/*       # or target a custom repository URL

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finquotes-0.67.1.tar.gz (44.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finquotes-0.67.1-py3-none-any.whl (50.6 kB view details)

Uploaded Python 3

File details

Details for the file finquotes-0.67.1.tar.gz.

File metadata

  • Download URL: finquotes-0.67.1.tar.gz
  • Upload date:
  • Size: 44.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for finquotes-0.67.1.tar.gz
Algorithm Hash digest
SHA256 52d098b1da09c35507a916f7a13c4bf76baa93cab4fe8be447194d5c0ac21368
MD5 d6dc48b457f2d365e115bb66ad5abc00
BLAKE2b-256 bd43b7bf3e27eb64a972615077f0d68fd71b912e1ebdbe06d8d9f5e6f6150ce0

See more details on using hashes here.

File details

Details for the file finquotes-0.67.1-py3-none-any.whl.

File metadata

  • Download URL: finquotes-0.67.1-py3-none-any.whl
  • Upload date:
  • Size: 50.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for finquotes-0.67.1-py3-none-any.whl
Algorithm Hash digest
SHA256 577e4f6b8d0fc7d87862dc8a85e99b8b29d45d15f12eb54aea6f04c40358a85b
MD5 05fd56f53f6a830e31f097f71193961c
BLAKE2b-256 959ba464e6c7d683d914c8e2255f65917b57b67500e9e3e4e63789efd4a294aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page