Add Binance SIM market adapter and exchange switch in settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-25 12:02:36 +08:00
parent 5dcec0fde0
commit 78fd046fb6
25 changed files with 879 additions and 45 deletions
+25 -1
View File
@@ -33,9 +33,17 @@ class Settings(BaseSettings):
okx_ws_public: str = "wss://ws.okx.com:8443/ws/v5/public"
okx_http_proxy: str = ""
# 币安公共行情(SIM 只读)
binance_fapi_base: str = "https://fapi.binance.com"
binance_eapi_base: str = "https://eapi.binance.com"
binance_futures_ws: str = "wss://fstream.binance.com/stream"
binance_options_ws: str = "wss://nbstream.binance.com/eoptions/stream"
binance_http_proxy: str = ""
perp_inst_id: str = "ETH-USDT-SWAP"
option_inst_family: str = "ETH-USD_UM"
index_inst_id: str = "ETH-USD"
option_ct_mult_default: float = 0.01
fee_rate: float = 0.0005
initial_equity: float = 10_000.0 # SIM 模拟初始资金(USDT),设置页可改
@@ -55,7 +63,6 @@ class Settings(BaseSettings):
close_bid_mark_max_pct: float = 30.0 # 平仓:买一相对标记最大偏差%
perp_qty_eth: float = 1.0
option_qty_eth: float = 2.0
option_ct_mult_default: float = 0.01
db_path: str = "" # empty -> backend/data/hedge.db
@property
@@ -63,6 +70,23 @@ class Settings(BaseSettings):
return self.mode.strip().upper() != "LIVE"
# 切换交易所时的合约默认
EXCHANGE_MARKET_DEFAULTS: dict[str, dict[str, str | float]] = {
"okx": {
"perp_inst_id": "ETH-USDT-SWAP",
"option_inst_family": "ETH-USD_UM",
"index_inst_id": "ETH-USD",
"option_ct_mult_default": 0.01,
},
"binance": {
"perp_inst_id": "ETHUSDT",
"option_inst_family": "ETHUSDT",
"index_inst_id": "ETHUSDT",
"option_ct_mult_default": 1.0,
},
}
@lru_cache
def get_settings() -> Settings:
return Settings()