Apply 200k scope when CTP offline; trailing breakeven order UX.
When SimNow or live CTP is disconnected, default to the four-product whitelist regardless of reference capital. Trailing breakeven defaults off; when enabled hide take-profit and risk-reward, monitor exits via trailing stop only. Document both behaviors in TRADING.md and FEATURES.md. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+23
-2
@@ -14,7 +14,11 @@ from typing import Callable, Optional
|
||||
|
||||
from contract_specs import get_contract_spec
|
||||
from fee_specs import ensure_fee_rates_schema
|
||||
from product_recommend import _attach_turnover, list_product_recommendations
|
||||
from product_recommend import (
|
||||
_attach_turnover,
|
||||
filter_rows_for_account_scope,
|
||||
list_product_recommendations,
|
||||
)
|
||||
from recommend_trend import sort_recommend_by_trend
|
||||
from symbols import product_category
|
||||
|
||||
@@ -104,6 +108,15 @@ def recommend_cache_needs_refresh(
|
||||
return False
|
||||
|
||||
|
||||
def _ctp_connected_for_mode(trading_mode: str) -> bool:
|
||||
try:
|
||||
from vnpy_bridge import ctp_status
|
||||
|
||||
return bool(ctp_status(trading_mode).get("connected"))
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def enrich_recommend_rows(
|
||||
rows: list[dict],
|
||||
capital: float,
|
||||
@@ -213,8 +226,13 @@ def refresh_recommend_cache(
|
||||
"""后台拉行情、筛选并写入数据库。"""
|
||||
ensure_recommend_tables(conn)
|
||||
ensure_fee_rates_schema(conn)
|
||||
ctp_connected = _ctp_connected_for_mode(trading_mode)
|
||||
all_rows = list_product_recommendations(
|
||||
capital, quote_fn, max_margin_pct=max_margin_pct, trading_mode=trading_mode,
|
||||
capital,
|
||||
quote_fn,
|
||||
max_margin_pct=max_margin_pct,
|
||||
trading_mode=trading_mode,
|
||||
ctp_connected=ctp_connected,
|
||||
)
|
||||
rows = filter_affordable_recommendations(all_rows)
|
||||
if not rows and float(capital or 0) > 0:
|
||||
@@ -289,6 +307,9 @@ def recommend_payload(
|
||||
rows = enrich_recommend_rows(
|
||||
rows, cap, max_margin_pct=pct, trading_mode=trading_mode,
|
||||
)
|
||||
rows = filter_rows_for_account_scope(
|
||||
rows, cap, ctp_connected=_ctp_connected_for_mode(trading_mode),
|
||||
)
|
||||
rows = filter_recommend_by_sizing(rows, sizing_mode=sizing_mode, fixed_lots=fixed_lots)
|
||||
rows = sort_recommend_by_trend(rows)
|
||||
payload["rows"] = rows
|
||||
|
||||
Reference in New Issue
Block a user