Skip to content

Add professional FastAPI crypto data service with OHLCV + indicators#2

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-fastapi-service-ohlcv
Draft

Add professional FastAPI crypto data service with OHLCV + indicators#2
Copilot wants to merge 2 commits intomainfrom
copilot/add-fastapi-service-ohlcv

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 19, 2026

Overview

Complete FastAPI service for cryptocurrency OHLCV data with real-time technical indicators (EMA 20/50/200, RSI-14, ATR-14) using ccxt exchange integration.

Architecture

Core Components

  • src/app/main.py - FastAPI app, health endpoint, router integration
  • src/app/core/ - Settings via pydantic-settings, logging config
  • src/app/api/v1/routes_live_data.py - /api/v1/live_data endpoint with query validation
  • src/app/integrations/exchanges.py - ccxt wrapper with rate limiting
  • src/app/services/ - Indicator calculations (ta + pandas), OHLCV processing
  • src/app/schemas/live_data.py - Pydantic models for request/response

Infrastructure

  • Docker: Python 3.11-slim, editable install with dev deps
  • CI: GitHub Actions - ruff, mypy strict, pytest
  • Type coverage: Full with mypy strict mode, pandas-stubs for numpy/pandas types

API Endpoint

GET /api/v1/live_data?symbol=BTC/USDT&timeframe=1h&limit=250&exchange=binance

Query Parameters

  • symbol (str, 3-30 chars, default: "BTC/USDT")
  • timeframe (str, 1-10 chars, default: "1h")
  • limit (int, 20-2000, default: 250)
  • exchange (str, 2-40 chars, default: "binance")

Response Model

  • Last 20 candles with OHLCV + indicators
  • Latest indicator values (EMA/RSI/ATR)
  • NaN → null conversion for JSON serialization
  • Numeric values rounded to 6 decimals

Error Handling

  • ccxt.NetworkError → 503 Service Unavailable
  • ccxt.ExchangeError → 400 Bad Request
  • ValueError → 400 Bad Request
  • Others → 500 Internal Server Error

Dependencies

Runtime: fastapi, uvicorn, pydantic-settings, ccxt, pandas, ta
Dev: pytest, httpx, ruff, mypy, pandas-stubs

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.binance.com
    • Triggering command: /home/REDACTED/.local/bin/pytest pytest -v (dns block)
    • Triggering command: /usr/local/bin/uvicorn uvicorn app.main:app --host 0.0.0.0 --port 8000 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Add a complete FastAPI service for fetching OHLCV candles and computing indicators (EMA/RSI/ATR) with Docker, CI, typing, and tests.

Changes to create (new files and folders under src/ plus top-level tooling):

  1. Project files
  • pyproject.toml (dependencies, dev deps, ruff, mypy, pytest config)
  • README.md (quickstart, Docker, notes)
  • .env.example
  • .gitignore
  • Dockerfile
  • docker-compose.yml
  • .github/workflows/ci.yml
  1. Application package (src/app)
  • src/app/init.py
  • src/app/main.py (FastAPI app, health endpoint, include router)
  1. core
  • src/app/core/init.py
  • src/app/core/config.py (pydantic-settings Settings)
  • src/app/core/logging.py (basic logging config)
  1. api
  • src/app/api/init.py
  • src/app/api/v1/init.py
  • src/app/api/v1/routes_live_data.py (GET /live_data route, validation, response_model)
  1. integrations
  • src/app/integrations/init.py
  • src/app/integrations/exchanges.py (ExchangeClient wrapper, build_exchange)
  1. schemas
  • src/app/schemas/init.py
  • src/app/schemas/live_data.py (Candle, LatestIndicators, LiveDataResponse Pydantic models)
  1. services
  • src/app/services/init.py
  • src/app/services/indicators.py (add_indicators, latest_indicator_values, NaN->None handling)
  • src/app/services/market_data.py (get_live_data, fetch ohlcv via ccxt, build response)
  1. tests
  • tests/init.py
  • tests/test_health.py
  • tests/test_live_data.py (network smoke test; notes recommend mocking ccxt for CI)

Implementation notes / behavior:

  • Uses ccxt for exchange connectivity; default exchange is 'binance' via settings.
  • Uses ta and pandas for indicators; rounds numeric values and converts NaN to null in responses.
  • Endpoint validates query params: symbol, timeframe, limit, exchange.
  • Error handling: ccxt.NetworkError -> 503, ccxt.ExchangeError -> 400, others -> 500.
  • Dockerfile installs package in editable mode with dev dependencies; docker-compose service 'api'.
  • GitHub Actions workflow runs ruff, mypy, pytest on Python 3.11.

Please create a pull request with these files added on top of branch 'main'. Do not add an assignee. Use the title: "Add professional FastAPI crypto data service with OHLCV + indicators" and include this problem statement in the PR description.

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Nfectious <19631929+Nfectious@users.noreply.github.com>
Copilot AI changed the title [WIP] Add complete FastAPI service for OHLCV candles and indicators Add professional FastAPI crypto data service with OHLCV + indicators Feb 19, 2026
Copilot AI requested a review from Nfectious February 19, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants