feat: CTP/SimNow 配置迁入系统设置,登录失败即时报错
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+11
-8
@@ -33,18 +33,21 @@ def _probe(host_port: str) -> str:
|
||||
|
||||
|
||||
def main() -> int:
|
||||
user = os.getenv("SIMNOW_USER", "")
|
||||
td = os.getenv("SIMNOW_TD_ADDRESS", "tcp://180.168.146.187:10201")
|
||||
md = os.getenv("SIMNOW_MD_ADDRESS", "tcp://180.168.146.187:10211")
|
||||
env = os.getenv("SIMNOW_ENV", "实盘")
|
||||
from ctp_settings import resolve_ctp_value
|
||||
|
||||
print("=== SimNow 配置 ===")
|
||||
user = resolve_ctp_value("simnow_user", "SIMNOW_USER")
|
||||
pwd = resolve_ctp_value("simnow_password", "SIMNOW_PASSWORD")
|
||||
td = resolve_ctp_value("simnow_td_address", "SIMNOW_TD_ADDRESS", "tcp://180.168.146.187:10201")
|
||||
md = resolve_ctp_value("simnow_md_address", "SIMNOW_MD_ADDRESS", "tcp://180.168.146.187:10211")
|
||||
env = resolve_ctp_value("simnow_env", "SIMNOW_ENV", "实盘")
|
||||
|
||||
print("=== SimNow 配置(系统设置优先)===")
|
||||
print(f"locale = {ensure_process_locale()}")
|
||||
missing = missing_ctp_locales()
|
||||
if missing:
|
||||
print(f"警告: 缺少 CTP 所需 locale: {', '.join(missing)}")
|
||||
print(f"SIMNOW_USER = {user or '(未设置)'}")
|
||||
print(f"SIMNOW_PASSWORD = {'*' * 8 if os.getenv('SIMNOW_PASSWORD') else '(未设置)'}")
|
||||
print(f"SIMNOW_PASSWORD = {'*' * 8 if pwd else '(未设置)'}")
|
||||
print(f"SIMNOW_TD = {td}")
|
||||
print(f"SIMNOW_MD = {md}")
|
||||
print(f"SIMNOW_ENV = {env}")
|
||||
@@ -54,8 +57,8 @@ def main() -> int:
|
||||
print(f"MD {md} -> {_probe(md)}")
|
||||
print()
|
||||
|
||||
if not user or not os.getenv("SIMNOW_PASSWORD"):
|
||||
print("错误:请在 .env 填写 SIMNOW_USER / SIMNOW_PASSWORD")
|
||||
if not user or not pwd:
|
||||
print("错误:请在系统设置或 .env 填写 SimNow 投资者代码与密码")
|
||||
return 1
|
||||
|
||||
print("=== CTP 登录测试 ===")
|
||||
|
||||
Reference in New Issue
Block a user