Complete AGI Trading Platform: trading engine, DataOps, infrastructure, tests, CI/CD, docs#63
Open
Complete AGI Trading Platform: trading engine, DataOps, infrastructure, tests, CI/CD, docs#63
Conversation
Add shared models, trading engine, dataops, infrastructure, tests, CI/CD workflows, and documentation for the AGI Trading Platform. ## Shared Layer - Pydantic v2 models: Order, Position, Portfolio, OHLCV, OrderBook, Ticker, Trade, MarketSnapshot, TradingSignal, RiskAssessment, AGIDecision - Configuration via pydantic-settings with TRADING_ env var prefix - Structured logging via loguru with file rotation - Domain exceptions hierarchy rooted at TradingPlatformError - Utility helpers: Decimal rounding, async retry decorator, Timer ## Trading Engine - BaseConnector ABC with uniform interface for all exchanges - AlpacaConnector (paper trading default) via alpaca-py - BinanceConnector (testnet default) via python-binance - OrderManager: async order registry with exchange sync and state transitions - RiskEngine: pre-trade checks (order size, position size, drawdown, daily loss) - PortfolioManager: asyncio.Lock-protected P&L tracking with mark-to-market ## DataOps - MarketDataCollector: WebSocket feed with Redis pub/sub fan-out and exponential-backoff reconnect - TimeSeriesDB: asyncpg + TimescaleDB wrapper for OHLCV and trade storage - StreamProcessor: aiokafka producer/consumer with per-topic handler dispatch ## Infrastructure - docker-compose.yml: full stack (trading-engine, TimescaleDB, Redis, Kafka/ZooKeeper, Prometheus, Grafana) - docker/Dockerfile.trading-engine: Python 3.12-slim non-root image - Kubernetes Deployment + Service + ServiceAccount for trading-engine - Kubernetes StatefulSet + headless Service for PostgreSQL - Prometheus scrape config for all services ## Tests (26 passing) - Unit tests: OrderManager, RiskEngine, PortfolioManager - Integration tests: full trade lifecycle, risk blocking, multi-order tracking - Shared conftest with reusable Order/Position/Portfolio fixtures ## CI/CD - ci.yml: lint (ruff + mypy), test (pytest --cov), Docker build - cd.yml: staging deploy on main push, production deploy on version tag Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- portfolio_manager: fix commission handling on sell fills (subtract, not add) - risk_engine: warn when market order price cannot be estimated - time_series_db: add UNIQUE(time,symbol,interval) constraint; use explicit ON CONFLICT columns - stream_processor/market_data_collector: use Task[None] generic annotation - order_manager: document GIL-safety of order_count() - docker-compose: add comment explaining ZooKeeper vs KRaft trade-off - ci.yml / cd.yml: add explicit permissions: contents: read on all jobs to satisfy least-privilege GITHUB_TOKEN requirements Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ntation Co-authored-by: Stacey77 <54900383+Stacey77@users.noreply.github.com>
Co-authored-by: Stacey77 <54900383+Stacey77@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add missing critical components to AGI Trading Platform
Complete AGI Trading Platform: trading engine, DataOps, infrastructure, tests, CI/CD, docs
Feb 20, 2026
Stacey77
reviewed
Feb 21, 2026
Owner
|
OK |
Owner
|
DONE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #62 shipped the AI layer (AGI orchestrator, vertical/synthetic/quantum AI, ops frameworks) but left the execution and data plumbing unimplemented. This PR adds everything needed to run the platform end-to-end.
Shared layer (
shared/)Order,Position,Portfolio,OHLCV,OrderBook,Ticker,Trade,TradingSignal,RiskAssessment,AGIDecisionconfig.py: pydantic-settings withTRADING_*env vars + YAML overlay viaget_config()logger.py: loguru with rotating file sink and async correlation ID propagationexceptions.py: domain exception hierarchy (OrderRejectedError,RiskLimitError, etc.)utils.py:retrydecorator,RateLimiter(token bucket),TimerTrading engine (
trading_engine/)BaseConnectorABC — uniform interface across exchangesAlpacaConnector(paper mode default) andBinanceConnector(testnet default)OrderManager— async order registry; tracksPENDING → SUBMITTED → ACCEPTED → FILLED/CANCELLEDRiskEngine— pre-trade checks: order notional, position concentration, portfolio drawdown, daily loss limitPortfolioManager—asyncio.Lock-protected fill application and mark-to-market P&LDataOps (
dataops/)MarketDataCollector— WebSocket feed → Redis pub/sub, exponential-backoff reconnectTimeSeriesDB— asyncpg wrapper for TimescaleDB (OHLCV + trade storage)StreamProcessor— aiokafka producer/consumer with per-topic handler dispatchInfrastructure
docker-compose.yml: TimescaleDB, Redis, Kafka/ZooKeeper, Prometheus, Grafanadocker/Dockerfile.trading-engine: Python 3.12-slim, non-root userDeployment+StatefulSetfor Postgres,ServiceAccountinfrastructure/prometheus/prometheus.ymlRoot files
requirements.txt,main.py(FastAPI +/health+/metrics),config.yaml,.env.example,.gitignoreTests
OrderManager,RiskEngine,PortfolioManager, and full trade lifecycleCI/CD
ci.yml: ruff lint → pytest → Docker buildcd.yml: staging deploy onmainpush; production deploy on semver tagWarning
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:
https://api.github.com/graphql/usr/bin/gh gh auth status -data-downloader(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.