using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace NT8.Core.OMS
{
    /// <summary>
    /// Order management interface - manages complete order lifecycle
    /// </summary>
    public interface IOrderManager : IDisposable
    {
        /// <summary>
        /// Submit new order for execution
        /// </summary>
        /// <param name="request">Order request with all parameters</param>
        /// <returns>Order result with unique order ID for tracking</returns>
        /// <exception cref="ArgumentNullException">Request is null</exception>
        /// <exception cref="ArgumentException">Request validation fails</exception>
        Task<OrderResult> SubmitOrderAsync(OrderRequest request);

        /// <summary>
        /// Modify existing order
        /// </summary>
        /// <param name="modification">Order modification parameters</param>
        /// <returns>True if modification was successful, false otherwise</returns>
        /// <exception cref="ArgumentNullException">Modification is null</exception>
        /// <exception cref="ArgumentException">Modification validation fails</exception>
        Task<bool> ModifyOrderAsync(OrderModification modification);

        /// <summary>
        /// Cancel existing order
        /// </summary>
        /// <param name="cancellation">Order cancellation request</param>
        /// <returns>True if cancellation was successful, false otherwise</returns>
        /// <exception cref="ArgumentNullException">Cancellation is null</exception>
        /// <exception cref="ArgumentException">Cancellation validation fails</exception>
        Task<bool> CancelOrderAsync(OrderCancellation cancellation);

        /// <summary>
        /// Get current status of an order
        /// </summary>
        /// <param name="orderId">Order ID to query</param>
        /// <returns>Current order status, or null if order not found</returns>
        Task<OrderStatus> GetOrderStatusAsync(string orderId);

        /// <summary>
        /// Get all active orders (working, partially filled, etc.)
        /// </summary>
        /// <returns>List of active order statuses</returns>
        Task<List<OrderStatus>> GetActiveOrdersAsync();

        /// <summary>
        /// Get all orders for a specific symbol
        /// </summary>
        /// <param name="symbol">Symbol to filter by</param>
        /// <returns>List of order statuses for the symbol</returns>
        Task<List<OrderStatus>> GetOrdersBySymbolAsync(string symbol);

        /// <summary>
        /// Flatten all positions for a specific symbol (cancel all working orders and close positions)
        /// </summary>
        /// <param name="symbol">Symbol to flatten</param>
        /// <returns>True if flatten operation initiated successfully</returns>
        Task<bool> FlattenSymbolAsync(string symbol);

        /// <summary>
        /// Flatten all positions across all symbols (cancel all working orders and close all positions)
        /// </summary>
        /// <returns>True if flatten all operation initiated successfully</returns>
        Task<bool> FlattenAllAsync();

        /// <summary>
        /// Subscribe to order status updates
        /// </summary>
        /// <param name="callback">Callback function to receive order updates</param>
        void SubscribeToOrderUpdates(Action<OrderStatus> callback);

        /// <summary>
        /// Unsubscribe from order status updates
        /// </summary>
        /// <param name="callback">Callback function to unsubscribe</param>
        void UnsubscribeFromOrderUpdates(Action<OrderStatus> callback);
    }
}
