Skip to content

A lightweight FastAPI microservice proxy for Yahoo Finance data via yfinance, enabling seamless access for any language or platform.

License

Notifications You must be signed in to change notification settings

Vorckea/yfinance-service

Repository files navigation

YFinance Proxy Service

Build Status Coverage Python FastAPI License Docker Stars Release

A lightweight FastAPI microservice that wraps yfinance, exposing RESTful endpoints for market data, perfect for non-Python projects, microservice architectures, and monitorable deployments.

Why Use This?

  • Language-agnostic: Get Yahoo Finance data via HTTP, no python dependency.
  • Production-ready: Includes Prometheus metrics and health checks.
  • Simple setup: Run with Docker, Poetry, or Docker Compose (Grafana/Prometheus included).
  • Extendable: Built on FastAPI; easy to add routes or middleware.

Features

Feature Description
Quote API Fetch latest market quotes (OHLCV) for ticker symbols.
Historical API Retrieve historical data within a date range.
Info API Get company fundamentals (sector, market cap, etc.).
Health Check Simple /health endpoint to verify service status.
Prometheus Metrics /metrics endpoint for request count, errors, latency.

API Endpoints

Endpoint Description Example
GET /quote/{symbol} Latest quote for a symbol /quote/AAPL
GET /historical/{symbol}?start=YYYY-MM-DD&end=YYYY-MM-DD Historical OHLCV data /historical/AAPL?start=2024-01-01&end=2024-02-01
GET /info/{symbol} Company details /info/TSLA
GET /health Health check /health
GET /metrics Prometheus metrics /metrics

Quick Start

Run with Docker

docker pull ghcr.io/vorckea/yfinance-service:latest
docker run -p 8000:8000 ghcr.io/vorckea/yfinance-service:latest

Then visit: http://localhost:8000/docs: Interactive Swagger UI

Local Development (Poetry)

poetry install
poetry run uvicorn app.main:app --reload

With Prometheus + Grafana

docker compose up --build

Access:

Relevant files:

  • Prometheus config: monitoring/infra/prometheus.yml
  • Alert rules: monitoring/infra/alert.rules.yml
  • Dashboards: monitoring/dashboards/

Usage Example

Get the latest quote for Apple:

curl http://localhost:8000/quote/AAPL

Get company info for Tesla:

curl http://localhost:8000/info/TSLA

Monitoring Example:

Prometheus query for average latency (5-minute window):

rate(request_latency_seconds_sum[5m]) / rate(request_latency_seconds_count[5m])

Contributing

Contributions are welcome!

  • Open an issue for bugs or new features.
  • Look for good first issue labels to get started.
  • Please see CONTRIBUTING.md

License

MIT License. See LICENSE for details.

Author

Aksel Heggland Schrader (@Vorckea)

About

A lightweight FastAPI microservice proxy for Yahoo Finance data via yfinance, enabling seamless access for any language or platform.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors 9