using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using static Managing.Common.Enums; namespace Managing.Infrastructure.Databases.PostgreSql.Entities; [Table("Bots")] public class BotEntity { [Key] public Guid Identifier { get; set; } [Required] [MaxLength(255)] public required string Name { get; set; } public Ticker Ticker { get; set; } public TradingType TradingType { get; set; } public int UserId { get; set; } [ForeignKey("UserId")] public UserEntity User { get; set; } public BotStatus Status { get; set; } public DateTime CreateDate { get; set; } public DateTime UpdatedAt { get; set; } public DateTime StartupTime { get; set; } // Runtime tracking fields public DateTime? LastStartTime { get; set; } public DateTime? LastStopTime { get; set; } public long AccumulatedRunTimeSeconds { get; set; } public int TradeWins { get; set; } public int TradeLosses { get; set; } public decimal Pnl { get; set; } public decimal NetPnL { get; set; } public decimal Roi { get; set; } public decimal Volume { get; set; } public decimal Fees { get; set; } public int LongPositionCount { get; set; } public int ShortPositionCount { get; set; } public decimal BotTradingBalance { get; set; } /// /// The backtest ID associated with this bot (nullable for bots not created from backtests) /// public int? BacktestId { get; set; } /// /// The user ID of the master bot's owner when this bot is for copy trading /// [ForeignKey("MasterBotUser")] public int? MasterBotUserId { get; set; } /// /// Navigation property for the master bot's owner when this bot is for copy trading /// public virtual UserEntity? MasterBotUser { get; set; } }