فهرست منبع

Show raw ATR inputs in dashboard

Lukas Goldschmidt 1 ماه پیش
والد
کامیت
3cb42fb8e9
1فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 11 0
      strategies/grid_trader.py

+ 11 - 0
strategies/grid_trader.py

@@ -130,19 +130,24 @@ class Strategy(Strategy):
         try:
             regime = self.context.get_regime(self._base_symbol(), tf)
             short_regime = self.context.get_regime(self._base_symbol(), "15m")
+            tf_atr_pct = float((regime or {}).get("volatility", {}).get("atr_percent") or 0.0)
             atr_pct = float((regime or {}).get("volatility", {}).get("atr_percent") or 0.0)
             short_atr_pct = float((short_regime or {}).get("volatility", {}).get("atr_percent") or 0.0)
             atr_pct = max(atr_pct, short_atr_pct)
             self.state["regimes"] = self._regime_snapshot()
         except Exception as exc:
             self._log(f"regime fetch failed: {exc}")
+            tf_atr_pct = 0.0
             atr_pct = 0.0
+            short_atr_pct = 0.0
 
         adaptive = (atr_pct / 100.0) * multiplier if atr_pct > 0 else base_step
         step = adaptive if atr_pct > 0 else base_step
         step = max(step, min_step)
         step = min(step, max_step)
         self.state["grid_step_pct"] = step
+        self.state["atr_percent_tf"] = tf_atr_pct
+        self.state["atr_percent_15m"] = short_atr_pct
         self.state["atr_percent"] = atr_pct
         return step
 
@@ -610,10 +615,14 @@ class Strategy(Strategy):
         # 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)
+        live_atr_tf_pct = float(self.state.get("atr_percent_tf") or 0.0)
+        live_atr_15m_pct = float(self.state.get("atr_percent_15m") or 0.0)
         try:
             self._refresh_balance_snapshot()
             live_step_pct = self._grid_step_pct()
             live_atr_pct = float(self.state.get("atr_percent") or live_atr_pct)
+            live_atr_tf_pct = float(self.state.get("atr_percent_tf") or live_atr_tf_pct)
+            live_atr_15m_pct = float(self.state.get("atr_percent_15m") or live_atr_15m_pct)
         except Exception as exc:
             self._log(f"render refresh failed: {exc}")
 
@@ -626,6 +635,8 @@ class Strategy(Strategy):
                 {"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(live_atr_pct, 4)},
+                {"type": "metric", "label": f"ATR {self.config.get('volatility_timeframe', '1h')}", "value": round(live_atr_tf_pct, 4)},
+                {"type": "metric", "label": "ATR 15m", "value": round(live_atr_15m_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')},