diff --git a/src/Managing.Application/Bots/Grains/AgentGrain.cs b/src/Managing.Application/Bots/Grains/AgentGrain.cs index 010da85d..0fb2dbe7 100644 --- a/src/Managing.Application/Bots/Grains/AgentGrain.cs +++ b/src/Managing.Application/Bots/Grains/AgentGrain.cs @@ -81,7 +81,8 @@ public class AgentGrain : Grain, IAgentGrain UpdatedAt = DateTime.UtcNow, ActiveStrategiesCount = 0, TotalVolume = 0, - TotalBalance = 0 + TotalBalance = 0, + TotalFees = 0 }; await _agentService.SaveOrUpdateAgentSummary(emptySummary); diff --git a/src/Managing.Application/Bots/Grains/LiveTradingBotGrain.cs b/src/Managing.Application/Bots/Grains/LiveTradingBotGrain.cs index e1336673..3c5cae8f 100644 --- a/src/Managing.Application/Bots/Grains/LiveTradingBotGrain.cs +++ b/src/Managing.Application/Bots/Grains/LiveTradingBotGrain.cs @@ -722,10 +722,10 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable var fees = _tradingBot.GetTotalFees(); var volume = TradingBox.GetTotalVolumeTraded(_tradingBot.Positions); - // Calculate ROI based on total investment + // Calculate ROI based on total investment (PnL minus fees) var totalInvestment = _tradingBot.Positions.Values .Sum(p => p.Open.Quantity * p.Open.Price); - var roi = totalInvestment > 0 ? (pnl / totalInvestment) * 100 : 0; + var roi = totalInvestment > 0 ? ((pnl - fees) / totalInvestment) * 100 : 0; // Calculate long and short position counts var longPositionCount = _tradingBot.Positions.Values diff --git a/src/Managing.WebApp/src/pages/dashboardPage/agentStrategy.tsx b/src/Managing.WebApp/src/pages/dashboardPage/agentStrategy.tsx index ad66c256..61ba86b3 100644 --- a/src/Managing.WebApp/src/pages/dashboardPage/agentStrategy.tsx +++ b/src/Managing.WebApp/src/pages/dashboardPage/agentStrategy.tsx @@ -1,12 +1,13 @@ import React, {useEffect, useState} from 'react' import {PlayIcon, StopIcon} from '@heroicons/react/solid' +import moment from 'moment' import { - BotClient, - BotStatus, - DataClient, - Position, - TradeDirection, - UserStrategyDetailsViewModel + BotClient, + BotStatus, + DataClient, + Position, + TradeDirection, + UserStrategyDetailsViewModel } from '../../generated/ManagingApi' import useApiUrlStore from '../../app/store/apiStore' import {Toast} from '../../components/mollecules' @@ -63,16 +64,22 @@ const AgentStrategy: React.FC = ({ index }) => { const formatDuration = (runtime?: Date | null) => { if (!runtime) return '0h' - const now = new Date() - const start = new Date(runtime) - const diffMs = now.getTime() - start.getTime() - const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)) - const diffHours = Math.floor((diffMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)) - if (diffDays > 0) { - return `${diffDays} week${diffDays > 6 ? 's' : ''} ${diffHours}h` + const start = moment(runtime) + const now = moment() + const duration = moment.duration(now.diff(start)) + + const days = Math.floor(duration.asDays()) + const hours = duration.hours() + const minutes = duration.minutes() + + if (days > 0) { + return `${days}d ${hours}h ${minutes}m` + } else if (hours > 0) { + return `${hours}h ${minutes}m` + } else { + return `${minutes}m` } - return `${diffHours}h` } const getStatusBadge = (state: string | null | undefined) => { @@ -176,10 +183,10 @@ const AgentStrategy: React.FC = ({ index }) => {
@@ -282,15 +289,6 @@ const AgentStrategy: React.FC = ({ index }) => { -
-
-

PnL %

-
- {formatPercentage(strategyData.roiPercentage)} -
-
-
-

Total Runtime