Fix Runtime by adding TotalRuntimeInSeconds
This commit is contained in:
@@ -13,6 +13,11 @@ namespace Managing.Domain.Bots
|
||||
public DateTime StartupTime { get; set; }
|
||||
public DateTime CreateDate { 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; }
|
||||
@@ -23,5 +28,21 @@ namespace Managing.Domain.Bots
|
||||
public int LongPositionCount { get; set; }
|
||||
public int ShortPositionCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total runtime in seconds, including the current session if the bot is running
|
||||
/// </summary>
|
||||
public long GetTotalRuntimeSeconds()
|
||||
{
|
||||
var totalSeconds = AccumulatedRunTimeSeconds;
|
||||
|
||||
// If bot is currently running, add current session time
|
||||
if (Status == BotStatus.Running && LastStartTime.HasValue)
|
||||
{
|
||||
var currentSessionSeconds = (long)(DateTime.UtcNow - LastStartTime.Value).TotalSeconds;
|
||||
totalSeconds += currentSessionSeconds;
|
||||
}
|
||||
|
||||
return totalSeconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user