From 6214bc2e9fa1de921aa7056db2380394af3cc066 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Fri, 8 Aug 2025 02:12:01 +0300 Subject: [PATCH] fixed TZ --- core/trading_executor.py | 10 +++++----- web/clean_dashboard.py | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/trading_executor.py b/core/trading_executor.py index dde4d04..b479a8f 100644 --- a/core/trading_executor.py +++ b/core/trading_executor.py @@ -1452,8 +1452,8 @@ class TradingExecutor: # Calculate position size in USD position_size_usd = position.quantity * position.entry_price - # Calculate gross PnL (before fees) with leverage - gross_pnl = (current_price - position.entry_price) * position.quantity * leverage + # Calculate gross PnL (before fees) with leverage - SHORT profits when price falls + gross_pnl = (position.entry_price - current_price) * position.quantity * leverage # Calculate net PnL (after fees) net_pnl = gross_pnl - simulated_fees @@ -1543,8 +1543,8 @@ class TradingExecutor: # Calculate position size in USD position_size_usd = position.quantity * position.entry_price - # Calculate gross PnL (before fees) with leverage - gross_pnl = (current_price - position.entry_price) * position.quantity * leverage + # Calculate gross PnL (before fees) with leverage - SHORT profits when price falls + gross_pnl = (position.entry_price - current_price) * position.quantity * leverage # Calculate net PnL (after fees) net_pnl = gross_pnl - fees @@ -1630,7 +1630,7 @@ class TradingExecutor: # Calculate position size in USD position_size_usd = position.quantity * position.entry_price - # Calculate gross PnL (before fees) with leverage + # Calculate gross PnL (before fees) with leverage - LONG profits when price rises gross_pnl = (current_price - position.entry_price) * position.quantity * leverage # Calculate net PnL (after fees) diff --git a/web/clean_dashboard.py b/web/clean_dashboard.py index 0d9b296..2cce514 100644 --- a/web/clean_dashboard.py +++ b/web/clean_dashboard.py @@ -9059,7 +9059,8 @@ class CleanTradingDashboard: kline = data['k'] tick_record = { 'symbol': 'ETHUSDT', - 'datetime': datetime.fromtimestamp(int(kline['t']) / 1000), + # Store as UTC-aware to avoid local/UTC mixing + 'datetime': datetime.fromtimestamp(int(kline['t']) / 1000, tz=timezone.utc), 'open': float(kline['o']), 'high': float(kline['h']), 'low': float(kline['l']),