using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Predictalytics.Domain.Entities;

public class TraderAnalytics
{
    [Key, ForeignKey("Trader")]
    public int TraderId { get; set; }

    public DateTime LastCalculatedAt { get; set; } = DateTime.UtcNow;

    public decimal OverallPnL { get; set; }
    public decimal OverallWinRate { get; set; }

    public decimal PnL30d { get; set; }
    public decimal WinRate30d { get; set; }

    public decimal PnL7d { get; set; }
    public decimal WinRate7d { get; set; }

    public decimal PnL24h { get; set; }
    public decimal WinRate24h { get; set; }

    public int Trades30d { get; set; }

    public decimal EstimatedBankroll { get; set; }
    public decimal CurrentBalance { get; set; }

    /// <summary>Copytrading suitability score (0-100). Generated by the Estimator.</summary>
    public decimal CopytradingScore { get; set; }

    /// <summary>The pure skill/edge dimension of the copytrading score (0-100). Generated by the Estimator.</summary>
    public decimal CopytradingQualityScore { get; set; }

    /// <summary>The copyability dimension (alpha-decay, sizing consistency) of the copytrading score (0-100). Generated by the Estimator.</summary>
    public decimal CopytradingCopyabilityScore { get; set; }

    // D2c Market Return Metrics
    public decimal MedianWinReturnPct { get; set; }
    public decimal AvgWinReturnPct { get; set; }
    public decimal MedianLossReturnPct { get; set; }
    public decimal AvgLossReturnPct { get; set; }
    public decimal? ProfitFactor { get; set; }

    // E3 Fingerprints
    public string? PriceBandProfileJson { get; set; }
    public decimal MedianHoldDurationHours { get; set; }
    public decimal P50PositionSize { get; set; }
    public decimal P90PositionSize { get; set; }
    public decimal TradesPerWeek { get; set; }

    // E5 Copyability Aggregates
    public decimal MedianMarketVolumeUsd { get; set; }
    public decimal MedianPostFillDriftPct { get; set; }
    public decimal NetEdgeAfterFeesPct { get; set; }

    // Navigation
    public virtual Trader Trader { get; set; } = null!;
}

public class MarketAnalytics
{
    [Key, ForeignKey("Market")]
    public int MarketId { get; set; }

    public DateTime LastCalculatedAt { get; set; } = DateTime.UtcNow;

    public decimal BotActivityScore { get; set; }
    public int UniqueTradersCount { get; set; }
    public decimal AverageTradeSize { get; set; }

    // Navigation
    public virtual Market Market { get; set; } = null!;
}
