feat: 导航开关与 CTP 柜台手续费

系统设置可开关五类导航;手续费默认从 CTP 查询同步,本地/AKShare 作离线兜底;补充 FEES.md。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-24 12:19:56 +08:00
parent ca894dfd4d
commit 528d9811e3
13 changed files with 523 additions and 48 deletions
+46
View File
@@ -0,0 +1,46 @@
"""顶栏导航项显示开关(系统设置)。"""
from __future__ import annotations
import json
from typing import Callable
# 可在系统设置中开关的导航项
NAV_TOGGLES: dict[str, str] = {
"fees": "手续费配置",
"contract": "品种简介",
"plans": "开单计划",
"market": "行情K线",
"strategy": "策略交易",
}
DEFAULT_NAV: dict[str, bool] = {k: True for k in NAV_TOGGLES}
def get_nav_items(get_setting: Callable[[str, str], str]) -> dict[str, bool]:
raw = (get_setting("nav_items", "") or "").strip()
out = dict(DEFAULT_NAV)
if not raw:
return out
try:
data = json.loads(raw)
if isinstance(data, dict):
for k in NAV_TOGGLES:
if k in data:
out[k] = bool(data[k])
except json.JSONDecodeError:
pass
return out
def save_nav_items(set_setting: Callable[[str, str], None], items: dict[str, bool]) -> None:
merged = dict(DEFAULT_NAV)
for k in NAV_TOGGLES:
if k in items:
merged[k] = bool(items[k])
set_setting("nav_items", json.dumps(merged, ensure_ascii=False))
def nav_enabled(get_setting: Callable[[str, str], str], key: str) -> bool:
if key not in NAV_TOGGLES:
return True
return get_nav_items(get_setting).get(key, True)