Skip to content

Add Order History: expose all-orders endpoint and tabbed dashboard view - #63

Open
Stacey77 with Copilot wants to merge 10 commits into
mainfrom
copilot/implement-trading-engine-dataops
Open

Add Order History: expose all-orders endpoint and tabbed dashboard view#63
Stacey77 with Copilot wants to merge 10 commits into
mainfrom
copilot/implement-trading-engine-dataops

Conversation

Copilot AI commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Paper MARKET orders fill instantly and disappear from the Open Orders view — there was no way to see order history. OrderManager.get_all_orders() existed but was never wired up.

Backend

  • GET /api/v1/orders/all — returns all orders regardless of status, sorted by updated_at desc
  • GET /api/v1/meta — exposes the canonical OPEN_STATUSES frozenset (derived from OrderStatus enum) so the frontend never hard-codes status strings
GET /api/v1/orders      → open orders only  (existing)
GET /api/v1/orders/all  → full session history, newest first  (new)
GET /api/v1/meta        → { open_order_statuses: [...] }  (new)

Dashboard

Orders panel gains Open / History tabs. History tab adds an Avg Fill column and replaces the Cancel button with for terminal orders. Open-status set is hydrated from /api/v1/meta on init.

Order History tab

Tests

7 new tests across TestMeta and TestListAllOrders (50 total).

Original prompt

Complete the AGI Trading Platform by adding the missing critical components from PR #62.

What's Missing from PR #62

The foundation PR #62 implemented the AI components but is missing:

  • Trading Engine (exchange connectors, order management)
  • DataOps (data ingestion, storage)
  • Infrastructure (Docker, Kubernetes)
  • Configuration files (main.py, requirements.txt, config.yaml)
  • Tests
  • Documentation

Implement These Components

1. Trading Engine

Create trading-engine/ directory with:

trading-engine/connectors/base_connector.py - Abstract base class:

from abc import ABC, abstractmethod
from typing import List, Optional
from shared.models.trading_models import Order, Position

class BaseConnector(ABC):
    @abstractmethod
    async def connect(self) -> bool:
        pass
    
    @abstractmethod
    async def place_order(self, order: Order) -> str:
        pass
    
    @abstractmethod
    async def get_positions(self) -> List[Position]:
        pass

trading-engine/connectors/alpaca_connector.py - Alpaca integration with alpaca-py library
trading-engine/connectors/binance_connector.py - Binance integration with python-binance

trading-engine/execution/order_manager.py - Order lifecycle management
trading-engine/risk_management/risk_engine.py - Pre-trade risk checks
trading-engine/portfolio/portfolio_manager.py - Position tracking and P&L

2. DataOps

Create dataops/ directory with:

dataops/ingestion/market_data_collector.py - Real-time market data collection
dataops/storage/time_series_db.py - TimescaleDB wrapper
dataops/processing/stream_processor.py - Kafka stream processing

3. Infrastructure

docker-compose.yml - Full stack with Redis, Postgres, Kafka, Prometheus, Grafana
docker/Dockerfile.trading-engine - Trading engine container
infrastructure/kubernetes/deployments/ - K8s manifests

4. Root Files

requirements.txt - All Python dependencies (torch, transformers, alpaca-py, etc.)
main.py - FastAPI application entry point
config.yaml - Application configuration
.env.example - Environment variables template

5. Tests

tests/unit/test_trading_engine.py - Trading engine unit tests
tests/integration/test_end_to_end.py - Full workflow tests
tests/conftest.py - Pytest fixtures

6. CI/CD

.github/workflows/ci.yml - Lint, test, build pipeline
.github/workflows/cd.yml - Deploy pipeline

7. Documentation

README.md - Comprehensive getting started guide with architecture overview
docs/DEPLOYMENT.md - Deployment instructions
docs/API.md - API documentation

Implementation Guidelines

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.

Copilot AI and others added 4 commits February 20, 2026 17:51
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
Copilot AI requested a review from Stacey77 February 20, 2026 18:01

@Stacey77 Stacey77 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#63

@Stacey77

Copy link
Copy Markdown
Owner

OK

@Stacey77
Stacey77 marked this pull request as ready for review February 21, 2026 01:34
@Stacey77

Copy link
Copy Markdown
Owner

DONE

…space and per-env ConfigMaps

Co-authored-by: Stacey77 <54900383+Stacey77@users.noreply.github.com>
Copilot AI changed the title Complete AGI Trading Platform: trading engine, DataOps, infrastructure, tests, CI/CD, docs Fix CD pipeline: production deployment was permanently blocked Mar 4, 2026
Copilot AI requested a review from Stacey77 March 4, 2026 16:26
Copilot AI and others added 2 commits March 4, 2026 16:38
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 Fix CD pipeline: production deployment was permanently blocked Wire trading service layer into FastAPI; add REST trading endpoints and paper connector Mar 4, 2026
Co-authored-by: Stacey77 <54900383+Stacey77@users.noreply.github.com>
Copilot AI changed the title Wire trading service layer into FastAPI; add REST trading endpoints and paper connector Add HTML trading dashboard served at / Mar 4, 2026
Co-authored-by: Stacey77 <54900383+Stacey77@users.noreply.github.com>
Copilot AI changed the title Add HTML trading dashboard served at / Add Order History: expose all-orders endpoint and tabbed dashboard view Mar 4, 2026

@Stacey77 Stacey77 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants