feat client.

This commit is contained in:
2026-08-31 13:00:22 +08:00
parent a946c5b53d
commit 1b6f5a9f03
33 changed files with 544 additions and 1284 deletions

View File

@@ -52,6 +52,9 @@ class AccountConfig:
enable_auto_ipo: bool = True
signal_allow: list[str] = field(default_factory=list)
excluded_codes: list[str] = field(default_factory=list)
zt_sell_ratio: float = 0.5
zt_buy_fall_pct: float = 1.0
zt_max_price: float = 200.0
# 当前账户启用的策略名称,例如 trend。
strategy: str = ""
@@ -129,12 +132,18 @@ def load(
account_config = AccountConfig(**_yaml(root / account_file))
if account_config.buy_value <= 0 or account_config.grid_step_pct <= 0:
raise ValueError("buy_value、grid_step_pct 必须大于 0")
if not 0 < account_config.zt_sell_ratio <= 1:
raise ValueError("zt_sell_ratio 必须在 (0, 1] 区间")
if account_config.zt_buy_fall_pct <= 0 or account_config.zt_max_price <= 0:
raise ValueError("zt_buy_fall_pct、zt_max_price 必须大于 0")
if not account_config.strategy.strip():
raise ValueError("strategy 不能为空")
# host_key 统一为小写,避免不同模块比较时受大小写影响。
account_config.host_key = account_config.host_key.lower()
account_config.strategy = account_config.strategy.lower()
if account_config.strategy == "zt" and account_config.signal_allow != ["dcm"]:
raise ValueError("zt 策略的 signal_allow 必须且只能为 [\"dcm\"]")
return global_config, account_config