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.
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 livenessGET /readiness- process readiness and cache statsGET /quote?symbol=INFY&exchange=NSEGET /intraday?symbol=INFY&exchange=NSE&interval=5mGET /historical?symbol=INFY&exchange=NSE&period=6moGET /fundamentals?symbol=INFY&exchange=NSEGET /company?symbol=INFY&exchange=NSEGET /search?query=INFYGET /metrics- in-memory service metricsGET /exchanges/status- per-exchange circuit and reliability summaryGET /market-status?exchange=NSE- exchange session status (calendar/timezone logic)
Backward-compatible routes:
GET /candlesGET /price/latestGET /symbols
OpenAPI docs (auto-generated by FastAPI):
/docs/redoc
- 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"
Internal provider mapping:
NSE-><SYMBOL>.NSBSE-><SYMBOL>.BONASDAQ-><SYMBOL>
Provider-formatted symbols are not exposed in API output.
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-instancessized to expected traffic- small CPU/memory tier (start with
1 vCPU,512Mi)
gcloud builds submit --config cloudbuild.yaml \
--substitutions=_REGION=us-central1,_AR_REPO=market-data,_SERVICE_NAME=market-data-gatewayUse 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-unauthenticatedgcloud run services update market-data-gateway \
--region us-central1 \
--update-env-vars RESTART_TOKEN=$(date +%s)gcloud run services update-traffic market-data-gateway \
--region us-central1 \
--to-latestpython -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python -m app.mainRun tests:
PYTHONPATH=. pytest -qThis 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.