Add industry filter to recommendations and fix verify button width.

Show category, turnover, and per-industry counts; clarify volume is in lots. Prevent trade-save button from stretching full column width.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-26 01:21:53 +08:00
parent e5f675c6ca
commit aad88a9e98
9 changed files with 184 additions and 14 deletions
+18 -1
View File
@@ -9,11 +9,23 @@ from typing import Callable, Optional
from contract_specs import get_contract_spec
from fee_specs import calc_fee_breakdown
from recommend_trend import analyze_product_daily, sort_recommend_by_trend
from symbols import PRODUCTS
from symbols import PRODUCTS, product_category
logger = logging.getLogger(__name__)
def _attach_turnover(row: dict) -> None:
"""成交额 = 昨日成交量(手) × 昨收 × 合约乘数。"""
try:
vol = float(row.get("volume") or 0)
price = float(row.get("prev_close") or row.get("price") or 0)
mult = float(row.get("mult") or 0)
except (TypeError, ValueError):
return
if vol > 0 and price > 0 and mult > 0:
row["turnover"] = round(vol * price * mult, 2)
def _letters_from_ths(ths_code: str) -> str:
import re
m = re.match(r"^([A-Za-z]+)", (ths_code or "").strip())
@@ -34,6 +46,7 @@ def assess_product_for_capital(
ths = product.get("ths") or ""
name = product.get("name") or ths
exchange = product.get("exchange") or ""
category = product.get("category") or product_category(ths)
spec = get_contract_spec(ths + "8888")
mult = spec["mult"]
margin_rate = spec["margin_rate"]
@@ -47,6 +60,7 @@ def assess_product_for_capital(
"ths": ths,
"name": name,
"exchange": exchange,
"category": category,
"status": "no_price",
"status_label": "暂无行情",
"min_capital_one_lot": None,
@@ -87,6 +101,7 @@ def assess_product_for_capital(
"ths": ths,
"name": name,
"exchange": exchange,
"category": category,
"price": round(p, 4),
"mult": mult,
"tick_size": tick,
@@ -129,6 +144,7 @@ def list_product_recommendations(
row["main_code"] = main_code
if main_code:
row.update(analyze_product_daily(main_code))
_attach_turnover(row)
return row
except Exception as exc:
logger.warning("recommend product failed %s: %s", ths, exc)
@@ -136,6 +152,7 @@ def list_product_recommendations(
"ths": ths,
"name": product.get("name") or ths,
"exchange": product.get("exchange") or "",
"category": product.get("category") or product_category(ths),
"status": "no_price",
"status_label": "计算失败",
"main_code": "",