Fix status IsFinished/IsOpen/IsForMetrics + use redis for markets on gmx.tsx instead of inmemory cache
This commit is contained in:
@@ -564,7 +564,7 @@ public static class TradingBox
|
||||
foreach (var position in positions.Values)
|
||||
{
|
||||
// Only count positions that were opened or closed within the last 24 hours
|
||||
if (position.IsFinished() &&
|
||||
if (position.IsValidForMetrics() &&
|
||||
(position.Open.Date >= cutoff ||
|
||||
(position.StopLoss.Status == TradeStatus.Filled && position.StopLoss.Date >= cutoff) ||
|
||||
(position.TakeProfit1.Status == TradeStatus.Filled && position.TakeProfit1.Date >= cutoff) ||
|
||||
@@ -595,7 +595,7 @@ public static class TradingBox
|
||||
if (timeFilter == "Total")
|
||||
{
|
||||
return positions
|
||||
.Where(p => p.IsFinished() && p.ProfitAndLoss != null)
|
||||
.Where(p => p.IsValidForMetrics() && p.ProfitAndLoss != null)
|
||||
.Sum(p => p.ProfitAndLoss.Realized);
|
||||
}
|
||||
|
||||
@@ -623,7 +623,7 @@ public static class TradingBox
|
||||
|
||||
// Include positions that were closed within the time range
|
||||
return positions
|
||||
.Where(p => p.IsFinished() && p.ProfitAndLoss != null &&
|
||||
.Where(p => p.IsValidForMetrics() && p.ProfitAndLoss != null &&
|
||||
(p.Date >= cutoffDate ||
|
||||
(p.StopLoss.Status == TradeStatus.Filled && p.StopLoss.Date >= cutoffDate) ||
|
||||
(p.TakeProfit1.Status == TradeStatus.Filled && p.TakeProfit1.Date >= cutoffDate) ||
|
||||
@@ -673,8 +673,8 @@ public static class TradingBox
|
||||
|
||||
// Filter positions in the time range
|
||||
var filteredPositions = timeFilter == "Total"
|
||||
? positions.Where(p => p.IsFinished() && p.ProfitAndLoss != null)
|
||||
: positions.Where(p => p.IsFinished() && p.ProfitAndLoss != null &&
|
||||
? positions.Where(p => p.IsValidForMetrics() && p.ProfitAndLoss != null)
|
||||
: positions.Where(p => p.IsValidForMetrics() && p.ProfitAndLoss != null &&
|
||||
(p.Date >= cutoffDate ||
|
||||
(p.StopLoss.Status == TradeStatus.Filled && p.StopLoss.Date >= cutoffDate) ||
|
||||
(p.TakeProfit1.Status == TradeStatus.Filled && p.TakeProfit1.Date >= cutoffDate) ||
|
||||
@@ -729,8 +729,8 @@ public static class TradingBox
|
||||
|
||||
// Filter positions in the time range
|
||||
var filteredPositions = timeFilter == "Total"
|
||||
? positions.Where(p => p.IsFinished())
|
||||
: positions.Where(p => p.IsFinished() &&
|
||||
? positions.Where(p => p.IsValidForMetrics())
|
||||
: positions.Where(p => p.IsValidForMetrics() &&
|
||||
(p.Date >= cutoffDate ||
|
||||
(p.StopLoss.Status == TradeStatus.Filled && p.StopLoss.Date >= cutoffDate) ||
|
||||
(p.TakeProfit1.Status == TradeStatus.Filled && p.TakeProfit1.Date >= cutoffDate) ||
|
||||
|
||||
Reference in New Issue
Block a user