# Foxhunt API Documentation **Version**: 1.0 **Last Updated**: 2025-10-16 **API Gateway**: `localhost:50051` **Protocol**: gRPC with TLS/mTLS (RSA 4096-bit) --- ## Table of Contents 1. [Overview](#overview) 2. [Authentication & Authorization](#authentication--authorization) 3. [Rate Limiting](#rate-limiting) 4. [Error Handling](#error-handling) 5. [Service APIs](#service-apis) - [Trading Service (7 methods)](#trading-service) - [Trading Agent Service (18 methods)](#trading-agent-service) - [ML Training Service (12 methods)](#ml-training-service) - [Backtesting Service (6 methods)](#backtesting-service) - [Risk Management Service (6 methods)](#risk-management-service) - [Monitoring Service (10 methods)](#monitoring-service) - [Configuration Service (4 methods)](#configuration-service) 6. [TLI Command Reference](#tli-command-reference) 7. [Common Data Types](#common-data-types) --- ## Overview The Foxhunt HFT Trading System exposes **37 gRPC methods** across **7 microservices**, all accessible through a single API Gateway at port **50051**. The API Gateway provides: - **Authentication**: JWT + MFA (multi-factor authentication) - **Rate Limiting**: Token bucket algorithm (100 req/sec default) - **Audit Logging**: All requests logged to PostgreSQL - **Request Routing**: Automatic service discovery and load balancing - **TLS Encryption**: RSA 4096-bit certificates for all connections ### Service Architecture ``` ┌──────────────────────────────────────────────────────────────┐ │ API Gateway (Port 50051) │ │ Auth, Rate Limiting, Audit Logging, Routing │ └──┬──────────────┬──────────────┬──────────────┬──────────────┘ │ │ │ │ ▼ ▼ ▼ ▼ Trading Trading Agent ML Training Backtesting Service Service Service Service (50052) (50055) (50054) (50053) ``` --- ## Authentication & Authorization ### JWT Authentication All API requests require a valid JWT token in the `authorization` metadata header: ``` authorization: Bearer ``` ### Obtaining a JWT Token (via TLI) ```bash # Login with username and password tli auth login --username --password # MFA verification (if enabled) tli auth verify-mfa --code <6-digit-code> # Token is automatically stored in ~/.config/foxhunt-tli/tokens/ ``` ### Token Lifetime - **Access Token**: 1 hour (3600 seconds) - **Refresh Token**: 7 days (604800 seconds) - **MFA Grace Period**: 10 minutes after login ### Required Permissions | Operation | Required Role | |-----------|--------------| | Submit Order | `TRADER`, `ADMIN` | | Cancel Order | `TRADER`, `ADMIN` | | Get Positions | `TRADER`, `VIEWER`, `ADMIN` | | Emergency Stop | `ADMIN` only | | Update Config | `ADMIN` only | | View Metrics | `TRADER`, `VIEWER`, `ADMIN` | --- ## Rate Limiting The API Gateway enforces rate limits using a token bucket algorithm: ### Default Limits | Endpoint Type | Requests/Second | Burst Capacity | |---------------|----------------|----------------| | Trading Operations | 100 | 200 | | Market Data Streams | 10 streams | 20 streams | | Backtesting | 5 | 10 | | ML Training | 2 | 5 | | Configuration | 10 | 20 | ### Rate Limit Headers Response headers indicate rate limit status: ``` X-RateLimit-Limit: 100 X-RateLimit-Remaining: 87 X-RateLimit-Reset: 1729123456 ``` ### Rate Limit Exceeded Error ```json { "code": "RESOURCE_EXHAUSTED", "message": "Rate limit exceeded: 100 requests/second", "details": { "retry_after_seconds": 1 } } ``` --- ## Error Handling ### gRPC Status Codes | gRPC Code | HTTP Equivalent | Description | |-----------|----------------|-------------| | `OK` (0) | 200 | Success | | `INVALID_ARGUMENT` (3) | 400 | Invalid request parameters | | `UNAUTHENTICATED` (16) | 401 | Missing or invalid JWT token | | `PERMISSION_DENIED` (7) | 403 | Insufficient permissions | | `NOT_FOUND` (5) | 404 | Resource not found | | `ALREADY_EXISTS` (6) | 409 | Resource already exists | | `RESOURCE_EXHAUSTED` (8) | 429 | Rate limit exceeded | | `INTERNAL` (13) | 500 | Internal server error | | `UNAVAILABLE` (14) | 503 | Service temporarily unavailable | ### Error Response Format ```protobuf message ErrorResponse { string code = 1; // gRPC status code name string message = 2; // Human-readable error message map details = 3; // Additional error context int64 timestamp = 4; // Error timestamp (nanoseconds) } ``` --- ## Service APIs ### Trading Service **Base Package**: `trading` **Backend Port**: 50052 **Total Methods**: 15 (12 core + 3 ML) #### Core Trading Operations ##### 1. SubmitOrder Submit a new trading order with validation and risk checks. **Method**: `TradingService.SubmitOrder` **Request**: ```protobuf message SubmitOrderRequest { string symbol = 1; // Trading symbol (e.g., "AAPL", "BTC-USD", "ES.FUT") OrderSide side = 2; // BUY or SELL double quantity = 3; // Number of shares/units to trade OrderType order_type = 4; // MARKET, LIMIT, STOP, STOP_LIMIT optional double price = 5; // Limit price (required for LIMIT orders) optional double stop_price = 6; // Stop price (required for STOP orders) string account_id = 7; // Trading account identifier map metadata = 8; // Additional order metadata (strategy, tags, etc.) } ``` **Response**: ```protobuf message SubmitOrderResponse { string order_id = 1; // Unique order identifier OrderStatus status = 2; // PENDING, SUBMITTED, etc. string message = 3; // Status message or error description int64 timestamp = 4; // Order submission timestamp (nanoseconds) } ``` **TLI Command**: `tli trade submit --symbol --side --quantity --type ` **Example**: ```bash tli trade submit --symbol ES.FUT --side BUY --quantity 10 --type MARKET ``` **Performance**: P99 latency ~15.96ms (target: <100ms) --- ##### 2. CancelOrder Cancel an existing order by order ID. **Method**: `TradingService.CancelOrder` **Request**: ```protobuf message CancelOrderRequest { string order_id = 1; // Order ID to cancel string account_id = 2; // Account ID for verification } ``` **Response**: ```protobuf message CancelOrderResponse { bool success = 1; // True if cancellation was successful string message = 2; // Success confirmation or error message int64 timestamp = 3; // Cancellation timestamp (nanoseconds) } ``` **TLI Command**: `tli trade cancel --order-id ` **Example**: ```bash tli trade cancel --order-id "550e8400-e29b-41d4-a716-446655440000" ``` --- ##### 3. GetOrderStatus Get current status of a specific order. **Method**: `TradingService.GetOrderStatus` **Request**: ```protobuf message GetOrderStatusRequest { string order_id = 1; // Order ID to query } ``` **Response**: ```protobuf message GetOrderStatusResponse { Order order = 1; // Complete order details with current status } ``` **TLI Command**: `tli trade status --order-id ` **Example**: ```bash tli trade status --order-id "550e8400-e29b-41d4-a716-446655440000" ``` --- ##### 4. StreamOrders Stream real-time order events for monitoring order lifecycle. **Method**: `TradingService.StreamOrders` (Server Streaming) **Request**: ```protobuf message StreamOrdersRequest { optional string account_id = 1; // Filter by account (all accounts if not specified) optional string symbol = 2; // Filter by symbol (all symbols if not specified) } ``` **Response Stream**: ```protobuf message OrderEvent { string order_id = 1; // Order identifier Order order = 2; // Complete order details OrderEventType event_type = 3; // CREATED, UPDATED, FILLED, CANCELLED, etc. int64 timestamp = 4; // Event timestamp (nanoseconds) string message = 5; // Event message or additional details } ``` **TLI Command**: `tli trade stream --type orders [--symbol ]` --- ##### 5. GetPositions Get current positions for account and/or symbol. **Method**: `TradingService.GetPositions` **Request**: ```protobuf message GetPositionsRequest { optional string account_id = 1; // Filter by account (all accounts if not specified) optional string symbol = 2; // Filter by symbol (all symbols if not specified) } ``` **Response**: ```protobuf message GetPositionsResponse { repeated Position positions = 1; // List of current positions } ``` **TLI Command**: `tli trade positions [--symbol ]` **Example**: ```bash tli trade positions --symbol ES.FUT ``` --- ##### 6. StreamPositions Stream real-time position updates as trades execute. **Method**: `TradingService.StreamPositions` (Server Streaming) **Request**: ```protobuf message StreamPositionsRequest { optional string account_id = 1; // Filter by account (all accounts if not specified) } ``` **Response Stream**: ```protobuf message PositionEvent { string symbol = 1; // Trading symbol Position position = 2; // Updated position details PositionEventType event_type = 3; // OPENED, UPDATED, CLOSED int64 timestamp = 4; // Event timestamp (nanoseconds) double quantity = 5; // Position quantity (quick access) double average_price = 6; // Average entry price (quick access) double unrealized_pnl = 7; // Unrealized P&L (quick access) } ``` **TLI Command**: `tli trade stream --type positions` --- ##### 7. GetPortfolioSummary Get comprehensive portfolio summary with P&L and risk metrics. **Method**: `TradingService.GetPortfolioSummary` **Request**: ```protobuf message GetPortfolioSummaryRequest { string account_id = 1; // Account ID for portfolio summary } ``` **Response**: ```protobuf message GetPortfolioSummaryResponse { double total_value = 1; // Total portfolio value in USD double unrealized_pnl = 2; // Unrealized profit/loss double realized_pnl = 3; // Realized profit/loss for the day double day_pnl = 4; // Total P&L for the current trading day double buying_power = 5; // Available buying power double margin_used = 6; // Amount of margin currently used repeated Position positions = 7; // Detailed position information } ``` **TLI Command**: `tli trade portfolio` --- #### Market Data Operations ##### 8. StreamMarketData Stream real-time market data (trades, quotes, order book). **Method**: `TradingService.StreamMarketData` (Server Streaming) **Request**: ```protobuf message StreamMarketDataRequest { repeated string symbols = 1; // List of symbols to subscribe to repeated MarketDataType data_types = 2; // TRADE, QUOTE, ORDER_BOOK } ``` **Response Stream**: ```protobuf message MarketDataEvent { string symbol = 1; // Trading symbol MarketDataType data_type = 2; // Type of market data oneof data { Trade trade = 3; // Trade data (when data_type = TRADE) Quote quote = 4; // Quote data (when data_type = QUOTE) OrderBook order_book = 5; // Order book data (when data_type = ORDER_BOOK) } int64 timestamp = 6; // Market data timestamp (nanoseconds) } ``` **TLI Command**: `tli market stream --symbols --types ` --- ##### 9. GetOrderBook Get current order book snapshot for a symbol. **Method**: `TradingService.GetOrderBook` **Request**: ```protobuf message GetOrderBookRequest { string symbol = 1; // Symbol to get order book for optional int32 depth = 2; // Number of price levels (default: full book) } ``` **Response**: ```protobuf message GetOrderBookResponse { OrderBook order_book = 1; // Current order book snapshot } ``` **TLI Command**: `tli market book --symbol [--depth ]` --- #### Execution Operations ##### 10. StreamExecutions Stream real-time trade executions as they occur. **Method**: `TradingService.StreamExecutions` (Server Streaming) **Request**: ```protobuf message StreamExecutionsRequest { optional string account_id = 1; // Filter by account (all accounts if not specified) optional string symbol = 2; // Filter by symbol (all symbols if not specified) } ``` **Response Stream**: ```protobuf message ExecutionEvent { string execution_id = 1; // Execution identifier Execution execution = 2; // Execution details int64 timestamp = 3; // Event timestamp (nanoseconds) string order_id = 4; // Associated order ID (quick access) string symbol = 5; // Trading symbol (quick access) double quantity = 6; // Executed quantity (quick access) double price = 7; // Execution price (quick access) } ``` **TLI Command**: `tli trade stream --type executions` --- ##### 11. GetExecutionHistory Get historical execution data with filtering options. **Method**: `TradingService.GetExecutionHistory` **Request**: ```protobuf message GetExecutionHistoryRequest { optional string account_id = 1; // Filter by account (all accounts if not specified) optional string symbol = 2; // Filter by symbol (all symbols if not specified) optional int64 start_time = 3; // Start time for query (nanoseconds) optional int64 end_time = 4; // End time for query (nanoseconds) optional int32 limit = 5; // Maximum number of executions to return } ``` **Response**: ```protobuf message GetExecutionHistoryResponse { repeated Execution executions = 1; // List of historical executions } ``` **TLI Command**: `tli trade history [--symbol ] [--limit ]` --- #### ML Trading Operations ##### 12. SubmitMLOrder Submit ML-generated trading order with ensemble predictions. **Method**: `TradingService.SubmitMLOrder` **Request**: ```protobuf message MLOrderRequest { string symbol = 1; // Trading symbol (e.g., "ES.FUT") string account_id = 2; // Trading account identifier bool use_ensemble = 3; // Use ensemble voting or specific model optional string model_name = 4; // Specific model name if not using ensemble repeated double features = 5; // Feature vector for ML prediction (26 features: OHLCV + technicals) } ``` **Response**: ```protobuf message MLOrderResponse { string order_id = 1; // Order ID if executed string prediction_id = 2; // Prediction ID from ensemble_predictions table string action = 3; // Action taken: BUY, SELL, HOLD double confidence = 4; // Prediction confidence (0.0-1.0) string message = 5; // Status message bool executed = 6; // True if order was executed } ``` **TLI Command**: `tli trade ml submit --symbol [--model ]` **Example**: ```bash # Submit ensemble ML order tli trade ml submit --symbol ES.FUT # Submit order using specific model tli trade ml submit --symbol ES.FUT --model DQN ``` **Performance**: Inference latency ~200μs (DQN), ~500μs (MAMBA-2) --- ##### 13. GetMLPredictions Get ML prediction history with outcomes. **Method**: `TradingService.GetMLPredictions` **Request**: ```protobuf message MLPredictionsRequest { string symbol = 1; // Trading symbol to filter by optional string model_name = 2; // Filter by specific model int32 limit = 3; // Maximum predictions to return (default: 100) optional int64 start_time = 4; // Start time filter (nanoseconds) optional int64 end_time = 5; // End time filter (nanoseconds) } ``` **Response**: ```protobuf message MLPredictionsResponse { repeated MLPrediction predictions = 1; // List of predictions with outcomes } ``` **TLI Command**: `tli trade ml predictions --symbol [--model ] [--limit ]` **Example**: ```bash tli trade ml predictions --symbol ES.FUT --limit 50 ``` --- ##### 14. GetMLPerformance Get ML model performance metrics. **Method**: `TradingService.GetMLPerformance` **Request**: ```protobuf message MLPerformanceRequest { optional string model_name = 1; // Filter by specific model (or all if not specified) optional int64 start_time = 2; // Start time for metrics (nanoseconds) optional int64 end_time = 3; // End time for metrics (nanoseconds) } ``` **Response**: ```protobuf message MLPerformanceResponse { repeated ModelPerformance models = 1; // Performance metrics per model } ``` **TLI Command**: `tli trade ml performance [--model ]` **Example**: ```bash # Get all model performance tli trade ml performance # Get specific model performance tli trade ml performance --model MAMBA2 ``` --- ### Trading Agent Service **Base Package**: `trading_agent` **Backend Port**: 50055 **Total Methods**: 18 The Trading Agent Service orchestrates portfolio management decisions through universe selection, asset ranking, capital allocation, and order generation. #### Universe Management ##### 1. SelectUniverse Select tradable universe based on liquidity, volatility, and ML signals. **Method**: `TradingAgentService.SelectUniverse` **Request**: ```protobuf message SelectUniverseRequest { UniverseCriteria criteria = 1; // Selection criteria optional uint32 max_instruments = 2; // Maximum instruments in universe bool force_refresh = 3; // Force recalculation } ``` **Response**: ```protobuf message SelectUniverseResponse { repeated Instrument instruments = 1; // Selected instruments UniverseMetrics metrics = 2; // Universe quality metrics int64 timestamp = 3; // Selection timestamp (nanoseconds) string universe_id = 4; // Unique universe identifier } ``` **TLI Command**: `tli agent universe select [--max-instruments ]` **Performance**: <1s (target met) --- ##### 2. GetUniverse Get current trading universe configuration. **Method**: `TradingAgentService.GetUniverse` **Request**: ```protobuf message GetUniverseRequest { optional string universe_id = 1; // Get specific universe, or current if not specified } ``` **Response**: ```protobuf message GetUniverseResponse { string universe_id = 1; repeated Instrument instruments = 2; UniverseCriteria criteria = 3; UniverseMetrics metrics = 4; int64 created_at = 5; int64 updated_at = 6; } ``` **TLI Command**: `tli agent universe show` --- ##### 3. UpdateUniverseCriteria Update universe selection criteria. **Method**: `TradingAgentService.UpdateUniverseCriteria` **Request**: ```protobuf message UpdateUniverseCriteriaRequest { UniverseCriteria criteria = 1; } ``` **Response**: ```protobuf message UpdateUniverseCriteriaResponse { bool success = 1; string message = 2; string universe_id = 3; // New universe ID after update } ``` **TLI Command**: `tli agent universe update --min-liquidity --min-volatility ` --- #### Asset Selection ##### 4. SelectAssets Select specific assets to trade within universe using ML-driven ranking. **Method**: `TradingAgentService.SelectAssets` **Request**: ```protobuf message SelectAssetsRequest { string universe_id = 1; // Universe to select from AssetSelectionCriteria criteria = 2; // Selection criteria uint32 max_assets = 3; // Maximum assets to select } ``` **Response**: ```protobuf message SelectAssetsResponse { repeated AssetScore assets = 1; // Selected assets with scores SelectionMetrics metrics = 2; // Selection quality metrics int64 timestamp = 3; } ``` **TLI Command**: `tli agent assets select --max-assets ` **Performance**: <2s (target met) **Multi-Factor Scoring**: - ML Score: 40% weight - Momentum Score: 30% weight - Value Score: 20% weight - Liquidity Score: 10% weight --- ##### 5. GetSelectedAssets Get current asset selection with scores. **Method**: `TradingAgentService.GetSelectedAssets` **Request**: ```protobuf message GetSelectedAssetsRequest { optional string universe_id = 1; } ``` **Response**: ```protobuf message GetSelectedAssetsResponse { repeated AssetScore assets = 1; SelectionMetrics metrics = 2; int64 timestamp = 3; } ``` **TLI Command**: `tli agent assets show` --- #### Portfolio Allocation ##### 6. AllocatePortfolio Allocate capital across selected assets using one of 5 strategies. **Method**: `TradingAgentService.AllocatePortfolio` **Request**: ```protobuf message AllocatePortfolioRequest { repeated AssetScore assets = 1; // Assets to allocate across AllocationStrategy strategy = 2; // EQUAL_WEIGHT, RISK_PARITY, MEAN_VARIANCE, ML_OPTIMIZED, KELLY RiskConstraints risk_constraints = 3; // Risk limits double total_capital = 4; // Total capital to allocate } ``` **Response**: ```protobuf message AllocatePortfolioResponse { repeated AssetAllocation allocations = 1; // Allocation per asset AllocationMetrics metrics = 2; // Allocation quality metrics int64 timestamp = 3; string allocation_id = 4; } ``` **TLI Command**: `tli agent allocate --strategy --capital ` **Performance**: <500ms (target met) **Supported Allocation Strategies**: 1. **Equal Weight**: 1/N allocation 2. **Risk Parity**: Equal risk contribution per asset 3. **Mean-Variance**: Markowitz optimization 4. **ML-Optimized**: ML model-driven allocation 5. **Kelly Criterion**: Optimal bet sizing --- ##### 7. GetAllocation Get current portfolio allocation. **Method**: `TradingAgentService.GetAllocation` **Request**: ```protobuf message GetAllocationRequest { optional string allocation_id = 1; // Get specific allocation, or current if not specified } ``` **Response**: ```protobuf message GetAllocationResponse { string allocation_id = 1; repeated AssetAllocation allocations = 2; AllocationMetrics metrics = 3; int64 created_at = 4; double total_capital = 5; } ``` **TLI Command**: `tli agent allocate show` --- ##### 8. RebalancePortfolio Rebalance portfolio based on target allocation. **Method**: `TradingAgentService.RebalancePortfolio` **Request**: ```protobuf message RebalancePortfolioRequest { string allocation_id = 1; // Target allocation double rebalance_threshold = 2; // Min deviation to trigger rebalance (%) bool force_rebalance = 3; // Force rebalance regardless of threshold } ``` **Response**: ```protobuf message RebalancePortfolioResponse { repeated RebalanceAction actions = 1; // Required rebalancing actions RebalanceMetrics metrics = 2; bool rebalance_required = 3; int64 timestamp = 4; } ``` **TLI Command**: `tli agent rebalance [--threshold ] [--force]` --- #### Order Generation ##### 9. GenerateOrders Generate orders based on allocation and ML signals. **Method**: `TradingAgentService.GenerateOrders` **Request**: ```protobuf message GenerateOrdersRequest { string allocation_id = 1; // Target allocation repeated MLSignal ml_signals = 2; // ML predictions for timing OrderGenerationStrategy strategy = 3; // Order generation algorithm } ``` **Response**: ```protobuf message GenerateOrdersResponse { repeated GeneratedOrder orders = 1; // Generated order instructions OrderGenerationMetrics metrics = 2; int64 timestamp = 3; string order_batch_id = 4; } ``` **TLI Command**: `tli agent orders generate` --- ##### 10. SubmitAgentOrders Submit generated orders to Trading Service. **Method**: `TradingAgentService.SubmitAgentOrders` **Request**: ```protobuf message SubmitAgentOrdersRequest { string order_batch_id = 1; // Batch ID from GenerateOrders repeated GeneratedOrder orders = 2; // Orders to submit bool dry_run = 3; // Test without actual submission } ``` **Response**: ```protobuf message SubmitAgentOrdersResponse { repeated OrderSubmissionResult results = 1; // Submission results per order OrderSubmissionMetrics metrics = 2; int64 timestamp = 3; } ``` **TLI Command**: `tli agent orders submit --batch-id [--dry-run]` --- #### Strategy Coordination ##### 11. RegisterStrategy Register a trading strategy with the agent. **Method**: `TradingAgentService.RegisterStrategy` **Request**: ```protobuf message RegisterStrategyRequest { string strategy_name = 1; // Unique strategy name StrategyType strategy_type = 2; // ML_ENSEMBLE, MEAN_REVERSION, MOMENTUM, ARBITRAGE, MARKET_MAKING StrategyConfig config = 3; // Strategy configuration bool auto_enable = 4; // Enable immediately after registration } ``` **Response**: ```protobuf message RegisterStrategyResponse { bool success = 1; string strategy_id = 2; string message = 3; } ``` **TLI Command**: `tli agent strategy register --name --type ` --- ##### 12. ListStrategies Get list of active strategies. **Method**: `TradingAgentService.ListStrategies` **Request**: ```protobuf message ListStrategiesRequest { optional StrategyStatus status_filter = 1; // ENABLED, DISABLED, PAUSED, ERROR } ``` **Response**: ```protobuf message ListStrategiesResponse { repeated Strategy strategies = 1; } ``` **TLI Command**: `tli agent strategy list [--status ]` --- ##### 13. UpdateStrategyStatus Enable/disable a strategy. **Method**: `TradingAgentService.UpdateStrategyStatus` **Request**: ```protobuf message UpdateStrategyStatusRequest { string strategy_id = 1; StrategyStatus new_status = 2; // ENABLED, DISABLED, PAUSED optional string reason = 3; } ``` **Response**: ```protobuf message UpdateStrategyStatusResponse { bool success = 1; string message = 2; Strategy updated_strategy = 3; } ``` **TLI Command**: `tli agent strategy update --id --status ` --- #### Agent Monitoring ##### 14. GetAgentStatus Get comprehensive agent status and performance. **Method**: `TradingAgentService.GetAgentStatus` **Request**: ```protobuf message GetAgentStatusRequest { bool include_performance = 1; // Include performance metrics bool include_positions = 2; // Include current positions } ``` **Response**: ```protobuf message GetAgentStatusResponse { AgentStatus status = 1; optional AgentPerformanceMetrics performance = 2; optional PositionSummary positions = 3; int64 timestamp = 4; } ``` **TLI Command**: `tli agent status [--with-performance] [--with-positions]` --- ##### 15. StreamAgentActivity Stream real-time agent decisions and actions. **Method**: `TradingAgentService.StreamAgentActivity` (Server Streaming) **Request**: ```protobuf message StreamAgentActivityRequest { repeated ActivityType activity_types = 1; // UNIVERSE_SELECTION, ASSET_SELECTION, ALLOCATION, ORDER_GENERATION, STRATEGY } ``` **Response Stream**: ```protobuf message AgentActivityEvent { ActivityType activity_type = 1; oneof event { UniverseSelectionEvent universe_event = 2; AssetSelectionEvent asset_event = 3; AllocationEvent allocation_event = 4; OrderGenerationEvent order_event = 5; StrategyEvent strategy_event = 6; } int64 timestamp = 7; } ``` **TLI Command**: `tli agent stream [--types ]` --- ##### 16. GetAgentPerformance Get agent performance metrics. **Method**: `TradingAgentService.GetAgentPerformance` **Request**: ```protobuf message GetAgentPerformanceRequest { optional int64 start_time = 1; // Performance window start (nanoseconds) optional int64 end_time = 2; // Performance window end (nanoseconds) bool include_strategy_breakdown = 3; // Include per-strategy performance } ``` **Response**: ```protobuf message GetAgentPerformanceResponse { AgentPerformanceMetrics metrics = 1; repeated StrategyPerformance strategy_performance = 2; int64 timestamp = 3; } ``` **TLI Command**: `tli agent performance [--start