# Trading Bot — Sprint Plan ## Sprint 1: Foundation **Goal:** Working project skeleton with database, shared libraries, and infrastructure containers. **Acceptance Criteria:** - [ ] `docker compose up -d postgres redis` boots healthy containers - [ ] `python -m alembic upgrade head` applies all migrations cleanly - [ ] `python -m pytest tests/` — all unit tests pass - [ ] Shared libraries importable: `shared.config`, `shared.redis_streams`, `shared.telemetry`, `shared.models`, `shared.schemas`, `shared.db` **Deliverables:** - `pyproject.toml` with all dependency groups - `docker-compose.yml` with postgres+timescaledb, redis, ollama - `.env.example`, `.gitignore` - `shared/` package: config, redis_streams, telemetry, db - `shared/models/` — all SQLAlchemy models (trading, news, learning, auth, timeseries) - `shared/schemas/` — all Pydantic schemas - `alembic/` — initial migration with hypertables - Unit tests for redis_streams, models, schemas **Tasks (Plan Tasks 1-4):** - Task 1: Python monorepo setup + shared utilities - Task 2: Docker Compose infrastructure - Task 3: Database models + Alembic migrations - Task 4: Pydantic schemas --- ## Sprint 2: Data Pipeline **Goal:** News articles flow from RSS/Reddit through sentiment analysis into scored Redis stream. **Acceptance Criteria:** - [ ] News fetcher polls RSS feeds and publishes `RawArticle` to `news:raw` stream - [ ] Sentiment analyzer consumes `news:raw`, scores with FinBERT, publishes to `news:scored` - [ ] Broker abstraction interface defined, Alpaca implementation can fetch account/positions - [ ] All unit tests pass **Deliverables:** - `shared/broker/` — abstract interface + Alpaca implementation - `services/news-fetcher/` — RSS + Reddit sources - `services/sentiment-analyzer/` — FinBERT + Ollama fallback + ticker extraction - Unit tests for broker, news fetcher, sentiment analyzer **Tasks (Plan Tasks 5-7):** - Task 5: Brokerage abstraction layer - Task 6: News fetcher service - Task 7: Sentiment analyzer service --- ## Sprint 3: Trading Core **Goal:** System generates trade signals from market data + sentiment and executes paper trades. **Acceptance Criteria:** - [ ] 3 strategies (momentum, mean reversion, news-driven) produce correct signals for known inputs - [ ] Signal generator combines strategies via weighted ensemble, publishes to `signals:generated` - [ ] Trade executor applies risk checks, submits orders via broker, records trades in DB - [ ] All unit tests pass **Deliverables:** - `shared/strategies/` — base interface + 3 strategy implementations - `services/signal-generator/` — market data consumer + weighted ensemble - `services/trade-executor/` — risk manager + execution loop - Unit tests for strategies, signal generator, trade executor **Tasks (Plan Tasks 8-10):** - Task 8: Strategy implementations - Task 9: Signal generator service - Task 10: Trade executor service --- ## Sprint 4: Intelligence **Goal:** System learns from trade outcomes and can replay historical data for backtesting. **Acceptance Criteria:** - [ ] Learning engine computes P&L, adjusts strategy weights respecting all guardrails - [ ] Backtester replays historical data through same strategies, produces equity curves + metrics - [ ] Weight adjustments logged in `learning_adjustments` table - [ ] All unit tests pass **Deliverables:** - `services/learning-engine/` — evaluator + weight adjuster - `backtester/` — engine, simulated broker, data loader, metrics - Unit tests for learning engine, backtester **Tasks (Plan Tasks 11-12):** - Task 11: Learning engine service - Task 12: Backtesting engine --- ## Sprint 5: API & Dashboard **Goal:** Web interface for monitoring and controlling the trading bot. **Acceptance Criteria:** - [ ] Passkey registration and login works end-to-end - [ ] All API endpoints return correct data (portfolio, trades, signals, strategies, news) - [ ] Control endpoints pause/resume trading, force-close positions - [ ] Dashboard renders all 5 views with real-time WebSocket updates - [ ] All tests pass (backend + frontend) **Deliverables:** - `services/api-gateway/` — FastAPI with passkey auth, all routes, WebSocket - `dashboard/` — React app with auth, portfolio, trades, strategies, news, backtest views - Unit tests for API routes, auth flow **Tasks (Plan Tasks 13-16):** - Task 13: API Gateway — Auth - Task 14: API Gateway — Trading endpoints - Task 15: Dashboard — Setup & Auth - Task 16: Dashboard — Trading views --- ## Sprint 6: Integration & Deployment **Goal:** Full system runs in Docker Compose, passes integration tests. **Acceptance Criteria:** - [ ] `docker compose up` starts all services, all health checks pass - [ ] Smoke test script passes (hits key endpoints, verifies responses) - [ ] Integration tests pass (news pipeline end-to-end, trading flow end-to-end) - [ ] Default strategies seeded in database **Deliverables:** - `docker/` — Dockerfiles for all services - Updated `docker-compose.yml` with all application services - `scripts/smoke-test.sh`, `scripts/seed_strategies.py` - `tests/integration/` — pipeline and trading flow tests **Tasks (Plan Tasks 17-18):** - Task 17: Dockerfiles & full Docker Compose - Task 18: Integration testing & seed data