Skip to main content

One finance data client to rule them all — unified API across multiple financial data providers

Project description

one-finance-data

Unified financial data client for Python. Abstracts FMP, Finnhub, Twelve Data, and Yahoo Finance behind a single interface with transparent disk-based caching and a CLI designed for agents and automation.

Installation

# Core library
pip install -e "."

# Core + CLI (ofclient)
pip install -e ".[cli]"

# Development
pip install -e ".[dev,cli]"

Environment variables

Variable Provider Required
FMP_API_KEY Financial Modeling Prep For FMPProvider
FINNHUB_API_KEY Finnhub For FinnhubProvider
TWELVE_DATA_API_KEY Twelve Data For TwelveDataProvider

Providers whose key is unset are skipped automatically. YFinanceProvider (no key) is always available as a fallback.

Python usage

from onefinance.core.client import OneFinanceClient
from datetime import date

# Reads API keys from environment; builds all available providers automatically
with OneFinanceClient() as client:
    # Price history — cached 30 days (historical) or 6 h (after market close)
    bars = client.get_price_history("AAPL", date(2024, 1, 1), date(2024, 12, 31))

    # Live quote — cached 30 seconds
    quote = client.get_quote("AAPL")

    # Company info — cached 30 days
    info = client.get_info("AAPL")

    # Financial statements
    income = client.get_financials("AAPL", statement="income", period="annual")

    # Ratios — use fresh=True to bypass the long-TTL cache
    ratios = client.get_ratios("AAPL", period="annual", fresh=True)

    # Earnings
    earnings = client.get_earnings("AAPL")

    # Insider trades
    trades = client.get_insider_trades("AAPL")

Per-call overrides

bars = client.get_price_history(
    "AAPL",
    date(2024, 1, 1), date(2024, 12, 31),
    no_cache=True,          # bypass cache
    provider="finnhub",     # force a specific provider
    ttl=3600,               # custom TTL in seconds
)

CLI usage

# Discover what's available
ofclient capabilities         # machine-readable command manifest (JSON)
ofclient version              # package + schema version

# Data commands (all output JSON by default)
ofclient price AAPL --range 1y
ofclient price AAPL --start 2024-01-01 --end 2024-12-31
ofclient quote AAPL
ofclient financials AAPL --statement income --period annual
ofclient info AAPL
ofclient insiders AAPL --since 2024-01-01
ofclient ratios AAPL --period annual --fresh
ofclient earnings AAPL

# Output formats
ofclient price AAPL --range 1m --format table
ofclient price AAPL --range 1m --format csv

# Dry-run: see cache key and whether a fetch would happen, without fetching
ofclient price AAPL --range 1y --dry-run

# Force a provider or bypass cache
ofclient quote AAPL --provider finnhub --no-cache

# Introspection
ofclient cache stats
ofclient providers status
ofclient config show
ofclient config init --output ./config.yaml

Exit codes

Code Meaning
0 Success
1 Invalid argument (bad range, unknown statement, etc.)
2 Provider error or rate limit
3 Endpoint not supported by any configured provider
4 Configuration error (missing API key, bad config file)

Environment overrides for CLI

Variable Effect
OFCLIENT_OUTPUT Default output format (json, table, csv)
OFCLIENT_NO_CACHE Set 1 to bypass cache on all calls
OFCLIENT_DRY_RUN Set 1 to dry-run all calls
OFCLIENT_CONFIG Path to config YAML file

Provider coverage

Endpoint FMP Finnhub Twelve Data YFinance
get_price_history
get_quote
get_info
get_financials
get_ratios
get_earnings
get_insider_trades

Running tests

# Unit tests only (no network)
python -m pytest tests/ -m "not integration"

# All tests including live API calls (requires API keys in env)
python -m pytest tests/ -m integration

# Single provider integration test
python -m pytest tests/integration/test_fmp_live.py -m integration -v

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

onefinance-0.1.1.tar.gz (155.4 kB view details)

Uploaded Source

Built Distribution

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

onefinance-0.1.1-py3-none-any.whl (65.5 kB view details)

Uploaded Python 3

File details

Details for the file onefinance-0.1.1.tar.gz.

File metadata

  • Download URL: onefinance-0.1.1.tar.gz
  • Upload date:
  • Size: 155.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for onefinance-0.1.1.tar.gz
Algorithm Hash digest
SHA256 530f02a0eccdc4f0e1a7e13018afa54bf9cb0f901f0721e082dc55e74e4f7d57
MD5 4ff5969402d4f139cf8d804d1e732976
BLAKE2b-256 af3e6b44243a60febd4724e46139084f8a3132690b253f424c8dcae5fd7d7625

See more details on using hashes here.

File details

Details for the file onefinance-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: onefinance-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 65.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for onefinance-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5360b055a2f23199b10e37113cb74342052df4ad977331ea67a041d947e1a324
MD5 5b1449cbdd4cee78e72cd1a7d28cba27
BLAKE2b-256 9c01be5a883ae5a07170c918cf0ebeea4e565c760c96d5892de5436818280c6b

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