ForesightX-data
Purpose
Market data service responsible for price/history APIs, technical indicators, news lookups, and real-time streaming.
Responsibilities
- Fetch current prices and historical bars
- Compute RSI + MACD and persist indicator snapshots
- Normalize and store news data
- Cache responses in Redis for low-latency reads
- Provide websocket stream for tick updates
Tech stack
- FastAPI, async SQLAlchemy
- Redis caching
- External sources via yfinance
API endpoints
GET /price/{ticker}GET /history/{ticker}?limit=30GET /bars/{ticker}?interval=1h&limit=240GET /indicators/{ticker}GET /news/{ticker}GET /instruments/search?q=...&limit=15POST /stream/ingestWS /stream/{ticker}GET /health
I/O contract
- Input: ticker symbols and query params
- Output: typed JSON responses for price, history, indicators, news, and bars
Data ownership
instrumentsdaily_price_snapshotstechnical_indicator_snapshotsnews_articlesandinstrument_news
Real-time stream flow
- Upstream adapter pushes ticks to
POST /stream/ingest - Service persists tick and refreshes caches
- Websocket clients subscribed to
WS /stream/{ticker}receive updates
Deployment notes
- Configure via
.envin the service root - Key env vars:
DATABASE_URL,REDIS_URL,CACHE_TTL_SECONDS,STREAM_HEARTBEAT_SECONDS - Default port:
8001