diff --git a/v2realbot/common/db.py b/v2realbot/common/db.py index 8c9ed5a..f8aa176 100644 --- a/v2realbot/common/db.py +++ b/v2realbot/common/db.py @@ -98,7 +98,7 @@ def row_to_runmanager(row: dict) -> RunManagerRecord: #prevede dict radku zpatky na objekt vcetme retypizace def row_to_runarchiveview(row: dict) -> RunArchiveView: - return RunArchive( + a = RunArchiveView( id=row['runner_id'], strat_id=row['strat_id'], batch_id=row['batch_id'], @@ -116,8 +116,11 @@ def row_to_runarchiveview(row: dict) -> RunArchiveView: trade_count=int(row['trade_count']), end_positions=int(row['end_positions']), end_positions_avgp=float(row['end_positions_avgp']), - metrics=orjson.loads(row['metrics']) if row['metrics'] else None + metrics=orjson.loads(row['metrics']) if row['metrics'] else None, + batch_profit=int(row['batch_profit']) if row['batch_profit'] else 0, + batch_count=int(row['batch_count']) if row['batch_count'] else 0, ) + return a #prevede dict radku zpatky na objekt vcetme retypizace def row_to_runarchive(row: dict) -> RunArchive: diff --git a/v2realbot/common/model.py b/v2realbot/common/model.py index f2dc6db..e26a475 100644 --- a/v2realbot/common/model.py +++ b/v2realbot/common/model.py @@ -320,6 +320,8 @@ class RunArchiveView(BaseModel): end_positions: int = 0 end_positions_avgp: float = 0 metrics: Union[dict, str] = None + batch_profit: float = 0 # Total profit for the batch - now calculated during query + batch_count: int = 0 # Count of runs in the batch - now calculated during query #same but with pagination class RunArchiveViewPagination(BaseModel): diff --git a/v2realbot/controller/services.py b/v2realbot/controller/services.py index 3bb197a..b43d0fe 100644 --- a/v2realbot/controller/services.py +++ b/v2realbot/controller/services.py @@ -1126,7 +1126,9 @@ def get_all_archived_runners_p(request: DataTablesRequest) -> Tuple[int, RunArch SELECT runner_id, strat_id, batch_id, symbol, name, note, started, stopped, mode, account, bt_from, bt_to, ilog_save, profit, trade_count, end_positions, end_positions_avgp, metrics, - MAX(stopped) OVER (PARTITION BY batch_id) AS max_stopped + MAX(stopped) OVER (PARTITION BY batch_id) AS max_stopped, + SUM(profit) OVER (PARTITION BY batch_id) AS batch_profit, + COUNT(*) OVER (PARTITION BY batch_id) AS batch_count FROM runner_header WHERE (:search_value = '' OR strat_id LIKE :search_value OR batch_id LIKE :search_value) ), @@ -1140,7 +1142,8 @@ def get_all_archived_runners_p(request: DataTablesRequest) -> Tuple[int, RunArch ) SELECT runner_id, strat_id, batch_id, symbol, name, note, started, stopped, mode, account, bt_from, bt_to, ilog_save, profit, - trade_count, end_positions, end_positions_avgp, metrics + trade_count, end_positions, end_positions_avgp, metrics, + batch_profit, batch_count FROM InterleavedGroups ORDER BY sort_key DESC, diff --git a/v2realbot/static/index.html b/v2realbot/static/index.html index 3521db6..b31df94 100644 --- a/v2realbot/static/index.html +++ b/v2realbot/static/index.html @@ -595,7 +595,9 @@