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

namespace Managing.Infrastructure.Databases.PostgreSql.Entities;

[Table("Backtests")]
public class BacktestEntity
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }

    [Required]
    [MaxLength(255)]
    public string Identifier { get; set; } = string.Empty;

    [Required]
    [MaxLength(255)]
    public string RequestId { get; set; } = string.Empty;

    [Required]
    [Column(TypeName = "decimal(18,8)")]
    public decimal FinalPnl { get; set; }

    [Required]
    public int WinRate { get; set; }

    [Required]
    [Column(TypeName = "decimal(18,8)")]
    public decimal GrowthPercentage { get; set; }

    [Required]
    [Column(TypeName = "decimal(18,8)")]
    public decimal HodlPercentage { get; set; }

    [Required]
    [Column(TypeName = "jsonb")]
    public string ConfigJson { get; set; } = string.Empty;

    [Required]
    [Column(TypeName = "jsonb")]
    public string PositionsJson { get; set; } = string.Empty;

    [Required]
    [Column(TypeName = "jsonb")]
    public string SignalsJson { get; set; } = string.Empty;

    [Required]
    public DateTime StartDate { get; set; }

    [Required]
    public DateTime EndDate { get; set; }

    [Required]
    [Column(TypeName = "jsonb")]
    public string MoneyManagementJson { get; set; } = string.Empty;

    [Required]
    public int UserId { get; set; }
    
    // Navigation property
    public UserEntity? User { get; set; }

    [Column(TypeName = "jsonb")]
    public string? StatisticsJson { get; set; }

    [Required]
    [Column(TypeName = "decimal(18,8)")]
    public decimal Fees { get; set; }

    [Required]
    public double Score { get; set; }

    [Column(TypeName = "text")]
    public string ScoreMessage { get; set; } = string.Empty;

    [Column(TypeName = "text")]
    public string? Metadata { get; set; }

    [Required]
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    [Required]
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
} 