feat: 添加 Binance 模拟交易支持
在 BinanceFuturesClient 和 BinanceSpotClient 中添加 enable_demo_trading 参数 根据 enable_demo_trading 自动设置正确的 demo base_url Futures: https://demo-fapi.binance.com Spot: https://demo-api.binance.com 在 factory.py 中从 exchange_config 读取 enable_demo_trading 配置并传递给客户端
This commit is contained in:
@@ -16,7 +16,10 @@ from app.services.live_trading.symbols import to_binance_futures_symbol
|
||||
|
||||
|
||||
class BinanceSpotClient(BaseRestClient):
|
||||
def __init__(self, *, api_key: str, secret_key: str, base_url: str = "https://api.binance.com", timeout_sec: float = 15.0):
|
||||
def __init__(self, *, api_key: str, secret_key: str, base_url: str = None, enable_demo_trading: bool = False, timeout_sec: float = 15.0):
|
||||
if not base_url:
|
||||
base_url = "https://demo-api.binance.com" if enable_demo_trading else "https://api.binance.com"
|
||||
|
||||
super().__init__(base_url=base_url, timeout_sec=timeout_sec)
|
||||
self.api_key = (api_key or "").strip()
|
||||
self.secret_key = (secret_key or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user