Skip to main content

Bardata - Common api to fetch stock prices from various sources

This project provides a minimal common api to fetch stock prices from various sources. It includes a driver model with entry points to add custom data source providers. Each driver is implemented as a thin wrapper around the respective client libraries.

[!WARNING] This project is experimental and the interface is likely to change.

Conventions

  • Prices are dataframes with a datetime index called date or datetime
  • Column names open, high, low, close, volume all lower case
  • Arguments like freq, start_date, end_date and max_bars are optional
  • Price data is adjusted by default

Fetching Prices

from bardata import get_prices

prices = get_prices("AAPL", freq="daily", source="tiingo")  # pandas.DataFrame

Polars Adapters

By default prices are returned as pandas DataFrames. For polars output, use the bardata.polars adapters, which mirror the pandas methods but return polars dataframes instead. This requires the polars extra "bardata[polars]".

from bardata.polars import get_prices

prices = get_prices("AAPL", freq="daily", source="tiingo")  # polars.DataFrame

The pandas index (date/datetime) becomes an explicit column in the polars dataframe.

Built-in Data Sources

Default Source

When source is omitted, it is resolved from environment variables depending on frequency — BARDATA_DEFAULT_ENDOFDAY for end-of-day data and BARDATA_DEFAULT_INTRADAY for intraday (hourly/minute). There is no built-in default: if the default variable is not set, fetching without an explicit source will raise an exception.

export BARDATA_DEFAULT_ENDOFDAY=tiingo
export BARDATA_DEFAULT_INTRADAY=massive

Caching

Optional on-disk caching of end-of-day prices, off by default. Set BARDATA_CACHING=1 to enable it; bardata picks the cache location automatically (a per-user cache directory). When enabled, the full history of each (source, ticker, freq, adjusted) is stored once and reused, with date ranges sliced from it — so repeated fetches don't re-download. Entries refresh automatically once a new trading session has closed.

export BARDATA_CACHING=1
  • Caching applies to daily/weekly/monthly data only; intraday is never cached.
  • Pass refresh=True to get_prices (or the multi-ticker functions) to force a refetch and rewrite the cache.
  • bardata.clear_cache(source, freq=None) removes cached entries; bardata.cache_root() returns the cache directory.

Credentials

Some data sources require credentials

  • Tiingo via the TIINGO_API_KEY environment variable
  • Massive via the MASSIVE_API_KEY environment variable

Installation

You can install the package with pip. Include the required source as an extra: yahoo, tiingo, massive, or all for all built-in sources. Add polars for polars support.

pip install "bardata[tiingo,massive,polars]"

Related Projects and Resources

  • yfinance - Download market data from Yahoo! Finance's API
  • tiingo-python - Python client for interacting with the Tiingo Financial Data API (stock ticker and news data)
  • client-python - The official Python client library for the Massive.com REST and WebSocket API.
  • pandas-datareader - Extract data from a wide range of Internet sources into a pandas DataFrame.
  • findatapy - Python library to download market data via Bloomberg, Eikon, Quandl, Yahoo etc.

Metadata

Release files for bardata 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for bardata 0.0.10
File Interpreter ABI Platform
bardata-0.0.10-py3-none-any.whl Python 3 none any Details

Release files / bardata-0.0.10-py3-none-any.whl

Download URL bardata-0.0.10-py3-none-any.whl
Size 544.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3cf9d1b5b73038e6a1eff7138234967ce8c95bc8e6bbbc063a6c66dc5ee83b40
BLAKE2b-256 checksum
How to use checksums
a421c2919bd3be6c2a9577053dce6ae511d9ee9c84a97b92133e29dbf3774a94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.04","id":"plucky","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for bardata 0.0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page