فهرست منبع

refactor(strategy): 移除冗余的日志记录以简化代码

清理交易策略中不必要的日志记录,保持代码简洁。主要移除了预签名订单创建和发送过程中的调试日志,仅保留关键操作的状态日志。
skyfffire 3 روز پیش
والد
کامیت
e9bb3e2a1a
1فایلهای تغییر یافته به همراه1 افزوده شده و 8 حذف شده
  1. 1 8
      src/leadlag/strategy.py

+ 1 - 8
src/leadlag/strategy.py

@@ -186,14 +186,12 @@ class TradingStrategy:
         # 首次签名
         if self.presigned_prices is None:
             need_presign = True
-            logger.info(f"首次预签名开仓订单,binance_price={binance_price_float}")
         else:
             # 检查价格变化(与签名时的binance_price对比)
             price_change = self._calculate_bps_change(binance_price_float, self.presigned_prices)
             
             if price_change >= self.presigned_bps_threshold:
                 need_presign = True
-                logger.info(f"价格变化超过{self.presigned_bps_threshold}bps,重新签名。price_change={price_change:.2f}bps")
         
         if not need_presign:
             return
@@ -205,8 +203,6 @@ class TradingStrategy:
             # 做空:在binance_price基础上往下减bps(更低的价格)
             short_price = binance_price_float * (1 - self.entry_price_bps / 10000)
             
-            logger.info(f"预签名订单 - binance_price={binance_price_float}, 做多价格={long_price}, 做空价格={short_price}")
-            
             # 签名做多订单(买入)
             long_tx_info, long_oid, error = await self.create_order_tx(
                 market_info=market_info,
@@ -218,11 +214,9 @@ class TradingStrategy:
             )
             
             if error:
-                logger.error(f"预签名做多订单失败: {error}")
                 self.presigned_long_tx = None
             else:
                 self.presigned_long_tx = (long_tx_info, long_oid)
-                logger.info(f"预签名做多订单成功: oid={long_oid}")
             
             # 签名做空订单(卖出)
             short_tx_info, short_oid, error = await self.create_order_tx(
@@ -235,11 +229,9 @@ class TradingStrategy:
             )
             
             if error:
-                logger.error(f"预签名做空订单失败: {error}")
                 self.presigned_short_tx = None
             else:
                 self.presigned_short_tx = (short_tx_info, short_oid)
-                logger.info(f"预签名做空订单成功: oid={short_oid}")
             
             # 保存签名时的binance_price
             self.presigned_prices = binance_price_float
@@ -476,6 +468,7 @@ class TradingStrategy:
         
         # 直接发送预签名交易
         try:
+            logger.info(f"发送预签名{side_desc}交易,oid={oid}")
             tx_hash, error = await self.send_order_tx(tx_info)
             
             if error: