Files
foxhunt/testing/e2e/src/proto/trading.rs
jgrusewski 5fe3608d92 fix(fxt,infra): production hardening — OTLP telemetry, TUI fixes, K8s infra
- Remove opentelemetry-otlp internal-logs feature (OTLP feedback loop)
- Switch trace sampling from AlwaysOn to 10% ratio-based
- Add RUST_LOG filtering (opentelemetry/h2/tonic/hyper=warn) to all 8 services
- Wire per-service latency measurement via health check → proto metadata → TUI
- Replace Vec::remove(0) with VecDeque ring buffers (O(1) vs O(n))
- Add Arc<AtomicBool> connected_sent for first-connected detection across 12 streams
- Add MAX_RECONNECT_ATTEMPTS (10) uniformly to all stream spawners
- Change kill switch/circuit breaker fields to Option types with N/A display
- Wire data_cache to real download status stream, remove dead cluster_events
- Remove ServiceData::new() hardcoded stubs, add honest placeholders
- Fix nanos_to_hms zero/negative guard, total_records semantic fix
- Fix RwLock held across yield in broker_gateway stream_account_state
- Add break after yield Err in broker/trading stream generators
- Fix connected_at advancing per tick in stream_session_status
- Tempo: replace emptyDir with 10Gi PVC, bump memory to 512Mi/2Gi
- Remove Prometheus gitlab-annotated-pods duplicate scrape job
- Wire 6 new gRPC streaming adapters (risk, trading, ml, data-acquisition)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 10:39:56 +01:00

1536 lines
58 KiB
Rust

