Limit tradable products to four varieties for accounts at or below 100k.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+12
-2
@@ -461,20 +461,25 @@ def _match_score(product: dict, q_lower: str) -> int:
|
||||
return 10
|
||||
|
||||
|
||||
def search_symbols(query: str) -> list:
|
||||
def search_symbols(query: str, *, capital: float | None = None) -> list:
|
||||
q = query.strip()
|
||||
if not q:
|
||||
return []
|
||||
|
||||
q_lower = q.lower()
|
||||
from market_sessions import is_night_trading_session
|
||||
from product_recommend import filter_products_for_capital, is_small_account
|
||||
|
||||
night_only = is_night_trading_session()
|
||||
product_pool = PRODUCTS
|
||||
if capital is not None and is_small_account(capital):
|
||||
product_pool = filter_products_for_capital(PRODUCTS, capital)
|
||||
with _main_index_lock:
|
||||
index = dict(_main_index)
|
||||
index_ready = bool(index)
|
||||
|
||||
scored: list[tuple[int, dict]] = []
|
||||
for p in PRODUCTS:
|
||||
for p in product_pool:
|
||||
if night_only and not product_has_night_session(p):
|
||||
continue
|
||||
if not _product_matches(p, q_lower):
|
||||
@@ -492,6 +497,11 @@ def search_symbols(query: str) -> list:
|
||||
if not results and len(q) >= 3:
|
||||
codes = ths_to_codes(q)
|
||||
if codes:
|
||||
product = _product_for_contract_code(codes["ths_code"])
|
||||
if capital is not None and is_small_account(capital):
|
||||
from product_recommend import is_small_account, product_in_small_account_whitelist
|
||||
if not product or not product_in_small_account_whitelist(product):
|
||||
return results
|
||||
raw = fetch_raw_for_volume(codes["sina_code"])
|
||||
name = raw["name"] if raw else q
|
||||
results.append(_enrich_item({
|
||||
|
||||
Reference in New Issue
Block a user