using NT8.Core.Common.Models; using System; using System.Collections.Generic; // ARCHIVED: This namespace (NT8.Core.Orders) is superseded by NT8.Core.OMS. // NT8.Core.OMS is the canonical order management implementation used by NT8StrategyBase. // These files are retained for reference only and are not referenced by any active code. // Do not add new code here. Do not remove these files until a full audit confirms zero references. namespace NT8.Core.Orders { #region Core Order Models /// /// Order request parameters /// public class OrderRequest { /// /// Trading symbol /// public string Symbol { get; set; } /// /// Order side /// public OrderSide Side { get; set; } /// /// Order type /// public OrderType Type { get; set; } /// /// Order quantity /// public int Quantity { get; set; } /// /// Limit price (if applicable) /// public decimal? LimitPrice { get; set; } /// /// Stop price (if applicable) /// public decimal? StopPrice { get; set; } /// /// Time in force /// public TimeInForce TimeInForce { get; set; } /// /// Algorithm to use (TWAP, VWAP, Iceberg, or null for regular order) /// public string Algorithm { get; set; } /// /// Algorithm-specific parameters /// public Dictionary AlgorithmParameters { get; set; } /// /// Constructor for OrderRequest /// public OrderRequest( string symbol, OrderSide side, OrderType type, int quantity, decimal? limitPrice, decimal? stopPrice, TimeInForce timeInForce, string algorithm, Dictionary algorithmParameters) { Symbol = symbol; Side = side; Type = type; Quantity = quantity; LimitPrice = limitPrice; StopPrice = stopPrice; TimeInForce = timeInForce; Algorithm = algorithm; AlgorithmParameters = algorithmParameters ?? new Dictionary(); } } /// /// Order submission result /// public class OrderResult { /// /// Whether the order submission was successful /// public bool Success { get; set; } /// /// Order ID if successful /// public string OrderId { get; set; } /// /// Message describing the result /// public string Message { get; set; } /// /// Order status if successful /// public OrderStatus Status { get; set; } /// /// Constructor for OrderResult /// public OrderResult( bool success, string orderId, string message, OrderStatus status) { Success = success; OrderId = orderId; Message = message; Status = status; } } /// /// Current order status /// public class OrderStatus { /// /// Order ID /// public string OrderId { get; set; } /// /// Trading symbol /// public string Symbol { get; set; } /// /// Order side /// public OrderSide Side { get; set; } /// /// Order type /// public OrderType Type { get; set; } /// /// Order quantity /// public int Quantity { get; set; } /// /// Filled quantity /// public int FilledQuantity { get; set; } /// /// Limit price (if applicable) /// public decimal? LimitPrice { get; set; } /// /// Stop price (if applicable) /// public decimal? StopPrice { get; set; } /// /// Current order state /// public OrderState State { get; set; } /// /// Order creation time /// public DateTime CreatedTime { get; set; } /// /// Order fill time (if filled) /// public DateTime? FilledTime { get; set; } /// /// Order fills /// public List Fills { get; set; } /// /// Constructor for OrderStatus /// public OrderStatus( string orderId, string symbol, OrderSide side, OrderType type, int quantity, int filledQuantity, decimal? limitPrice, decimal? stopPrice, OrderState state, DateTime createdTime, DateTime? filledTime, List fills) { OrderId = orderId; Symbol = symbol; Side = side; Type = type; Quantity = quantity; FilledQuantity = filledQuantity; LimitPrice = limitPrice; StopPrice = stopPrice; State = state; CreatedTime = createdTime; FilledTime = filledTime; Fills = fills ?? new List(); } } /// /// Order modification parameters /// public class OrderModification { /// /// New quantity (if changing) /// public int? NewQuantity { get; set; } /// /// New limit price (if changing) /// public decimal? NewLimitPrice { get; set; } /// /// New stop price (if changing) /// public decimal? NewStopPrice { get; set; } /// /// New time in force (if changing) /// public TimeInForce? NewTimeInForce { get; set; } /// /// Constructor for OrderModification /// public OrderModification( int? newQuantity, decimal? newLimitPrice, decimal? newStopPrice, TimeInForce? newTimeInForce) { NewQuantity = newQuantity; NewLimitPrice = newLimitPrice; NewStopPrice = newStopPrice; NewTimeInForce = newTimeInForce; } } #endregion #region Algorithm Parameters /// /// TWAP algorithm parameters /// public class TwapParameters { /// /// Trading symbol /// public string Symbol { get; set; } /// /// Order side /// public OrderSide Side { get; set; } /// /// Total quantity to trade /// public int TotalQuantity { get; set; } /// /// Total duration for execution /// public TimeSpan Duration { get; set; } /// /// Interval between order slices in seconds /// public int IntervalSeconds { get; set; } /// /// Limit price (if applicable) /// public decimal? LimitPrice { get; set; } /// /// Constructor for TwapParameters /// public TwapParameters( string symbol, OrderSide side, int totalQuantity, TimeSpan duration, int intervalSeconds, decimal? limitPrice) { Symbol = symbol; Side = side; TotalQuantity = totalQuantity; Duration = duration; IntervalSeconds = intervalSeconds; LimitPrice = limitPrice; } } /// /// VWAP algorithm parameters /// public class VwapParameters { /// /// Trading symbol /// public string Symbol { get; set; } /// /// Order side /// public OrderSide Side { get; set; } /// /// Total quantity to trade /// public int TotalQuantity { get; set; } /// /// Start time for execution /// public DateTime StartTime { get; set; } /// /// End time for execution /// public DateTime EndTime { get; set; } /// /// Limit price (if applicable) /// public decimal? LimitPrice { get; set; } /// /// Participation rate (0.0 to 1.0) /// public double ParticipationRate { get; set; } /// /// Constructor for VwapParameters /// public VwapParameters( string symbol, OrderSide side, int totalQuantity, DateTime startTime, DateTime endTime, decimal? limitPrice, double participationRate) { Symbol = symbol; Side = side; TotalQuantity = totalQuantity; StartTime = startTime; EndTime = endTime; LimitPrice = limitPrice; ParticipationRate = participationRate; } } /// /// Iceberg algorithm parameters /// public class IcebergParameters { /// /// Trading symbol /// public string Symbol { get; set; } /// /// Order side /// public OrderSide Side { get; set; } /// /// Total quantity to trade /// public int TotalQuantity { get; set; } /// /// Visible quantity for each slice /// public int VisibleQuantity { get; set; } /// /// Limit price (if applicable) /// public decimal? LimitPrice { get; set; } /// /// Constructor for IcebergParameters /// public IcebergParameters( string symbol, OrderSide side, int totalQuantity, int visibleQuantity, decimal? limitPrice) { Symbol = symbol; Side = side; TotalQuantity = totalQuantity; VisibleQuantity = visibleQuantity; LimitPrice = limitPrice; } } #endregion #region Routing Models /// /// Order routing result /// public class RoutingResult { /// /// Whether routing was successful /// public bool Success { get; set; } /// /// Order ID /// public string OrderId { get; set; } /// /// Selected execution venue /// public ExecutionVenue SelectedVenue { get; set; } /// /// Message describing the result /// public string Message { get; set; } /// /// Routing details /// public Dictionary RoutingDetails { get; set; } /// /// Constructor for RoutingResult /// public RoutingResult( bool success, string orderId, ExecutionVenue selectedVenue, string message, Dictionary routingDetails) { Success = success; OrderId = orderId; SelectedVenue = selectedVenue; Message = message; RoutingDetails = routingDetails ?? new Dictionary(); } } /// /// Execution venue information /// public class ExecutionVenue { /// /// Venue name /// public string Name { get; set; } /// /// Venue description /// public string Description { get; set; } /// /// Whether venue is active /// public bool IsActive { get; set; } /// /// Relative cost factor (1.0 = baseline) /// public double CostFactor { get; set; } /// /// Relative speed factor (1.0 = baseline) /// public double SpeedFactor { get; set; } /// /// Reliability score (0.0 to 1.0) /// public double ReliabilityFactor { get; set; } /// /// Constructor for ExecutionVenue /// public ExecutionVenue( string name, string description, bool isActive, double costFactor, double speedFactor, double reliabilityFactor) { Name = name; Description = description; IsActive = isActive; CostFactor = costFactor; SpeedFactor = speedFactor; ReliabilityFactor = reliabilityFactor; } } /// /// Routing performance metrics /// public class RoutingMetrics { /// /// Performance metrics by venue /// public Dictionary VenuePerformance { get; set; } /// /// Total number of routed orders /// public int TotalRoutedOrders { get; set; } /// /// Average routing time in milliseconds /// public double AverageRoutingTimeMs { get; set; } /// /// Last update timestamp /// public DateTime LastUpdated { get; set; } /// /// Constructor for RoutingMetrics /// public RoutingMetrics( Dictionary venuePerformance, int totalRoutedOrders, double averageRoutingTimeMs, DateTime lastUpdated) { VenuePerformance = venuePerformance ?? new Dictionary(); TotalRoutedOrders = totalRoutedOrders; AverageRoutingTimeMs = averageRoutingTimeMs; LastUpdated = lastUpdated; } } /// /// Metrics for a specific execution venue /// public class VenueMetrics { /// /// Venue name /// public string VenueName { get; set; } /// /// Number of orders routed to this venue /// public int OrdersRouted { get; set; } /// /// Fill rate for this venue /// public double FillRate { get; set; } /// /// Average slippage for this venue /// public double AverageSlippage { get; set; } /// /// Average execution time in milliseconds /// public double AverageExecutionTimeMs { get; set; } /// /// Total value routed through this venue /// public decimal TotalValueRouted { get; set; } /// /// Constructor for VenueMetrics /// public VenueMetrics( string venueName, int ordersRouted, double fillRate, double averageSlippage, double averageExecutionTimeMs, decimal totalValueRouted) { VenueName = venueName; OrdersRouted = ordersRouted; FillRate = fillRate; AverageSlippage = averageSlippage; AverageExecutionTimeMs = averageExecutionTimeMs; TotalValueRouted = totalValueRouted; } } /// /// Routing configuration parameters /// public class RoutingConfig { /// /// Whether smart routing is enabled /// public bool SmartRoutingEnabled { get; set; } /// /// Default venue to use when smart routing is disabled /// public string DefaultVenue { get; set; } /// /// Venue preferences (venue name -> preference weight) /// public Dictionary VenuePreferences { get; set; } /// /// Maximum allowed slippage percentage /// public double MaxSlippagePercent { get; set; } /// /// Maximum time allowed for routing /// public TimeSpan MaxRoutingTime { get; set; } /// /// Whether to route based on cost /// public bool RouteByCost { get; set; } /// /// Whether to route based on speed /// public bool RouteBySpeed { get; set; } /// /// Whether to route based on reliability /// public bool RouteByReliability { get; set; } /// /// Constructor for RoutingConfig /// public RoutingConfig( bool smartRoutingEnabled, string defaultVenue, Dictionary venuePreferences, double maxSlippagePercent, TimeSpan maxRoutingTime, bool routeByCost, bool routeBySpeed, bool routeByReliability) { SmartRoutingEnabled = smartRoutingEnabled; DefaultVenue = defaultVenue; VenuePreferences = venuePreferences ?? new Dictionary(); MaxSlippagePercent = maxSlippagePercent; MaxRoutingTime = maxRoutingTime; RouteByCost = routeByCost; RouteBySpeed = routeBySpeed; RouteByReliability = routeByReliability; } } /// /// Algorithm configuration parameters /// public class AlgorithmParameters { /// /// TWAP settings /// public TwapConfig TwapSettings { get; set; } /// /// VWAP settings /// public VwapConfig VwapSettings { get; set; } /// /// Iceberg settings /// public IcebergConfig IcebergSettings { get; set; } /// /// Constructor for AlgorithmParameters /// public AlgorithmParameters( TwapConfig twapSettings, VwapConfig vwapSettings, IcebergConfig icebergSettings) { TwapSettings = twapSettings; VwapSettings = vwapSettings; IcebergSettings = icebergSettings; } } /// /// TWAP configuration /// public class TwapConfig { /// /// Default duration for TWAP orders /// public TimeSpan DefaultDuration { get; set; } /// /// Default interval between slices in seconds /// public int DefaultIntervalSeconds { get; set; } /// /// Whether TWAP is enabled /// public bool Enabled { get; set; } /// /// Constructor for TwapConfig /// public TwapConfig( TimeSpan defaultDuration, int defaultIntervalSeconds, bool enabled) { DefaultDuration = defaultDuration; DefaultIntervalSeconds = defaultIntervalSeconds; Enabled = enabled; } } /// /// VWAP configuration /// public class VwapConfig { /// /// Default participation rate for VWAP orders /// public double DefaultParticipationRate { get; set; } /// /// Whether VWAP is enabled /// public bool Enabled { get; set; } /// /// Constructor for VwapConfig /// public VwapConfig( double defaultParticipationRate, bool enabled) { DefaultParticipationRate = defaultParticipationRate; Enabled = enabled; } } /// /// Iceberg configuration /// public class IcebergConfig { /// /// Default visible ratio for Iceberg orders /// public double DefaultVisibleRatio { get; set; } /// /// Whether Iceberg is enabled /// public bool Enabled { get; set; } /// /// Constructor for IcebergConfig /// public IcebergConfig( double defaultVisibleRatio, bool enabled) { DefaultVisibleRatio = defaultVisibleRatio; Enabled = enabled; } } #endregion #region Metrics Models /// /// OMS performance metrics /// public class OmsMetrics { /// /// Total number of orders /// public int TotalOrders { get; set; } /// /// Number of active orders /// public int ActiveOrders { get; set; } /// /// Number of failed orders /// public int FailedOrders { get; set; } /// /// Fill rate (0.0 to 1.0) /// public double FillRate { get; set; } /// /// Average slippage /// public double AverageSlippage { get; set; } /// /// Average execution time in milliseconds /// public double AverageExecutionTimeMs { get; set; } /// /// Total value traded /// public decimal TotalValueTraded { get; set; } /// /// Last update timestamp /// public DateTime LastUpdated { get; set; } /// /// Constructor for OmsMetrics /// public OmsMetrics( int totalOrders, int activeOrders, int failedOrders, double fillRate, double averageSlippage, double averageExecutionTimeMs, decimal totalValueTraded, DateTime lastUpdated) { TotalOrders = totalOrders; ActiveOrders = activeOrders; FailedOrders = failedOrders; FillRate = fillRate; AverageSlippage = averageSlippage; AverageExecutionTimeMs = averageExecutionTimeMs; TotalValueTraded = totalValueTraded; LastUpdated = lastUpdated; } } #endregion #region Enumerations /// /// Order side enumeration /// public enum OrderSide { Buy = 1, Sell = -1 } /// /// Order type enumeration /// public enum OrderType { Market, Limit, StopMarket, StopLimit } /// /// Order state enumeration /// public enum OrderState { New, Submitted, Accepted, PartiallyFilled, Filled, Cancelled, Rejected, Expired } /// /// Time in force enumeration /// public enum TimeInForce { Day, Gtc, // Good Till Cancelled Ioc, // Immediate Or Cancel Fok // Fill Or Kill } #endregion }