Skip to main content

Unified api to fetch stock prices from varied sources

Project description

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.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

bardata-0.0.10-py3-none-any.whl (544.5 kB view details)

Uploaded Python 3

File details

Details for the file bardata-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: bardata-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 544.5 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for bardata-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 3cf9d1b5b73038e6a1eff7138234967ce8c95bc8e6bbbc063a6c66dc5ee83b40
MD5 c32fc868b69d2b1b34681e5d0249e0cd
BLAKE2b-256 a421c2919bd3be6c2a9577053dce6ae511d9ee9c84a97b92133e29dbf3774a94

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