refactor(hedger): rename logger to HEDGER and show Total PnL in idle logs

This commit is contained in:
2025-12-20 12:15:57 +01:00
parent 98bda8d71a
commit 0cba52b60c

View File

@ -43,7 +43,7 @@ class UnixMsLogFilter(logging.Filter):
return True return True
# Configure Logging # Configure Logging
logger = logging.getLogger("SCALPER_HEDGER") logger = logging.getLogger("HEDGER")
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
logger.propagate = False # Prevent double logging from root logger logger.propagate = False # Prevent double logging from root logger
logger.handlers.clear() # Clear existing handlers to prevent duplicates logger.handlers.clear() # Clear existing handlers to prevent duplicates
@ -842,7 +842,7 @@ class ScalperHedger:
self.last_idle_log_time = time.time() self.last_idle_log_time = time.time()
else: else:
if time.time() - self.last_idle_log_time > 30: if time.time() - self.last_idle_log_time > 30:
logger.info(f"[IDLE] Px: {price:.2f} | Diff: {diff_abs:.4f} < {rebalance_threshold:.4f} (Vol: {vol_pct*100:.3f}% x{vol_multiplier:.1f} | Thresh: {final_threshold_pct*100:.1f}%) | PnL: {current_pnl:.2f}") logger.info(f"[IDLE] Px: {price:.2f} | Diff: {diff_abs:.4f} < {rebalance_threshold:.4f} (Vol: {vol_pct*100:.3f}% x{vol_multiplier:.1f} | Thresh: {final_threshold_pct*100:.1f}%) | TotPnL: {self.accumulated_pnl:.2f}")
self.last_idle_log_time = time.time() self.last_idle_log_time = time.time()
self.track_fills_and_pnl() self.track_fills_and_pnl()