fix: TradingView K线图表并修复品种推荐为空。
- 行情页改用 Lightweight Charts 标准蜡烛图(红跌绿涨) - 修复 fee_rates 缺 source 列导致推荐刷新失败 - 空缓存自动重试,持仓页实时兜底计算推荐列表 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+25
-5
@@ -22,9 +22,9 @@ from position_sizing import (
|
||||
)
|
||||
from recommend_store import (
|
||||
load_recommend_cache,
|
||||
recommend_cache_needs_refresh,
|
||||
recommend_payload,
|
||||
refresh_recommend_cache,
|
||||
rows_missing_max_lots,
|
||||
)
|
||||
from recommend_stream import recommend_hub, start_recommend_worker
|
||||
from ctp_reconnect import start_ctp_reconnect_worker
|
||||
@@ -407,11 +407,31 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
sizing = get_sizing_mode(get_setting)
|
||||
max_pct = get_max_margin_pct(get_setting)
|
||||
rec_loaded = load_recommend_cache(conn)
|
||||
if rec_loaded.get("stale") or rows_missing_max_lots(rec_loaded.get("rows") or []):
|
||||
refresh_recommend_cache(
|
||||
conn, capital, _main_quote, trading_mode=mode, max_margin_pct=max_pct,
|
||||
)
|
||||
if recommend_cache_needs_refresh(rec_loaded, capital=capital):
|
||||
try:
|
||||
refresh_recommend_cache(
|
||||
conn, capital, _main_quote, trading_mode=mode, max_margin_pct=max_pct,
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.warning("positions recommend refresh failed: %s", exc)
|
||||
rec_cache = recommend_payload(conn, live_capital=capital, max_margin_pct=max_pct)
|
||||
if not rec_cache.get("rows") and capital > 0:
|
||||
try:
|
||||
from product_recommend import list_product_recommendations
|
||||
from recommend_store import enrich_recommend_rows, filter_affordable_recommendations
|
||||
|
||||
live_rows = filter_affordable_recommendations(
|
||||
list_product_recommendations(
|
||||
capital, _main_quote, max_margin_pct=max_pct, trading_mode=mode,
|
||||
)
|
||||
)
|
||||
if live_rows:
|
||||
rec_cache["rows"] = enrich_recommend_rows(
|
||||
live_rows, capital, max_margin_pct=max_pct,
|
||||
)
|
||||
rec_cache["updated_at"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
except Exception as exc:
|
||||
logger.warning("positions recommend live fallback failed: %s", exc)
|
||||
return render_template(
|
||||
"trade.html",
|
||||
trading_mode=mode,
|
||||
|
||||
Reference in New Issue
Block a user