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

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.9-py3-none-any.whl (542.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bardata-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 542.2 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ebd92ee9dee40801efbbf2f8bb2f8ce0a94a4e473d644d93f38a3dca5bcca096
MD5 e7d64f751170acbc1b9f75e349611691
BLAKE2b-256 15c08e5da3a76e72e9fdc9a3e0ca545598a017ef0a307b86095b1877b21d241b

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