using NT8.Core.Common.Models;
using NT8.Core.Risk;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NT8.Core.Orders
{
    /// <summary>
    /// Order management interface - handles order submission, routing, and execution
    /// </summary>
    public interface IOrderManager
    {
        #region Order Submission and Management

        /// <summary>
        /// Submit a new order for execution
        /// </summary>
        Task<OrderResult> SubmitOrderAsync(OrderRequest request, StrategyContext context);

        /// <summary>
        /// Cancel an existing order
        /// </summary>
        Task<bool> CancelOrderAsync(string orderId);

        /// <summary>
        /// Modify an existing order
        /// </summary>
        Task<OrderResult> ModifyOrderAsync(string orderId, OrderModification modification);

        /// <summary>
        /// Get order status
        /// </summary>
        Task<OrderStatus> GetOrderStatusAsync(string orderId);

        /// <summary>
        /// Get all orders for a symbol
        /// </summary>
        Task<List<OrderStatus>> GetOrdersBySymbolAsync(string symbol);

        /// <summary>
        /// Get all active orders
        /// </summary>
        Task<List<OrderStatus>> GetActiveOrdersAsync();

        #endregion

        #region Algorithmic Execution

        /// <summary>
        /// Execute a TWAP order
        /// </summary>
        Task<OrderResult> ExecuteTwapAsync(TwapParameters parameters, StrategyContext context);

        /// <summary>
        /// Execute a VWAP order
        /// </summary>
        Task<OrderResult> ExecuteVwapAsync(VwapParameters parameters, StrategyContext context);

        /// <summary>
        /// Execute an Iceberg order
        /// </summary>
        Task<OrderResult> ExecuteIcebergAsync(IcebergParameters parameters, StrategyContext context);

        #endregion

        #region Smart Order Routing

        /// <summary>
        /// Route order based on smart routing logic
        /// </summary>
        Task<RoutingResult> RouteOrderAsync(OrderRequest request, StrategyContext context);

        /// <summary>
        /// Get available execution venues
        /// </summary>
        List<ExecutionVenue> GetAvailableVenues();

        /// <summary>
        /// Get routing performance metrics
        /// </summary>
        RoutingMetrics GetRoutingMetrics();

        #endregion

        #region Risk Integration

        /// <summary>
        /// Validate order against risk parameters
        /// </summary>
        Task<RiskDecision> ValidateOrderAsync(OrderRequest request, StrategyContext context);

        #endregion

        #region Configuration and Management

        /// <summary>
        /// Update routing configuration
        /// </summary>
        void UpdateRoutingConfig(RoutingConfig config);

        /// <summary>
        /// Get current routing configuration
        /// </summary>
        RoutingConfig GetRoutingConfig();

        /// <summary>
        /// Update algorithm parameters
        /// </summary>
        void UpdateAlgorithmParameters(AlgorithmParameters parameters);

        /// <summary>
        /// Get current algorithm parameters
        /// </summary>
        AlgorithmParameters GetAlgorithmParameters();

        /// <summary>
        /// Reset OMS state
        /// </summary>
        void Reset();

        #endregion

        #region Monitoring and Metrics

        /// <summary>
        /// Get OMS performance metrics
        /// </summary>
        OmsMetrics GetMetrics();

        /// <summary>
        /// Check if OMS is healthy
        /// </summary>
        bool IsHealthy();

        #endregion
    }
}
