Fix missing recommend_payload import; raise small-account cap to 200k.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+11
-2
@@ -28,7 +28,16 @@ from position_sizing import (
|
|||||||
calc_order_tick_metrics,
|
calc_order_tick_metrics,
|
||||||
normalize_sizing_mode,
|
normalize_sizing_mode,
|
||||||
)
|
)
|
||||||
from product_recommend import assert_product_allowed_for_capital, is_small_account, SMALL_ACCOUNT_SCOPE_LABEL
|
from product_recommend import (
|
||||||
|
assert_product_allowed_for_capital,
|
||||||
|
is_small_account,
|
||||||
|
small_account_scope_hint,
|
||||||
|
SMALL_ACCOUNT_SCOPE_LABEL,
|
||||||
|
)
|
||||||
|
from recommend_store import (
|
||||||
|
recommend_payload,
|
||||||
|
refresh_recommend_cache,
|
||||||
|
)
|
||||||
from recommend_stream import recommend_hub, schedule_recommend_refresh, start_recommend_worker
|
from recommend_stream import recommend_hub, schedule_recommend_refresh, start_recommend_worker
|
||||||
from position_stream import position_hub, start_position_worker
|
from position_stream import position_hub, start_position_worker
|
||||||
from ctp_settings import is_ctp_auto_connect_enabled
|
from ctp_settings import is_ctp_auto_connect_enabled
|
||||||
@@ -1643,7 +1652,7 @@ def install_trading(app, *, login_required, require_nav, get_db, get_setting, se
|
|||||||
recommend_updated_at=rec_cache.get("updated_at"),
|
recommend_updated_at=rec_cache.get("updated_at"),
|
||||||
night_session=is_night_trading_session(),
|
night_session=is_night_trading_session(),
|
||||||
small_account_scope=is_small_account(capital),
|
small_account_scope=is_small_account(capital),
|
||||||
small_account_scope_label=SMALL_ACCOUNT_SCOPE_LABEL,
|
small_account_scope_hint=small_account_scope_hint(),
|
||||||
product_categories=PRODUCT_CATEGORIES,
|
product_categories=PRODUCT_CATEGORIES,
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
+15
-4
@@ -18,12 +18,22 @@ from symbols import PRODUCTS, product_category, product_has_night_session
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# 权益低于该值时,仅允许下列品种(可开仓列表、品种下拉、开仓报单)
|
# 权益不超过该值时,仅允许下列品种(可开仓列表、品种下拉、开仓报单)
|
||||||
SMALL_ACCOUNT_CAPITAL_MAX = 100_000.0
|
SMALL_ACCOUNT_CAPITAL_MAX = 200_000.0
|
||||||
SMALL_ACCOUNT_PRODUCT_THS = frozenset({"c", "m", "MA", "rb"})
|
SMALL_ACCOUNT_PRODUCT_THS = frozenset({"c", "m", "MA", "rb"})
|
||||||
SMALL_ACCOUNT_SCOPE_LABEL = "玉米、豆粕、甲醇、螺纹钢"
|
SMALL_ACCOUNT_SCOPE_LABEL = "玉米、豆粕、甲醇、螺纹钢"
|
||||||
|
|
||||||
|
|
||||||
|
def small_account_scope_hint() -> str:
|
||||||
|
wan = int(SMALL_ACCOUNT_CAPITAL_MAX // 10_000)
|
||||||
|
return f"权益 {wan} 万以下仅显示并可交易:{SMALL_ACCOUNT_SCOPE_LABEL}"
|
||||||
|
|
||||||
|
|
||||||
|
def small_account_scope_status_label() -> str:
|
||||||
|
wan = int(SMALL_ACCOUNT_CAPITAL_MAX // 10_000)
|
||||||
|
return f"权益{wan}万以下限{SMALL_ACCOUNT_SCOPE_LABEL}"
|
||||||
|
|
||||||
|
|
||||||
def normalize_product_ths(ths: str) -> str:
|
def normalize_product_ths(ths: str) -> str:
|
||||||
import re
|
import re
|
||||||
s = (ths or "").strip()
|
s = (ths or "").strip()
|
||||||
@@ -56,7 +66,8 @@ def assert_product_allowed_for_capital(ths: str, capital: float) -> Optional[str
|
|||||||
return None
|
return None
|
||||||
if product_in_small_account_whitelist(ths):
|
if product_in_small_account_whitelist(ths):
|
||||||
return None
|
return None
|
||||||
return f"权益 10 万以下仅可交易:{SMALL_ACCOUNT_SCOPE_LABEL}"
|
wan = int(SMALL_ACCOUNT_CAPITAL_MAX // 10_000)
|
||||||
|
return f"权益 {wan} 万以下仅可交易:{SMALL_ACCOUNT_SCOPE_LABEL}"
|
||||||
|
|
||||||
|
|
||||||
def filter_products_for_capital(products: list[dict], capital: float) -> list[dict]:
|
def filter_products_for_capital(products: list[dict], capital: float) -> list[dict]:
|
||||||
@@ -115,7 +126,7 @@ def assess_product_for_capital(
|
|||||||
"mult": spec["mult"],
|
"mult": spec["mult"],
|
||||||
"tick_size": tick,
|
"tick_size": tick,
|
||||||
"status": "blocked",
|
"status": "blocked",
|
||||||
"status_label": f"10万以下限{SMALL_ACCOUNT_SCOPE_LABEL}",
|
"status_label": small_account_scope_status_label(),
|
||||||
"min_capital_one_lot": None,
|
"min_capital_one_lot": None,
|
||||||
"margin_one_lot": None,
|
"margin_one_lot": None,
|
||||||
"max_lots": 0,
|
"max_lots": 0,
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
"""Fix recommend_payload import and deploy 200k scope."""
|
||||||
|
import paramiko, sys
|
||||||
|
from pathlib import Path
|
||||||
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||||||
|
root = Path(__file__).resolve().parents[1]
|
||||||
|
files = ["product_recommend.py", "install_trading.py", "templates/trade.html"]
|
||||||
|
c = paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
c.connect("192.168.8.21", username="root", password="woaini88", timeout=15)
|
||||||
|
sftp = c.open_sftp()
|
||||||
|
for rel in files:
|
||||||
|
sftp.put(str(root / rel), f"/opt/qihuo/{rel.replace(chr(92), '/')}")
|
||||||
|
print("uploaded", rel)
|
||||||
|
sftp.close()
|
||||||
|
_, o, e = c.exec_command("cd /opt/qihuo && pm2 restart qihuo && sleep 2 && /opt/qihuo/venv/bin/python -c \"from recommend_store import recommend_payload; from install_trading import install_trading; print('import ok')\"")
|
||||||
|
print(o.read().decode("utf-8", errors="replace"))
|
||||||
|
print(e.read().decode("utf-8", errors="replace"))
|
||||||
|
_, o, e = c.exec_command("curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:6600/login")
|
||||||
|
print("login status", o.read().decode())
|
||||||
|
c.close()
|
||||||
@@ -133,7 +133,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="hint">最大手数 = floor(权益 × 保证金上限 <strong>{{ max_margin_pct }}%</strong> ÷ 1手保证金);当前权益 <strong class="text-accent" id="rec-capital">{{ '%.2f'|format(capital) }}</strong> 元。
|
<p class="hint">最大手数 = floor(权益 × 保证金上限 <strong>{{ max_margin_pct }}%</strong> ÷ 1手保证金);当前权益 <strong class="text-accent" id="rec-capital">{{ '%.2f'|format(capital) }}</strong> 元。
|
||||||
{% if sizing_mode == 'fixed' %}仅显示最大手数 ≥ <strong>{{ fixed_lots }}</strong> 手的品种。{% endif %}
|
{% if sizing_mode == 'fixed' %}仅显示最大手数 ≥ <strong>{{ fixed_lots }}</strong> 手的品种。{% endif %}
|
||||||
{% if small_account_scope %}<span class="text-muted">权益 10 万以下仅显示并可交易:{{ small_account_scope_label }}。</span>{% endif %}
|
{% if small_account_scope %}<span class="text-muted">{{ small_account_scope_hint }}。</span>{% endif %}
|
||||||
{% if night_session %}<span class="text-muted">当前为夜盘时段,品种下拉与下表仅显示有夜盘品种;带「夜盘」标记。</span>{% elif not small_account_scope %}<span class="text-muted">有夜盘交易的品种带「夜盘」标记。</span>{% endif %}
|
{% if night_session %}<span class="text-muted">当前为夜盘时段,品种下拉与下表仅显示有夜盘品种;带「夜盘」标记。</span>{% elif not small_account_scope %}<span class="text-muted">有夜盘交易的品种带「夜盘」标记。</span>{% endif %}
|
||||||
保证金优先读取 CTP 柜台合约信息。
|
保证金优先读取 CTP 柜台合约信息。
|
||||||
{% if recommend_updated_at %}<span class="text-muted">每日后台更新 · 最近 {{ recommend_updated_at }}</span>{% else %}<span class="text-muted" id="rec-updated">等待今日后台刷新…</span>{% endif %}
|
{% if recommend_updated_at %}<span class="text-muted">每日后台更新 · 最近 {{ recommend_updated_at }}</span>{% else %}<span class="text-muted" id="rec-updated">等待今日后台刷新…</span>{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user