Procházet zdrojové kódy

Show live grid metrics in dashboard

Lukas Goldschmidt před 1 měsícem
rodič
revize
85531c2503
1 změnil soubory, kde provedl 6 přidání a 3 odebrání
  1. 6 3
      strategies/grid_trader.py

+ 6 - 3
strategies/grid_trader.py

@@ -608,9 +608,12 @@ class Strategy(Strategy):
     def render(self):
         # Refresh the market-derived display values on render so the dashboard
         # reflects the same inputs the strategy would use on the next tick.
+        live_step_pct = float(self.state.get("grid_step_pct") or 0.0)
+        live_atr_pct = float(self.state.get("atr_percent") or 0.0)
         try:
             self._refresh_balance_snapshot()
-            self._grid_step_pct()
+            live_step_pct = self._grid_step_pct()
+            live_atr_pct = float(self.state.get("atr_percent") or live_atr_pct)
         except Exception as exc:
             self._log(f"render refresh failed: {exc}")
 
@@ -622,8 +625,8 @@ class Strategy(Strategy):
                 {"type": "metric", "label": "state", "value": self.state.get("last_action", "idle")},
                 {"type": "metric", "label": "orders", "value": len(self.state.get("orders") or [])},
                 {"type": "metric", "label": "open orders", "value": self.state.get("open_order_count", 0)},
-                {"type": "metric", "label": "ATR %", "value": round(float(self.state.get("atr_percent") or 0.0), 4)},
-                {"type": "metric", "label": "grid step %", "value": round(float(self.state.get("grid_step_pct") or 0.0) * 100.0, 4)},
+                {"type": "metric", "label": "ATR %", "value": round(live_atr_pct, 4)},
+                {"type": "metric", "label": "grid step %", "value": round(live_step_pct * 100.0, 4)},
                 {"type": "metric", "label": "1d", "value": ((self.state.get('regimes') or {}).get('1d') or {}).get('trend', {}).get('state', 'n/a')},
                 {"type": "metric", "label": "4h", "value": ((self.state.get('regimes') or {}).get('4h') or {}).get('trend', {}).get('state', 'n/a')},
                 {"type": "metric", "label": "1h", "value": ((self.state.get('regimes') or {}).get('1h') or {}).get('trend', {}).get('state', 'n/a')},