Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Market Data Gateway

Production-ready, stateless, exchange-agnostic market data gateway built with FastAPI.

It serves normalized market data for downstream systems such as:

  • Quant and ML Analytics engines
  • Market intelligence and portfolio platforms

The service uses Yahoo Finance as provider input, but returns a strict provider-neutral schema.


What you can see after hosting

This project is API-first. There is no frontend dashboard UI in the current architecture.

After deployment, you can access these JSON HTTP endpoints:

  • GET /health - service liveness
  • GET /readiness - process readiness and cache stats
  • GET /quote?symbol=INFY&exchange=NSE
  • GET /intraday?symbol=INFY&exchange=NSE&interval=5m
  • GET /historical?symbol=INFY&exchange=NSE&period=6mo
  • GET /fundamentals?symbol=INFY&exchange=NSE
  • GET /company?symbol=INFY&exchange=NSE
  • GET /search?query=INFY
  • GET /metrics - in-memory service metrics
  • GET /exchanges/status - per-exchange circuit and reliability summary
  • GET /market-status?exchange=NSE - exchange session status (calendar/timezone logic)

Backward-compatible routes:

  • GET /candles
  • GET /price/latest
  • GET /symbols

OpenAPI docs (auto-generated by FastAPI):

  • /docs
  • /redoc

Core capabilities

  • Stateless runtime (no database, no Redis)
  • In-memory TTL cache only
  • Exchange abstraction for NSE, BSE, NASDAQ
  • Per-exchange circuit breaker (CLOSED, OPEN, HALF_OPEN)
  • Controlled degradation (cache fallback during provider issues)
  • Internal metrics and exchange health visibility
  • Strict normalized responses with schema_version: "1.1"

Exchange model

Internal provider mapping:

  • NSE -> <SYMBOL>.NS
  • BSE -> <SYMBOL>.BO
  • NASDAQ -> <SYMBOL>

Provider-formatted symbols are not exposed in API output.


Cloud Run deployment (low-cost pattern)

This service is suitable for low-cost Cloud Run operation because it is stateless and has no external database dependency.

Recommended low-cost settings:

  • --min-instances=0
  • --max-instances sized to expected traffic
  • small CPU/memory tier (start with 1 vCPU, 512Mi)

1) Build and deploy using Cloud Build

gcloud builds submit --config cloudbuild.yaml \
  --substitutions=_REGION=us-central1,_AR_REPO=market-data,_SERVICE_NAME=market-data-gateway

2) Manual restart (new revision, same image)

Use this when you want to force a restart/revision rollout:

gcloud run deploy market-data-gateway \
  --region us-central1 \
  --platform managed \
  --image us-central1-docker.pkg.dev/<PROJECT_ID>/market-data/market-data-gateway:latest \
  --allow-unauthenticated

3) Fast instance recycle by changing env var (forces new revision)

gcloud run services update market-data-gateway \
  --region us-central1 \
  --update-env-vars RESTART_TOKEN=$(date +%s)

4) Roll traffic to latest revision

gcloud run services update-traffic market-data-gateway \
  --region us-central1 \
  --to-latest

Local development

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python -m app.main

Run tests:

PYTHONPATH=. pytest -q

Project summary

This project provides a unified market data gateway that normalizes quotes, candles, fundamentals, and company metadata across multiple exchanges in a deterministic schema, with in-memory resilience patterns (cache + circuit breaker + metrics) and backward-compatible APIs for existing consumers.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages