settings: add Exchange API tab for instance system settings.

Allow configuring perpetual API keys and live trading from Settings, reusing the existing env save API.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 17:09:53 +08:00
parent 82d16a73e8
commit fd1bf9982c
8 changed files with 150 additions and 4 deletions
+21
View File
@@ -220,6 +220,27 @@ def ui_allowed_keys(exchange_key: str) -> frozenset[str]:
return frozenset(keys)
def build_exchange_api_group(
exchange_key: str,
example_path: str,
env_path: str,
) -> dict[str, Any]:
"""系统设置「交易所 API」专用:仅交易所与实盘字段."""
schema = _schema_field_map(example_path)
values = env_get_all(read_env_lines(env_path))
ex = (exchange_key or "").strip().lower()
live_fields = _EXCHANGE_LIVE_FIELDS.get(ex, _EXCHANGE_LIVE_FIELDS["okx"])
fields = [
_build_field(key, label, note, schema, values)
for key, label, note in live_fields
]
return {
"title": "交易所 API",
"fields": fields,
"has_restart": any(f.get("restart_required") for f in fields),
}
def build_env_ui_payload(
exchange_key: str,
example_path: str,