Use Sina-only market K-lines and editable admin login synced to .env.

Market page uses Sina for quotes and bars with an auto-follow toggle and incremental chart updates while panning. Settings lets users change username and password, persisting to the database and .env.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-26 13:53:12 +08:00
parent 6905373401
commit 382a9a0e14
9 changed files with 324 additions and 75 deletions
+4 -8
View File
@@ -268,7 +268,7 @@ def fetch_market_klines(
force_remote: bool = False,
*,
trading_mode: Optional[str] = None,
prefer_ctp: bool = True,
prefer_ctp: bool = False,
) -> dict:
chart_sym = ths_to_sina_chart_symbol(symbol)
p = (period or "15m").lower()
@@ -303,11 +303,7 @@ def fetch_market_klines(
except Exception as exc:
logger.debug("ctp kline fetch failed %s %s: %s", symbol, p, exc)
need_sina = (
force_remote
or not ctp_bars
or len(ctp_bars) < MIN_CTP_KLINE_BARS
)
need_sina = force_remote or not prefer_ctp or not ctp_bars or len(ctp_bars) < MIN_CTP_KLINE_BARS
if ctp_bars and len(ctp_bars) >= MIN_CTP_KLINE_BARS:
bars = ctp_bars
@@ -325,10 +321,10 @@ def fetch_market_klines(
except Exception as exc:
logger.warning("kline cache read failed %s %s: %s", chart_sym, p, exc)
if not bars or len(ctp_bars) < MIN_CTP_KLINE_BARS:
if not bars or len(ctp_bars) < MIN_CTP_KLINE_BARS or not prefer_ctp:
remote_bars = fetch_sina_klines(symbol, p)
if remote_bars:
if ctp_bars and ctp_connected:
if prefer_ctp and ctp_bars and ctp_connected:
bars = _merge_kline_bars(remote_bars, ctp_bars)
source = "ctp+remote"
else: