using Predictalytics.Domain.Enums;

namespace Predictalytics.Domain.Entities;

public class TraderCategoryPerformance
{
    public int Id { get; set; }
    
    public int TraderId { get; set; }
    public Trader Trader { get; set; } = null!;

    public MarketCategory Category { get; set; }

    /// <summary>Subcategory (e.g. "Basketball", "Elections", "Bitcoin").</summary>
    public string Subcategory { get; set; } = string.Empty;

    /// <summary>Total volume traded in this category (USD).</summary>
    public decimal TotalVolume { get; set; }

    /// <summary>Total Profit/Loss in this category (USD).</summary>
    public decimal TotalPnL { get; set; }

    /// <summary>Total invested amount in this category (USD).</summary>
    public decimal TotalInvested { get; set; }

    /// <summary>Number of trades in this category.</summary>
    public int TotalTrades { get; set; }

    /// <summary>Number of profitable trades in this category.</summary>
    public int WinningTrades { get; set; }

    /// <summary>Calculated win rate for this category (0.0 - 1.0).</summary>
    public decimal WinRate => TotalTrades > 0 ? (decimal)WinningTrades / TotalTrades : 0;

    /// <summary>Calculated ROI percentage (Total PnL / Total Invested * 100).</summary>
    public decimal AvgReturnPct => TotalInvested > 0 ? (TotalPnL / TotalInvested) * 100m : 0;
}
