Forráskód Böngészése

fix(策略): 修正价差计算逻辑并清理无用代码

将价差计算从binance_price - lighter_price改为lighter_price - binance_price以符合业务逻辑
移除未使用的市场数据变量binance_mark_price和lighter_mark_price
将entry_price_diff改为entry_price_bps并设置默认值5bps
skyfffire 1 hete
szülő
commit
9cbc88f860
1 módosított fájl, 6 hozzáadás és 6 törlés
  1. 6 6
      src/record/strategy.py

+ 6 - 6
src/record/strategy.py

@@ -41,9 +41,9 @@ class TradingStrategy:
     def __init__(self):
         """初始化策略"""
         self.state = StrategyState.WAITING_INIT
-        self.current_position = None  # 当前持仓信息
-        self.entry_price_diff = None  # 入场时的价差
-        self.target_symbol = "DOGE"  # 目标交易对
+        self.current_position = None    # 当前持仓信息
+        self.entry_price_bps = 5        # 入场时的价差
+        self.target_symbol = "DOGE"     # 目标交易对
         
         logger.info("策略初始化完成,当前状态: WAITING_INIT")
     
@@ -88,9 +88,9 @@ class TradingStrategy:
     def _print_market_data(self, market_data):
         """打印市场数据"""
         symbol = market_data.get('symbol')
-        binance_mark = market_data.get('binance_mark_price')
+        # binance_mark = market_data.get('binance_mark_price')
         binance_price = market_data.get('binance_price')
-        lighter_mark = market_data.get('lighter_mark_price')
+        # lighter_mark = market_data.get('lighter_mark_price')
         lighter_price = market_data.get('lighter_price')
         
         # 计算价差,转换为bps单位
@@ -100,7 +100,7 @@ class TradingStrategy:
             lighter_price_float = float(lighter_price) if isinstance(lighter_price, str) else lighter_price
             
             # 计算价差并转换为bps (1bps = 0.01%)
-            price_diff_bps = int((binance_price_float - lighter_price_float) / binance_price_float * 10000) if binance_price_float else 0
+            price_diff_bps = int((lighter_price_float - binance_price_float) / binance_price_float * 10000) if binance_price_float else 0
         else:
             price_diff_bps = None