Use 100k equity for recommend list when CTP is offline.
When SimNow or live CTP is disconnected, the tradable-products section shows four whitelisted symbols and calculates max lots from a fixed 100,000 capital instead of reference capital in settings. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+10
-4
@@ -92,6 +92,7 @@ from trading_context import (
|
||||
get_max_margin_pct,
|
||||
get_pending_order_timeout_min,
|
||||
get_pending_order_timeout_sec,
|
||||
get_recommend_capital,
|
||||
get_risk_percent,
|
||||
get_sizing_mode,
|
||||
get_trailing_be_tick_buffer,
|
||||
@@ -148,7 +149,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
|
||||
schedule_recommend_refresh(
|
||||
db_path=DB_PATH,
|
||||
get_capital_fn=_capital,
|
||||
get_capital_fn=_recommend_capital,
|
||||
quote_fn=_main_quote,
|
||||
init_tables_fn=lambda c: init_strategy_tables(c),
|
||||
get_mode_fn=lambda: get_trading_mode(get_setting),
|
||||
@@ -161,13 +162,16 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
mode = get_trading_mode(get_setting)
|
||||
return recommend_payload(
|
||||
conn,
|
||||
live_capital=_capital(conn),
|
||||
live_capital=_recommend_capital(conn),
|
||||
max_margin_pct=get_max_margin_pct(get_setting),
|
||||
trading_mode=mode,
|
||||
sizing_mode=get_sizing_mode(get_setting),
|
||||
fixed_lots=get_fixed_lots(get_setting),
|
||||
)
|
||||
|
||||
def _recommend_capital(conn) -> float:
|
||||
return get_recommend_capital(conn, get_setting)
|
||||
|
||||
def _settings_dict() -> dict:
|
||||
return {
|
||||
"trading_mode": get_trading_mode(get_setting),
|
||||
@@ -1613,6 +1617,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
mode = get_trading_mode(get_setting)
|
||||
ctp_st = ctp_status(mode)
|
||||
capital = _capital(conn)
|
||||
recommend_capital = _recommend_capital(conn)
|
||||
risk = get_risk_status(conn, active_count=_effective_active_position_count(conn, mode))
|
||||
ctp_acc = _ctp_account(mode) if ctp_st.get("connected") else {}
|
||||
active_trend = conn.execute(
|
||||
@@ -1636,6 +1641,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
trading_mode=mode,
|
||||
trading_mode_label=trading_mode_label(get_setting),
|
||||
capital=capital,
|
||||
recommend_capital=recommend_capital,
|
||||
risk_status=risk,
|
||||
ctp_status=ctp_st,
|
||||
ctp_account=ctp_acc,
|
||||
@@ -2459,7 +2465,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
conn = get_db()
|
||||
try:
|
||||
init_strategy_tables(conn)
|
||||
capital = _capital(conn)
|
||||
capital = _recommend_capital(conn)
|
||||
mode = get_trading_mode(get_setting)
|
||||
rows = refresh_recommend_cache(
|
||||
conn, capital, _main_quote, trading_mode=mode,
|
||||
@@ -2815,7 +2821,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
||||
|
||||
start_recommend_worker(
|
||||
db_path=DB_PATH,
|
||||
get_capital_fn=_capital,
|
||||
get_capital_fn=_recommend_capital,
|
||||
quote_fn=_main_quote,
|
||||
init_tables_fn=_init_tables,
|
||||
get_mode_fn=lambda: get_trading_mode(get_setting),
|
||||
|
||||
Reference in New Issue
Block a user