Sviluppo TradingBot
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
|
||||
namespace DesktopBot.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Record di un trade (aperto o chiuso) effettuato dal bot.
|
||||
/// </summary>
|
||||
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; }
|
||||
|
||||
/// <summary>PnL percentuale sull'investimento iniziale.</summary>
|
||||
public decimal PnLPercent =>
|
||||
EntryPrice > 0 && Quantity > 0
|
||||
? PnL / (EntryPrice * Quantity) * 100m
|
||||
: 0m;
|
||||
|
||||
/// <summary>
|
||||
/// Badge testuale: APERTA / +X.XX% / -X.XX%
|
||||
/// </summary>
|
||||
public string PnLBadge =>
|
||||
IsOpen
|
||||
? "APERTA"
|
||||
: $"{PnL:+0.00;-0.00;0.00} ({PnLPercent:+0.0;-0.0;0.0}%)";
|
||||
|
||||
/// <summary>Stringa di stato colorabile via DataTrigger.</summary>
|
||||
public string Status => IsOpen ? "APERTA" : (PnL >= 0 ? "CHIUSA +" : "CHIUSA -");
|
||||
|
||||
/// <summary>
|
||||
/// Categoria PnL per i DataTrigger XAML ("open" / "profit" / "loss").
|
||||
/// </summary>
|
||||
public string PnLCategory =>
|
||||
IsOpen ? "open" :
|
||||
PnL > 0 ? "profit" : "loss";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user