// This file is @generated by prost-build.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StreamPortfolioSummaryRequest {
/// Account ID for portfolio summary
#[prost(string, tag = "1")]
pub account_id: ::prost::alloc::string::String,
/// 0 = server default (3s)
#[prost(uint32, tag = "2")]
pub interval_seconds: u32,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StreamOrderBookRequest {
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
#[prost(int32, tag = "2")]
pub depth: i32,
/// 0 = server default (1s)
#[prost(uint32, tag = "3")]
pub interval_seconds: u32,
}
/// Request to submit a new trading order
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SubmitOrderRequest {
/// Trading symbol (e.g., "AAPL", "BTC-USD")
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Buy or sell direction
#[prost(enumeration = "OrderSide", tag = "2")]
pub side: i32,
/// Number of shares/units to trade
#[prost(double, tag = "3")]
pub quantity: f64,
/// Market, limit, stop, or stop-limit
#[prost(enumeration = "OrderType", tag = "4")]
pub order_type: i32,
/// Limit price (required for limit orders)
#[prost(double, optional, tag = "5")]
pub price: ::core::option::Option<f64>,
/// Stop price (required for stop orders)
#[prost(double, optional, tag = "6")]
pub stop_price: ::core::option::Option<f64>,
/// Trading account identifier
#[prost(string, tag = "7")]
pub account_id: ::prost::alloc::string::String,
/// Additional order metadata (strategy, tags, etc.)
#[prost(map = "string, string", tag = "8")]
pub metadata: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
/// Response after submitting an order
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SubmitOrderResponse {
/// Unique order identifier assigned by system
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
/// Current order status (pending, submitted, etc.)
#[prost(enumeration = "OrderStatus", tag = "2")]
pub status: i32,
/// Status message or error description
#[prost(string, tag = "3")]
pub message: ::prost::alloc::string::String,
/// Order submission timestamp (nanoseconds)
#[prost(int64, tag = "4")]
pub timestamp: i64,
}
/// Request to cancel an existing order
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CancelOrderRequest {
/// Order ID to cancel
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
/// Account ID for verification
#[prost(string, tag = "2")]
pub account_id: ::prost::alloc::string::String,
}
/// Response after attempting to cancel an order
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CancelOrderResponse {
/// True if cancellation was successful
#[prost(bool, tag = "1")]
pub success: bool,
/// Success confirmation or error message
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
/// Cancellation timestamp (nanoseconds)
#[prost(int64, tag = "3")]
pub timestamp: i64,
}
/// Request to get current status of an order
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetOrderStatusRequest {
/// Order ID to query
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
}
/// Response containing order status information
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetOrderStatusResponse {
/// Complete order details with current status
#[prost(message, optional, tag = "1")]
pub order: ::core::option::Option<Order>,
}
/// Request to stream real-time order events
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StreamOrdersRequest {
/// Filter by account (all accounts if not specified)
#[prost(string, optional, tag = "1")]
pub account_id: ::core::option::Option<::prost::alloc::string::String>,
/// Filter by symbol (all symbols if not specified)
#[prost(string, optional, tag = "2")]
pub symbol: ::core::option::Option<::prost::alloc::string::String>,
}
/// Request to get current positions
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetPositionsRequest {
/// Filter by account (all accounts if not specified)
#[prost(string, optional, tag = "1")]
pub account_id: ::core::option::Option<::prost::alloc::string::String>,
/// Filter by symbol (all symbols if not specified)
#[prost(string, optional, tag = "2")]
pub symbol: ::core::option::Option<::prost::alloc::string::String>,
}
/// Response containing position information
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetPositionsResponse {
/// List of current positions
#[prost(message, repeated, tag = "1")]
pub positions: ::prost::alloc::vec::Vec<Position>,
}
/// Request to stream real-time position updates
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StreamPositionsRequest {
/// Filter by account (all accounts if not specified)
#[prost(string, optional, tag = "1")]
pub account_id: ::core::option::Option<::prost::alloc::string::String>,
}
/// Request for portfolio summary
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetPortfolioSummaryRequest {
/// Account ID for portfolio summary
#[prost(string, tag = "1")]
pub account_id: ::prost::alloc::string::String,
}
/// Response containing comprehensive portfolio information
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetPortfolioSummaryResponse {
/// Total portfolio value in USD
#[prost(double, tag = "1")]
pub total_value: f64,
/// Unrealized profit/loss
#[prost(double, tag = "2")]
pub unrealized_pnl: f64,
/// Realized profit/loss for the day
#[prost(double, tag = "3")]
pub realized_pnl: f64,
/// Total P&L for the current trading day
#[prost(double, tag = "4")]
pub day_pnl: f64,
/// Available buying power
#[prost(double, tag = "5")]
pub buying_power: f64,
/// Amount of margin currently used
#[prost(double, tag = "6")]
pub margin_used: f64,
/// Detailed position information
#[prost(message, repeated, tag = "7")]
pub positions: ::prost::alloc::vec::Vec<Position>,
}
/// Request to stream real-time market data
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StreamMarketDataRequest {
/// List of symbols to subscribe to
#[prost(string, repeated, tag = "1")]
pub symbols: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Types of data to stream (trades, quotes, order book)
#[prost(enumeration = "MarketDataType", repeated, tag = "2")]
pub data_types: ::prost::alloc::vec::Vec<i32>,
}
/// Request for order book snapshot
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetOrderBookRequest {
/// Symbol to get order book for
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Number of price levels (default: full book)
#[prost(int32, optional, tag = "2")]
pub depth: ::core::option::Option<i32>,
}
/// Response containing order book data
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetOrderBookResponse {
/// Current order book snapshot
#[prost(message, optional, tag = "1")]
pub order_book: ::core::option::Option<OrderBook>,
}
/// Request to stream real-time executions
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StreamExecutionsRequest {
/// Filter by account (all accounts if not specified)
#[prost(string, optional, tag = "1")]
pub account_id: ::core::option::Option<::prost::alloc::string::String>,
/// Filter by symbol (all symbols if not specified)
#[prost(string, optional, tag = "2")]
pub symbol: ::core::option::Option<::prost::alloc::string::String>,
}
/// Request for historical execution data
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetExecutionHistoryRequest {
/// Filter by account (all accounts if not specified)
#[prost(string, optional, tag = "1")]
pub account_id: ::core::option::Option<::prost::alloc::string::String>,
/// Filter by symbol (all symbols if not specified)
#[prost(string, optional, tag = "2")]
pub symbol: ::core::option::Option<::prost::alloc::string::String>,
/// Start time for query (nanoseconds)
#[prost(int64, optional, tag = "3")]
pub start_time: ::core::option::Option<i64>,
/// End time for query (nanoseconds)
#[prost(int64, optional, tag = "4")]
pub end_time: ::core::option::Option<i64>,
/// Maximum number of executions to return
#[prost(int32, optional, tag = "5")]
pub limit: ::core::option::Option<i32>,
}
/// Response containing execution history
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetExecutionHistoryResponse {
/// List of historical executions
#[prost(message, repeated, tag = "1")]
pub executions: ::prost::alloc::vec::Vec<Execution>,
}
/// Request to submit ML-generated order
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MlOrderRequest {
/// Trading symbol (e.g., "ES.FUT")
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Trading account identifier
#[prost(string, tag = "2")]
pub account_id: ::prost::alloc::string::String,
/// Use ensemble voting or specific model
#[prost(bool, tag = "3")]
pub use_ensemble: bool,
/// Specific model name if not using ensemble
#[prost(string, optional, tag = "4")]
pub model_name: ::core::option::Option<::prost::alloc::string::String>,
/// Feature vector for ML prediction (26 features: OHLCV + technicals)
#[prost(double, repeated, tag = "5")]
pub features: ::prost::alloc::vec::Vec<f64>,
}
/// Response after submitting ML order
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MlOrderResponse {
/// Order ID if executed
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
/// Prediction ID from ensemble_predictions table
#[prost(string, tag = "2")]
pub prediction_id: ::prost::alloc::string::String,
/// Action taken: BUY, SELL, HOLD
#[prost(string, tag = "3")]
pub action: ::prost::alloc::string::String,
/// Prediction confidence (0.0-1.0)
#[prost(double, tag = "4")]
pub confidence: f64,
/// Status message
#[prost(string, tag = "5")]
pub message: ::prost::alloc::string::String,
/// True if order was executed
#[prost(bool, tag = "6")]
pub executed: bool,
}
/// Request to get ML prediction history
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct MlPredictionsRequest {
/// Trading symbol to filter by
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Filter by specific model
#[prost(string, optional, tag = "2")]
pub model_name: ::core::option::Option<::prost::alloc::string::String>,
/// Maximum predictions to return (default: 100)
#[prost(int32, tag = "3")]
pub limit: i32,
/// Start time filter (nanoseconds)
#[prost(int64, optional, tag = "4")]
pub start_time: ::core::option::Option<i64>,
/// End time filter (nanoseconds)
#[prost(int64, optional, tag = "5")]
pub end_time: ::core::option::Option<i64>,
}
/// Response containing ML prediction history
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MlPredictionsResponse {
/// List of predictions with outcomes
#[prost(message, repeated, tag = "1")]
pub predictions: ::prost::alloc::vec::Vec<MlPrediction>,
}
/// Single ML prediction with outcome
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MlPrediction {
/// Prediction ID (UUID)
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
/// Trading symbol
#[prost(string, tag = "2")]
pub symbol: ::prost::alloc::string::String,
/// Predicted action: BUY, SELL, HOLD
#[prost(string, tag = "3")]
pub ensemble_action: ::prost::alloc::string::String,
/// Signal strength (-1.0 to 1.0)
#[prost(double, tag = "4")]
pub ensemble_signal: f64,
/// Confidence level (0.0-1.0)
#[prost(double, tag = "5")]
pub ensemble_confidence: f64,
/// Prediction timestamp (nanoseconds)
#[prost(int64, tag = "6")]
pub timestamp: i64,
/// Order ID if executed
#[prost(string, optional, tag = "7")]
pub order_id: ::core::option::Option<::prost::alloc::string::String>,
/// Actual P&L if order filled
#[prost(double, optional, tag = "8")]
pub actual_pnl: ::core::option::Option<f64>,
/// Individual model predictions
#[prost(message, repeated, tag = "9")]
pub model_predictions: ::prost::alloc::vec::Vec<ModelPrediction>,
}
/// Individual model prediction within ensemble
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModelPrediction {
/// Model name (DQN, MAMBA2, PPO, TFT)
#[prost(string, tag = "1")]
pub model_name: ::prost::alloc::string::String,
/// Model signal strength
#[prost(double, tag = "2")]
pub signal: f64,
/// Model confidence
#[prost(double, tag = "3")]
pub confidence: f64,
}
/// Request to get ML model performance metrics
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct MlPerformanceRequest {
/// Filter by specific model (or all if not specified)
#[prost(string, optional, tag = "1")]
pub model_name: ::core::option::Option<::prost::alloc::string::String>,
/// Start time for metrics (nanoseconds)
#[prost(int64, optional, tag = "2")]
pub start_time: ::core::option::Option<i64>,
/// End time for metrics (nanoseconds)
#[prost(int64, optional, tag = "3")]
pub end_time: ::core::option::Option<i64>,
}
/// Response containing ML model performance
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MlPerformanceResponse {
/// Performance metrics per model
#[prost(message, repeated, tag = "1")]
pub models: ::prost::alloc::vec::Vec<ModelPerformance>,
}
/// Performance metrics for a single model
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModelPerformance {
/// Model name
#[prost(string, tag = "1")]
pub model_name: ::prost::alloc::string::String,
/// Total predictions made
#[prost(int64, tag = "2")]
pub total_predictions: i64,
/// Correct predictions (profitable)
#[prost(int64, tag = "3")]
pub correct_predictions: i64,
/// Accuracy rate (0.0-1.0)
#[prost(double, tag = "4")]
pub accuracy: f64,
/// Risk-adjusted return
#[prost(double, tag = "5")]
pub sharpe_ratio: f64,
/// Average P&L per prediction
#[prost(double, tag = "6")]
pub avg_pnl: f64,
}
/// Request to get current regime state
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetRegimeStateRequest {
/// Trading symbol to query
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
}
/// Response containing current regime state
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRegimeStateResponse {
/// Trading symbol
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Current regime: TRENDING, RANGING, VOLATILE, CRISIS
#[prost(string, tag = "2")]
pub current_regime: ::prost::alloc::string::String,
/// Regime confidence (0.0-1.0)
#[prost(double, tag = "3")]
pub confidence: f64,
/// CUSUM S+ statistic
#[prost(double, tag = "4")]
pub cusum_s_plus: f64,
/// CUSUM S- statistic
#[prost(double, tag = "5")]
pub cusum_s_minus: f64,
/// Average Directional Index
#[prost(double, tag = "6")]
pub adx: f64,
/// Regime stability score (0.0-1.0)
#[prost(double, tag = "7")]
pub stability: f64,
/// Transition entropy (0.0-1.0)
#[prost(double, tag = "8")]
pub entropy: f64,
/// Last update timestamp (nanoseconds)
#[prost(int64, tag = "9")]
pub updated_at: i64,
}
/// Request to get regime transition history
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetRegimeTransitionsRequest {
/// Trading symbol to query
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Maximum transitions to return (default: 100)
#[prost(int32, tag = "2")]
pub limit: i32,
}
/// Response containing regime transition history
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRegimeTransitionsResponse {
/// List of regime transitions
#[prost(message, repeated, tag = "1")]
pub transitions: ::prost::alloc::vec::Vec<RegimeTransition>,
}
/// Single regime transition record
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegimeTransition {
/// Previous regime
#[prost(string, tag = "1")]
pub from_regime: ::prost::alloc::string::String,
/// New regime
#[prost(string, tag = "2")]
pub to_regime: ::prost::alloc::string::String,
/// Duration in previous regime (bars)
#[prost(int32, tag = "3")]
pub duration_bars: i32,
/// Transition probability from matrix
#[prost(double, tag = "4")]
pub transition_probability: f64,
/// Transition timestamp (nanoseconds)
#[prost(int64, tag = "5")]
pub timestamp: i64,
}
/// Complete order information with all lifecycle details
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Order {
/// Unique order identifier
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
/// Trading symbol (e.g., "AAPL", "BTC-USD")
#[prost(string, tag = "2")]
pub symbol: ::prost::alloc::string::String,
/// Buy or sell direction
#[prost(enumeration = "OrderSide", tag = "3")]
pub side: i32,
/// Total quantity ordered
#[prost(double, tag = "4")]
pub quantity: f64,
/// Quantity already filled
#[prost(double, tag = "5")]
pub filled_quantity: f64,
/// Market, limit, stop, or stop-limit
#[prost(enumeration = "OrderType", tag = "6")]
pub order_type: i32,
/// Limit price (for limit orders)
#[prost(double, optional, tag = "7")]
pub price: ::core::option::Option<f64>,
/// Stop price (for stop orders)
#[prost(double, optional, tag = "8")]
pub stop_price: ::core::option::Option<f64>,
/// Current order status
#[prost(enumeration = "OrderStatus", tag = "9")]
pub status: i32,
/// Order creation timestamp (nanoseconds)
#[prost(int64, tag = "10")]
pub created_at: i64,
/// Last update timestamp (nanoseconds)
#[prost(int64, optional, tag = "11")]
pub updated_at: ::core::option::Option<i64>,
/// Associated trading account
#[prost(string, tag = "12")]
pub account_id: ::prost::alloc::string::String,
/// Additional order metadata
#[prost(map = "string, string", tag = "13")]
pub metadata: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
/// Current position information for a symbol
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Position {
/// Trading symbol
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Current position size (positive for long, negative for short)
#[prost(double, tag = "2")]
pub quantity: f64,
/// Average cost basis per share
#[prost(double, tag = "3")]
pub average_price: f64,
/// Current market value of position
#[prost(double, tag = "4")]
pub market_value: f64,
/// Unrealized profit/loss
#[prost(double, tag = "5")]
pub unrealized_pnl: f64,
/// Realized profit/loss for the day
#[prost(double, tag = "6")]
pub realized_pnl: f64,
/// Associated trading account
#[prost(string, tag = "7")]
pub account_id: ::prost::alloc::string::String,
/// Last update timestamp (nanoseconds)
#[prost(int64, tag = "8")]
pub updated_at: i64,
}
/// Trade execution details
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Execution {
/// Unique execution identifier
#[prost(string, tag = "1")]
pub execution_id: ::prost::alloc::string::String,
/// Associated order ID
#[prost(string, tag = "2")]
pub order_id: ::prost::alloc::string::String,
/// Trading symbol
#[prost(string, tag = "3")]
pub symbol: ::prost::alloc::string::String,
/// Buy or sell direction
#[prost(enumeration = "OrderSide", tag = "4")]
pub side: i32,
/// Quantity executed
#[prost(double, tag = "5")]
pub quantity: f64,
/// Execution price
#[prost(double, tag = "6")]
pub price: f64,
/// Execution timestamp (nanoseconds)
#[prost(int64, tag = "7")]
pub timestamp: i64,
/// Associated trading account
#[prost(string, tag = "8")]
pub account_id: ::prost::alloc::string::String,
/// Additional execution metadata
#[prost(map = "string, string", tag = "9")]
pub metadata: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
/// Order book snapshot for a symbol
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderBook {
/// Trading symbol
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Bid levels (buyers) sorted by price descending
#[prost(message, repeated, tag = "2")]
pub bids: ::prost::alloc::vec::Vec<OrderBookLevel>,
/// Ask levels (sellers) sorted by price ascending
#[prost(message, repeated, tag = "3")]
pub asks: ::prost::alloc::vec::Vec<OrderBookLevel>,
/// Order book timestamp (nanoseconds)
#[prost(int64, tag = "4")]
pub timestamp: i64,
}
/// Single price level in the order book
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct OrderBookLevel {
/// Price level
#[prost(double, tag = "1")]
pub price: f64,
/// Total quantity at this price level
#[prost(double, tag = "2")]
pub quantity: f64,
/// Number of orders at this price level
#[prost(int32, tag = "3")]
pub order_count: i32,
}
/// Real-time order event notification
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OrderEvent {
/// Order identifier
#[prost(string, tag = "1")]
pub order_id: ::prost::alloc::string::String,
/// Complete order details
#[prost(message, optional, tag = "2")]
pub order: ::core::option::Option<Order>,
/// Type of event (created, updated, filled, etc.)
#[prost(enumeration = "OrderEventType", tag = "3")]
pub event_type: i32,
/// Event timestamp (nanoseconds)
#[prost(int64, tag = "4")]
pub timestamp: i64,
/// Event message or additional details
#[prost(string, tag = "5")]
pub message: ::prost::alloc::string::String,
}
/// Real-time position change notification
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PositionEvent {
/// Trading symbol
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Updated position details
#[prost(message, optional, tag = "2")]
pub position: ::core::option::Option<Position>,
/// Type of event (opened, updated, closed)
#[prost(enumeration = "PositionEventType", tag = "3")]
pub event_type: i32,
/// Event timestamp (nanoseconds)
#[prost(int64, tag = "4")]
pub timestamp: i64,
/// Position quantity (quick access)
#[prost(double, tag = "5")]
pub quantity: f64,
/// Average entry price (quick access)
#[prost(double, tag = "6")]
pub average_price: f64,
/// Unrealized P&L (quick access)
#[prost(double, tag = "7")]
pub unrealized_pnl: f64,
}
/// Real-time execution notification
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExecutionEvent {
/// Execution identifier
#[prost(string, tag = "1")]
pub execution_id: ::prost::alloc::string::String,
/// Execution details
#[prost(message, optional, tag = "2")]
pub execution: ::core::option::Option<Execution>,
/// Event timestamp (nanoseconds)
#[prost(int64, tag = "3")]
pub timestamp: i64,
/// Associated order ID (quick access)
#[prost(string, tag = "4")]
pub order_id: ::prost::alloc::string::String,
/// Trading symbol (quick access)
#[prost(string, tag = "5")]
pub symbol: ::prost::alloc::string::String,
/// Executed quantity (quick access)
#[prost(double, tag = "6")]
pub quantity: f64,
/// Execution price (quick access)
#[prost(double, tag = "7")]
pub price: f64,
}
/// Real-time market data update
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MarketDataEvent {
/// Trading symbol
#[prost(string, tag = "1")]
pub symbol: ::prost::alloc::string::String,
/// Type of market data
#[prost(enumeration = "MarketDataType", tag = "2")]
pub data_type: i32,
/// Market data timestamp (nanoseconds)
#[prost(int64, tag = "6")]
pub timestamp: i64,
#[prost(oneof = "market_data_event::Data", tags = "3, 4, 5")]
pub data: ::core::option::Option<market_data_event::Data>,
}
/// Nested message and enum types in `MarketDataEvent`.
pub mod market_data_event {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Data {
/// Trade data (when data_type = TRADE)
#[prost(message, tag = "3")]
Trade(super::Trade),
/// Quote data (when data_type = QUOTE)
#[prost(message, tag = "4")]
Quote(super::Quote),
/// Order book data (when data_type = ORDER_BOOK)
#[prost(message, tag = "5")]
OrderBook(super::OrderBook),
}
}
/// Market trade information
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Trade {
/// Trade price
#[prost(double, tag = "1")]
pub price: f64,
/// Trade volume
#[prost(double, tag = "2")]
pub volume: f64,
/// Trade timestamp (nanoseconds)
#[prost(int64, tag = "3")]
pub timestamp: i64,
}
/// Market quote (bid/ask) information
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Quote {
/// Best bid price
#[prost(double, tag = "1")]
pub bid_price: f64,
/// Size at best bid
#[prost(double, tag = "2")]
pub bid_size: f64,
/// Best ask price
#[prost(double, tag = "3")]
pub ask_price: f64,
/// Size at best ask
#[prost(double, tag = "4")]
pub ask_size: f64,
/// Quote timestamp (nanoseconds)
#[prost(int64, tag = "5")]
pub timestamp: i64,
}
/// Order direction (buy or sell)
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OrderSide {
/// Default/unknown side
Unspecified = 0,
/// Buy order (long position)
Buy = 1,
/// Sell order (short position)
Sell = 2,
}
impl OrderSide {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "ORDER_SIDE_UNSPECIFIED",
Self::Buy => "ORDER_SIDE_BUY",
Self::Sell => "ORDER_SIDE_SELL",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ORDER_SIDE_UNSPECIFIED" => Some(Self::Unspecified),
"ORDER_SIDE_BUY" => Some(Self::Buy),
"ORDER_SIDE_SELL" => Some(Self::Sell),
_ => None,
}
}
}
/// Order type determining execution behavior
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OrderType {
/// Default/unknown type
Unspecified = 0,
/// Execute immediately at market price
Market = 1,
/// Execute only at specified price or better
Limit = 2,
/// Market order triggered at stop price
Stop = 3,
/// Limit order triggered at stop price
StopLimit = 4,
}
impl OrderType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "ORDER_TYPE_UNSPECIFIED",
Self::Market => "ORDER_TYPE_MARKET",
Self::Limit => "ORDER_TYPE_LIMIT",
Self::Stop => "ORDER_TYPE_STOP",
Self::StopLimit => "ORDER_TYPE_STOP_LIMIT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ORDER_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"ORDER_TYPE_MARKET" => Some(Self::Market),
"ORDER_TYPE_LIMIT" => Some(Self::Limit),
"ORDER_TYPE_STOP" => Some(Self::Stop),
"ORDER_TYPE_STOP_LIMIT" => Some(Self::StopLimit),
_ => None,
}
}
}
/// Current status of an order in its lifecycle
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OrderStatus {
/// Default/unknown status
Unspecified = 0,
/// Order created but not yet submitted
Pending = 1,
/// Order submitted to exchange
Submitted = 2,
/// Order partially executed
PartiallyFilled = 3,
/// Order completely executed
Filled = 4,
/// Order cancelled by user or system
Cancelled = 5,
/// Order rejected by exchange or risk system
Rejected = 6,
}
impl OrderStatus {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "ORDER_STATUS_UNSPECIFIED",
Self::Pending => "ORDER_STATUS_PENDING",
Self::Submitted => "ORDER_STATUS_SUBMITTED",
Self::PartiallyFilled => "ORDER_STATUS_PARTIALLY_FILLED",
Self::Filled => "ORDER_STATUS_FILLED",
Self::Cancelled => "ORDER_STATUS_CANCELLED",
Self::Rejected => "ORDER_STATUS_REJECTED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ORDER_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
"ORDER_STATUS_PENDING" => Some(Self::Pending),
"ORDER_STATUS_SUBMITTED" => Some(Self::Submitted),
"ORDER_STATUS_PARTIALLY_FILLED" => Some(Self::PartiallyFilled),
"ORDER_STATUS_FILLED" => Some(Self::Filled),
"ORDER_STATUS_CANCELLED" => Some(Self::Cancelled),
"ORDER_STATUS_REJECTED" => Some(Self::Rejected),
_ => None,
}
}
}
/// Type of order event notification
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OrderEventType {
/// Default/unknown event
Unspecified = 0,
/// Order was created
Created = 1,
/// Order details were updated
Updated = 2,
/// Order was executed (full or partial)
Filled = 3,
/// Order was cancelled
Cancelled = 4,
/// Order was partially filled
PartiallyFilled = 5,
/// Order was rejected
Rejected = 6,
}
impl OrderEventType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "ORDER_EVENT_TYPE_UNSPECIFIED",
Self::Created => "ORDER_EVENT_TYPE_CREATED",
Self::Updated => "ORDER_EVENT_TYPE_UPDATED",
Self::Filled => "ORDER_EVENT_TYPE_FILLED",
Self::Cancelled => "ORDER_EVENT_TYPE_CANCELLED",
Self::PartiallyFilled => "ORDER_EVENT_TYPE_PARTIALLY_FILLED",
Self::Rejected => "ORDER_EVENT_TYPE_REJECTED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ORDER_EVENT_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"ORDER_EVENT_TYPE_CREATED" => Some(Self::Created),
"ORDER_EVENT_TYPE_UPDATED" => Some(Self::Updated),
"ORDER_EVENT_TYPE_FILLED" => Some(Self::Filled),
"ORDER_EVENT_TYPE_CANCELLED" => Some(Self::Cancelled),
"ORDER_EVENT_TYPE_PARTIALLY_FILLED" => Some(Self::PartiallyFilled),
"ORDER_EVENT_TYPE_REJECTED" => Some(Self::Rejected),
_ => None,
}
}
}
/// Type of position change event
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum PositionEventType {
/// Default/unknown event
Unspecified = 0,
/// New position was opened
Opened = 1,
/// Existing position was modified
Updated = 2,
/// Position was closed
Closed = 3,
}
impl PositionEventType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "POSITION_EVENT_TYPE_UNSPECIFIED",
Self::Opened => "POSITION_EVENT_TYPE_OPENED",
Self::Updated => "POSITION_EVENT_TYPE_UPDATED",
Self::Closed => "POSITION_EVENT_TYPE_CLOSED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"POSITION_EVENT_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"POSITION_EVENT_TYPE_OPENED" => Some(Self::Opened),
"POSITION_EVENT_TYPE_UPDATED" => Some(Self::Updated),
"POSITION_EVENT_TYPE_CLOSED" => Some(Self::Closed),
_ => None,
}
}
}
/// Type of market data being streamed
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MarketDataType {
/// Default/unknown type
Unspecified = 0,
/// Trade/transaction data
Trade = 1,
/// Best bid/ask quotes
Quote = 2,
/// Full order book depth
OrderBook = 3,
}
impl MarketDataType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "MARKET_DATA_TYPE_UNSPECIFIED",
Self::Trade => "MARKET_DATA_TYPE_TRADE",
Self::Quote => "MARKET_DATA_TYPE_QUOTE",
Self::OrderBook => "MARKET_DATA_TYPE_ORDER_BOOK",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"MARKET_DATA_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"MARKET_DATA_TYPE_TRADE" => Some(Self::Trade),
"MARKET_DATA_TYPE_QUOTE" => Some(Self::Quote),
"MARKET_DATA_TYPE_ORDER_BOOK" => Some(Self::OrderBook),
_ => None,
}
}
}
/// Generated client implementations.
#[allow(unused_qualifications)]
pub mod trading_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// Trading Service provides comprehensive real-time trading operations for high-frequency trading.
/// This service handles order management, position tracking, market data streaming, and execution monitoring.
/// All operations are designed for ultra-low latency with microsecond precision timing.
#[derive(Debug, Clone)]
pub struct TradingServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl TradingServiceClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> TradingServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> TradingServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
TradingServiceClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// Order Management Operations
/// Submit a new trading order with validation and risk checks
pub async fn submit_order(
&mut self,
request: impl tonic::IntoRequest<super::SubmitOrderRequest>,
) -> std::result::Result<
tonic::Response<super::SubmitOrderResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/SubmitOrder",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "SubmitOrder"));
self.inner.unary(req, path, codec).await
}
/// Cancel an existing order by order ID
pub async fn cancel_order(
&mut self,
request: impl tonic::IntoRequest<super::CancelOrderRequest>,
) -> std::result::Result<
tonic::Response<super::CancelOrderResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/CancelOrder",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "CancelOrder"));
self.inner.unary(req, path, codec).await
}
/// Get current status of a specific order
pub async fn get_order_status(
&mut self,
request: impl tonic::IntoRequest<super::GetOrderStatusRequest>,
) -> std::result::Result<
tonic::Response<super::GetOrderStatusResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/GetOrderStatus",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "GetOrderStatus"));
self.inner.unary(req, path, codec).await
}
/// Stream real-time order events for monitoring order lifecycle
pub async fn stream_orders(
&mut self,
request: impl tonic::IntoRequest<super::StreamOrdersRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::OrderEvent>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/StreamOrders",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "StreamOrders"));
self.inner.server_streaming(req, path, codec).await
}
/// Position Management Operations
/// Get current positions for account and/or symbol
pub async fn get_positions(
&mut self,
request: impl tonic::IntoRequest<super::GetPositionsRequest>,
) -> std::result::Result<
tonic::Response<super::GetPositionsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/GetPositions",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "GetPositions"));
self.inner.unary(req, path, codec).await
}
/// Stream real-time position updates as trades execute
pub async fn stream_positions(
&mut self,
request: impl tonic::IntoRequest<super::StreamPositionsRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::PositionEvent>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/StreamPositions",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "StreamPositions"));
self.inner.server_streaming(req, path, codec).await
}
/// Get comprehensive portfolio summary with P&L and risk metrics
pub async fn get_portfolio_summary(
&mut self,
request: impl tonic::IntoRequest<super::GetPortfolioSummaryRequest>,
) -> std::result::Result<
tonic::Response<super::GetPortfolioSummaryResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/GetPortfolioSummary",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("trading.TradingService", "GetPortfolioSummary"),
);
self.inner.unary(req, path, codec).await
}
/// Market Data Operations
/// Stream real-time market data (trades, quotes, order book)
pub async fn stream_market_data(
&mut self,
request: impl tonic::IntoRequest<super::StreamMarketDataRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::MarketDataEvent>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/StreamMarketData",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "StreamMarketData"));
self.inner.server_streaming(req, path, codec).await
}
/// Get current order book snapshot for a symbol
pub async fn get_order_book(
&mut self,
request: impl tonic::IntoRequest<super::GetOrderBookRequest>,
) -> std::result::Result<
tonic::Response<super::GetOrderBookResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/GetOrderBook",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "GetOrderBook"));
self.inner.unary(req, path, codec).await
}
/// Execution Operations
/// Stream real-time trade executions as they occur
pub async fn stream_executions(
&mut self,
request: impl tonic::IntoRequest<super::StreamExecutionsRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::ExecutionEvent>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/StreamExecutions",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "StreamExecutions"));
self.inner.server_streaming(req, path, codec).await
}
/// Get historical execution data with filtering options
pub async fn get_execution_history(
&mut self,
request: impl tonic::IntoRequest<super::GetExecutionHistoryRequest>,
) -> std::result::Result<
tonic::Response<super::GetExecutionHistoryResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/GetExecutionHistory",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("trading.TradingService", "GetExecutionHistory"),
);
self.inner.unary(req, path, codec).await
}
/// ML-specific Trading Operations
/// Submit ML-generated trading order with ensemble predictions
pub async fn submit_ml_order(
&mut self,
request: impl tonic::IntoRequest<super::MlOrderRequest>,
) -> std::result::Result<
tonic::Response<super::MlOrderResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/SubmitMLOrder",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "SubmitMLOrder"));
self.inner.unary(req, path, codec).await
}
/// Get ML prediction history with outcomes
pub async fn get_ml_predictions(
&mut self,
request: impl tonic::IntoRequest<super::MlPredictionsRequest>,
) -> std::result::Result<
tonic::Response<super::MlPredictionsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/GetMLPredictions",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "GetMLPredictions"));
self.inner.unary(req, path, codec).await
}
/// Get ML model performance metrics
pub async fn get_ml_performance(
&mut self,
request: impl tonic::IntoRequest<super::MlPerformanceRequest>,
) -> std::result::Result<
tonic::Response<super::MlPerformanceResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/GetMLPerformance",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "GetMLPerformance"));
self.inner.unary(req, path, codec).await
}
/// Wave D: Regime Detection Operations
/// Get current regime state for a symbol
pub async fn get_regime_state(
&mut self,
request: impl tonic::IntoRequest<super::GetRegimeStateRequest>,
) -> std::result::Result<
tonic::Response<super::GetRegimeStateResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/GetRegimeState",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "GetRegimeState"));
self.inner.unary(req, path, codec).await
}
/// Get regime transition history for a symbol
pub async fn get_regime_transitions(
&mut self,
request: impl tonic::IntoRequest<super::GetRegimeTransitionsRequest>,
) -> std::result::Result<
tonic::Response<super::GetRegimeTransitionsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/GetRegimeTransitions",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("trading.TradingService", "GetRegimeTransitions"),
);
self.inner.unary(req, path, codec).await
}
/// Server-streaming: polls GetPortfolioSummary at gateway level
pub async fn stream_portfolio_summary(
&mut self,
request: impl tonic::IntoRequest<super::StreamPortfolioSummaryRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::GetPortfolioSummaryResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/StreamPortfolioSummary",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new("trading.TradingService", "StreamPortfolioSummary"),
);
self.inner.server_streaming(req, path, codec).await
}
/// Server-streaming: polls GetOrderBook at gateway level
pub async fn stream_order_book(
&mut self,
request: impl tonic::IntoRequest<super::StreamOrderBookRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::GetOrderBookResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/trading.TradingService/StreamOrderBook",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("trading.TradingService", "StreamOrderBook"));
self.inner.server_streaming(req, path, codec).await
}
}
}