stability fixes, lower updates

This commit is contained in:
Dobromir Popov
2025-07-26 22:32:45 +03:00
parent 9576c52039
commit 7c61c12b70
9 changed files with 1210 additions and 45 deletions

View File

@ -119,9 +119,7 @@ class CleanTradingDashboard:
def __init__(self, data_provider=None, orchestrator: Optional[Any] = None, trading_executor: Optional[TradingExecutor] = None):
self.config = get_config()
# Initialize update batch counter to reduce flickering
self.update_batch_counter = 0
self.update_batch_interval = 3 # Update less critical elements every 3 intervals
# Removed batch counter - now using proper interval separation for performance
# Initialize components
self.data_provider = data_provider or DataProvider()
@ -612,7 +610,7 @@ class CleanTradingDashboard:
Output('profitability-multiplier', 'children'),
Output('cob-websocket-status', 'children'),
Output('mexc-status', 'children')],
[Input('interval-component', 'n_intervals')]
[Input('interval-component', 'n_intervals')] # Keep critical metrics at 2s
)
def update_metrics(n):
"""Update key metrics - ENHANCED with position sync monitoring"""
@ -793,15 +791,12 @@ class CleanTradingDashboard:
@self.app.callback(
Output('recent-decisions', 'children'),
[Input('interval-component', 'n_intervals')]
[Input('slow-interval-component', 'n_intervals')] # OPTIMIZED: Move to 10s interval
)
def update_recent_decisions(n):
"""Update recent trading signals - FILTER OUT HOLD signals and highlight COB signals"""
try:
# Update less frequently to reduce flickering
self.update_batch_counter += 1
if self.update_batch_counter % self.update_batch_interval != 0:
raise PreventUpdate
# Now using slow-interval-component (10s) - no batching needed
# Filter out HOLD signals and duplicate signals before displaying
filtered_decisions = []
@ -875,7 +870,7 @@ class CleanTradingDashboard:
@self.app.callback(
Output('closed-trades-table', 'children'),
[Input('interval-component', 'n_intervals')]
[Input('slow-interval-component', 'n_intervals')] # OPTIMIZED: Move to 10s interval
)
def update_closed_trades(n):
"""Update closed trades table with statistics"""
@ -888,7 +883,7 @@ class CleanTradingDashboard:
@self.app.callback(
Output('pending-orders-content', 'children'),
[Input('interval-component', 'n_intervals')]
[Input('slow-interval-component', 'n_intervals')] # OPTIMIZED: Move to 10s interval
)
def update_pending_orders(n):
"""Update pending orders and position sync status"""
@ -906,9 +901,7 @@ class CleanTradingDashboard:
def update_cob_data(n):
"""Update COB data displays with real order book ladders and cumulative stats"""
try:
# COB data is critical - update every second (no batching)
# if n % self.update_batch_interval != 0:
# raise PreventUpdate
# COB data is critical for trading - keep at 2s interval
eth_snapshot = self._get_cob_snapshot('ETH/USDT')
btc_snapshot = self._get_cob_snapshot('BTC/USDT')
@ -975,14 +968,12 @@ class CleanTradingDashboard:
@self.app.callback(
Output('training-metrics', 'children'),
[Input('interval-component', 'n_intervals')]
[Input('slow-interval-component', 'n_intervals')] # OPTIMIZED: Move to 10s interval
)
def update_training_metrics(n):
"""Update training metrics"""
try:
# Update less frequently to reduce flickering
if n % self.update_batch_interval != 0:
raise PreventUpdate
# Now using slow-interval-component (10s) - no batching needed
metrics_data = self._get_training_metrics()
return self.component_manager.format_training_metrics(metrics_data)