- Add AllocatePortfolioArgs struct with validation
- Support 5 allocation strategies (equal-weight, risk-parity, ml-optimized, mean-variance, kelly)
- Implement constraint validation (0 < min < max < 1.0, positive capital)
- Real gRPC integration with Trading Agent Service via API Gateway
- Formatted table output with portfolio allocations and risk metrics
- JWT authentication support via Bearer token in gRPC metadata
- 15 comprehensive TDD integration tests (all passing)
- Case-insensitive strategy parsing
Test Results: cargo test -p tli --test agent_commands_test
✅ 15 passed, 0 failed
Files:
- tli/src/commands/agent.rs (NEW - 466 lines)
- tli/src/commands/mod.rs (export AgentArgs)
- tli/src/main.rs (integrate agent command)
- tli/tests/agent_commands_test.rs (NEW - 15 tests)
- tli/proto/trading_agent.proto (NEW)
Co-authored-by: Wave 12.3.3 TDD Implementation
Common Crate
Overview
The common crate provides a foundational set of shared types and utilities essential for building high-frequency trading applications within the Foxhunt ecosystem. It encapsulates core data structures, error handling patterns, and common helpers used across various components.
Features
- Market Data & Order Types: Defines standardized structs for market data (e.g.,
Tick,OrderBook) and various order types (e.g.,LimitOrder,MarketOrder). - High-Precision Time Utilities: Offers utilities for working with nanosecond-resolution timestamps and duration calculations critical for HFT.
- Robust Error Handling: Implements a custom
FoxhuntErrorenum andResulttype for consistent and traceable error management across the system. - Data Validation Helpers: Provides functions for validating common HFT parameters such as prices, quantities, and instrument IDs.
- Serialization/Deserialization: Includes helpers and derive macros for efficient data serialization (e.g., using
serde) for inter-process communication or persistence. - Instrument & Asset Definitions: Standardized types for defining trading instruments, assets, and exchanges.
Usage
use common::types::{Order, OrderSide, Price, Quantity, InstrumentId};
use common::errors::FoxhuntError;
fn create_limit_order(instrument: InstrumentId, price: Price, quantity: Quantity) -> Result<Order, FoxhuntError> {
if price.value() <= 0.0 || quantity.value() <= 0.0 {
return Err(FoxhuntError::ValidationError("Price and quantity must be positive".to_string()));
}
Ok(Order::new_limit(instrument, OrderSide::Buy, price, quantity))
}
let instrument = InstrumentId::new("BTCUSD".to_string());
let order = create_limit_order(instrument, Price::new(60000.0), Quantity::new(0.5));
println!("{:?}", order);
Testing
cargo test --package common
Documentation
Comprehensive API documentation is available at docs.rs/common.