using Managing.Common;

namespace Managing.Api.Models.Responses
{
    /// <summary>
    /// Detailed information about a user's deployed strategy
    /// </summary>
    public class UserStrategyDetailsViewModel
    {
        /// <summary>
        /// Name of the deployed strategy
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Current state of the strategy (RUNNING, STOPPED, UNUSED)
        /// </summary>
        public Enums.BotStatus State { get; set; }

        /// <summary>
        /// Total profit or loss generated by the strategy in USD (gross, before fees)
        /// </summary>
        public decimal PnL { get; set; }

        /// <summary>
        /// Net profit or loss generated by the strategy in USD (after fees)
        /// </summary>
        public decimal NetPnL { get; set; }

        /// <summary>
        /// Return on investment percentage
        /// </summary>
        public decimal ROIPercentage { get; set; }

        /// <summary>
        /// Date and time when the strategy was started (only present when running, for live ticker)
        /// </summary>
        public DateTime? Runtime { get; set; }

        /// <summary>
        /// Total accumulated runtime in seconds (including current session if running)
        /// </summary>
        public long TotalRuntimeSeconds { get; set; }

        /// <summary>
        /// Time when the current or last session started
        /// </summary>
        public DateTime? LastStartTime { get; set; }

        /// <summary>
        /// Time when the last session stopped (null if currently running)
        /// </summary>
        public DateTime? LastStopTime { get; set; }

        /// <summary>
        /// Total accumulated runtime across all past sessions (seconds)
        /// </summary>
        public long AccumulatedRunTimeSeconds { get; set; }

        /// <summary>
        /// Average percentage of successful trades
        /// </summary>
        public int WinRate { get; set; }

        /// <summary>
        /// Total trading volume for all trades
        /// </summary>
        public decimal TotalVolumeTraded { get; set; }

        /// <summary>
        /// Trading volume in the last 24 hours
        /// </summary>
        public decimal VolumeLast24H { get; set; }

        /// <summary>
        /// Number of winning trades
        /// </summary>
        public int Wins { get; set; }

        /// <summary>
        /// Number of losing trades
        /// </summary>
        public int Losses { get; set; }

        /// <summary>
        /// Dictionary of all positions executed by this strategy, keyed by position identifier
        /// </summary>
        public List<PositionViewModel> Positions { get; set; } = new List<PositionViewModel>();

        public Guid Identifier { get; set; }

        public Dictionary<DateTime, decimal> WalletBalances { get; set; } = new Dictionary<DateTime, decimal>();
        public Enums.Ticker Ticker { get; set; }
    }
}