|
@@ -10,6 +10,13 @@ from enum import Enum
|
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
|
import os
|
|
import os
|
|
|
|
|
|
|
|
|
|
+"""
|
|
|
|
|
+ind 0
|
|
|
|
|
+pub c787afe5ff5d02fb3b0180c86ea4bbf9bfdd1bcab3d96e395d52502532fe05cfc43807e062b16814
|
|
|
|
|
+pri f3625c4662ab0b338e405f61b7555e90aeda8fa28dd607588c9e275dc6f326ddcbd9341e18ca2950
|
|
|
|
|
+"""
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
# 配置日志
|
|
# 配置日志
|
|
|
logs_dir = "logs"
|
|
logs_dir = "logs"
|
|
|
if not os.path.exists(logs_dir):
|
|
if not os.path.exists(logs_dir):
|
|
@@ -86,17 +93,21 @@ class TradingStrategy:
|
|
|
lighter_mark = market_data.get('lighter_mark_price')
|
|
lighter_mark = market_data.get('lighter_mark_price')
|
|
|
lighter_price = market_data.get('lighter_price')
|
|
lighter_price = market_data.get('lighter_price')
|
|
|
|
|
|
|
|
- # 计算价差
|
|
|
|
|
|
|
+ # 计算价差,转换为bps单位
|
|
|
if binance_price and lighter_price:
|
|
if binance_price and lighter_price:
|
|
|
- price_diff = binance_price - lighter_price
|
|
|
|
|
- price_diff_pct = (price_diff / binance_price) * 100 if binance_price else 0
|
|
|
|
|
|
|
+ # 确保两个价格都是浮点数
|
|
|
|
|
+ binance_price_float = float(binance_price) if isinstance(binance_price, str) else binance_price
|
|
|
|
|
+ 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
|
|
|
else:
|
|
else:
|
|
|
- price_diff = None
|
|
|
|
|
- price_diff_pct = None
|
|
|
|
|
|
|
+ price_diff_bps = None
|
|
|
|
|
+
|
|
|
|
|
+ # 格式化输出
|
|
|
|
|
+ price_diff_str = f"{price_diff_bps}bps" if price_diff_bps is not None else "N/A"
|
|
|
|
|
|
|
|
- logger.info(f"[{symbol}] Binance: 标记价={binance_mark}, 最新价={binance_price} | "
|
|
|
|
|
- f"Lighter: 标记价={lighter_mark}, 最新价={lighter_price} | "
|
|
|
|
|
- f"价差={price_diff:.6f if price_diff else 'N/A'} ({price_diff_pct:.4f}% if price_diff_pct else 'N/A')")
|
|
|
|
|
|
|
+ logger.info(f"[{symbol}] Binance: 最新价={binance_price} | Lighter: 最新价={lighter_price} | 价差={price_diff_str}")
|
|
|
|
|
|
|
|
def _handle_waiting_init(self):
|
|
def _handle_waiting_init(self):
|
|
|
"""处理等待初始化状态"""
|
|
"""处理等待初始化状态"""
|