using System;
namespace DesktopBot.Models
{
///
/// Record di un trade (aperto o chiuso) effettuato dal bot.
///
public class BotTradeRecord
{
public string Symbol { get; set; }
public string Side { get; set; } // "BUY" / "SELL"
public decimal EntryPrice { get; set; }
public decimal ExitPrice { get; set; } // 0 se ancora aperta
public decimal Quantity { get; set; }
public decimal StopLoss { get; set; }
public decimal TakeProfit { get; set; }
public decimal PnL { get; set; } // 0 se ancora aperta
public DateTime OpenedAt { get; set; }
public DateTime? ClosedAt { get; set; }
public bool IsOpen => ClosedAt == null;
public int Confidence { get; set; }
/// PnL percentuale sull'investimento iniziale.
public decimal PnLPercent =>
EntryPrice > 0 && Quantity > 0
? PnL / (EntryPrice * Quantity) * 100m
: 0m;
///
/// Badge testuale: APERTA / +X.XX% / -X.XX%
///
public string PnLBadge =>
IsOpen
? "APERTA"
: $"{PnL:+0.00;-0.00;0.00} ({PnLPercent:+0.0;-0.0;0.0}%)";
/// Stringa di stato colorabile via DataTrigger.
public string Status => IsOpen ? "APERTA" : (PnL >= 0 ? "CHIUSA +" : "CHIUSA -");
///
/// Categoria PnL per i DataTrigger XAML ("open" / "profit" / "loss").
///
public string PnLCategory =>
IsOpen ? "open" :
PnL > 0 ? "profit" : "loss";
}
}