接入用户候选与选股计划添加入口
This commit is contained in:
parent
b798c1f38e
commit
bb044b7da7
|
|
@ -882,6 +882,7 @@ def eval_open(c: dict, params: dict, caps: dict, room_amt: float):
|
|||
"valuation_text": c.get("valuation_text"),
|
||||
# 催化事件与定价状态 (2026-09-08 量价研判链 3.5): 原值进账本与提议卡; 两句整句另送研判
|
||||
# (它们是事件与量价, 不是产业逻辑, 见 judge.OPEN_JUDGE_KEYS)。不参与任何判定。
|
||||
'user_candidate': c.get('user_candidate'), 'user_required': c.get('user_required'),
|
||||
"events": c.get("events"), "events_text": c.get("events_text"),
|
||||
"pricing_state": c.get("pricing_state"), "pricing_text": c.get("pricing_text"),
|
||||
# 相关快讯 (2026-09-08 台账 050): 原值进账本与提议卡, 整句另送研判。只是上下文, 不进判定。
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ def basis(row):
|
|||
result = {k: row.get(k) for k in ('score', 'tier', 'upside', 'heat', 'theme',
|
||||
'verdict', 'risk', 'missing', 'reasons', 'logic_state', 'company_gate',
|
||||
'company_review', 'company_review_text', 'events', 'pricing_state', 'news')}
|
||||
if row.get('user_candidate'):
|
||||
result.update(user_candidate=row['user_candidate'], user_required=bool(row.get('user_required')))
|
||||
if row.get('candidate_source') == 'dividend':
|
||||
result.update({k: row.get(k) for k in ('candidate_source', 'dividend_ref', 'dividend_policy_version')})
|
||||
# 资料年龄不是研究变化;固定报告引用和研究内容才是。
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ INFRA_PREFIX = ("PROXY_DB", "SOURCE_DB", "DB_MYSQL", "SIGNAL_REDIS", "PMS_REDIS"
|
|||
# 2026-09-03 补进会话票签名密钥 PMS_SESSION_SECRET: 它 2026-08 随登录一起加进 settings,
|
||||
# 当时漏了这份名单, 于是参数设置页把它当普通业务参数原文显示出来 (登录中间件读的是
|
||||
# settings, 功能没受影响, 但密钥不该出现在页面上)。
|
||||
SECRET_KEYS = ("PMS_QMT_SIGN_SEED_HEX", "PMS_QMT_PEER_PUBKEY_B64", "PMS_SESSION_SECRET")
|
||||
SECRET_KEYS = ("PMS_QMT_SIGN_SEED_HEX", "PMS_QMT_PEER_PUBKEY_B64", "PMS_SESSION_SECRET", "PMS_PLAN_WRITE_KEY")
|
||||
|
||||
# 运行态开关: key -> (默认值, 类型, 说明)
|
||||
RUNTIME_EXTRA = {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
"""选股计划的用户候选入口;只登记来源,不创建交易命令。"""
|
||||
import re
|
||||
|
||||
from app.services import param_store, plan_feed
|
||||
from config.settings import settings
|
||||
|
||||
|
||||
def request(method='GET', *, payload=None, identity=None, actor='user', query=None):
|
||||
import requests
|
||||
base = str(param_store.get('PMS_PLAN_API_BASE', '') or '').rstrip('/')
|
||||
if not base:
|
||||
raise ValueError('选股计划暂不可用,请稍后重试')
|
||||
secret = settings.PMS_PLAN_WRITE_KEY
|
||||
if method != 'GET' and not secret:
|
||||
raise ValueError('添加功能尚未启用,请联系管理员')
|
||||
path = '/plan/user-candidates'
|
||||
if query is not None:
|
||||
path += '/search'
|
||||
if identity is not None:
|
||||
if not re.fullmatch(r'[0-9a-f]{32}', str(identity)):
|
||||
raise ValueError('添加记录无效,请刷新后重试')
|
||||
path += '/' + identity + '/remove'
|
||||
body = {k: (payload or {}).get(k) for k in ('codes', 'reason', 'expires_on')}
|
||||
body['actor'] = actor
|
||||
try:
|
||||
response = requests.request(method, base + path,
|
||||
json=body if method != 'GET' else None,
|
||||
headers={'X-Job-Key': secret} if method != 'GET' else {},
|
||||
params={'q': str(query)[:40]} if query is not None else None,
|
||||
timeout=15, allow_redirects=False)
|
||||
except requests.RequestException as exc:
|
||||
raise ValueError('选股系统暂未回应,请刷新列表核对后再试') from None
|
||||
if response.status_code in (404, 405):
|
||||
raise ValueError('选股系统暂不支持添加,请联系管理员完成更新')
|
||||
if response.status_code in (401, 403, 503):
|
||||
raise ValueError('选股系统暂不能处理添加,请联系管理员检查连接')
|
||||
if response.status_code != 200:
|
||||
if response.status_code == 400:
|
||||
detail = response.json().get('detail')
|
||||
if isinstance(detail, str):
|
||||
raise ValueError(detail[:300])
|
||||
raise ValueError('操作未完成,请刷新列表核对后再试')
|
||||
try:
|
||||
result = response.json()
|
||||
except ValueError:
|
||||
raise ValueError('选股系统返回异常,请稍后重试') from None
|
||||
if not isinstance(result, dict) or result.get('ok') is not True:
|
||||
raise ValueError('操作未完成,请刷新列表核对后再试')
|
||||
if method != 'GET':
|
||||
plan_feed.invalidate()
|
||||
return dict(result, writable=bool(secret))
|
||||
|
|
@ -343,6 +343,8 @@ def _rows(raw, bucket: str) -> list:
|
|||
"research_rank": _int_or_none(it.get('research_rank')),
|
||||
"research": it.get('research') if isinstance(it.get('research'), dict) else None,
|
||||
"review_ref": _text_or_none(it.get('review_ref')),
|
||||
'user_candidate': it.get('user_candidate') if isinstance(it.get('user_candidate'), dict) else None,
|
||||
'user_required': bool(it.get('user_required')),
|
||||
})
|
||||
return out
|
||||
|
||||
|
|
@ -496,6 +498,9 @@ def select_candidates(plan: dict, *, held=(), black=(), top_n: int = 30, tiers=N
|
|||
规则闸按 PMS_SECTOR_MAX_NAMES 一拦就剩 4 只, 白瞎 26 个名额且**日志上看不出来**。
|
||||
在候选阶段先按主题摊开, top_n 切出来的才是能用的票。
|
||||
"""
|
||||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
today = datetime.now(ZoneInfo('Asia/Shanghai')).date().isoformat()
|
||||
held = {normalize_code(c) for c in (held or []) if c}
|
||||
black = {normalize_code(c) for c in (black or []) if c}
|
||||
tiers = {str(t).strip() for t in (tiers or []) if str(t).strip()}
|
||||
|
|
@ -541,6 +546,10 @@ def select_candidates(plan: dict, *, held=(), black=(), top_n: int = 30, tiers=N
|
|||
drop('dup', c)
|
||||
continue
|
||||
seen.add(c)
|
||||
if r.get('user_required') and str((r.get('user_candidate') or {}).get('expires_on') or '') < today:
|
||||
drop('display', c)
|
||||
display_only.append({'ts_code': c, 'basis': '用户关注已到期'})
|
||||
continue
|
||||
if c in held:
|
||||
drop('held', c)
|
||||
continue
|
||||
|
|
@ -609,7 +618,7 @@ def select_candidates(plan: dict, *, held=(), black=(), top_n: int = 30, tiers=N
|
|||
# 排序轴四键 (2026-09-17 工作包乙): 原样透传给动作引擎与提议卡, 缺就是 None。
|
||||
"quality_band": r.get("quality_band"), "pointed": r.get("pointed"),
|
||||
"rank_axis": r.get("rank_axis"), "rank_old": r.get("rank_old"),
|
||||
**{k: r.get(k) for k in ('research_rank', 'research', 'review_ref')}}
|
||||
**{k: r.get(k) for k in ('research_rank', 'research', 'review_ref', 'user_candidate', 'user_required')}}
|
||||
for r in passed[:n]]
|
||||
for i, item in enumerate(items, 1):
|
||||
item.update(selection_rank=i, decision=plan.get('decision'),
|
||||
|
|
@ -1191,6 +1200,8 @@ def candidates(*, held=(), black=(), route_by_verdict: bool = False, force=False
|
|||
p = _params()
|
||||
plan = plan_override if plan_override is not None else (get_plan(force=force) if force else get_plan())
|
||||
route = bool(route_by_verdict)
|
||||
if not route:
|
||||
plan = dict(plan, **{b: [r for r in plan.get(b, []) if not r.get('user_required')] for b in ('main', 'observe')})
|
||||
out = select_candidates(plan, held=held, black=black, top_n=0 if recheck_code else p["top_n"], tiers=p["tiers"],
|
||||
include_observe=p["include_observe"],
|
||||
min_score=(p["min_score"] or None),
|
||||
|
|
|
|||
|
|
@ -223,9 +223,10 @@ def scan_and_route(*, now=None, dry_run: bool = False) -> dict:
|
|||
# 候选池发布给择时决策系统 (2026-09-09, 台账 004): 它的盘中强势扫描拿这份当覆盖面,
|
||||
# 读不到就本轮不扫、绝不回退全市场。这里只写代码不写别的; 写失败只记日志, 不影响本轮。
|
||||
# 落点选在候选产出之后、分流之前: 发布的是"今天该盯哪几只", 与它们最后买没买无关。
|
||||
if not dry_run and open_cands:
|
||||
monitor_codes = {x.get('ts_code') for x in open_cands} | set(out.get('user_monitor_codes') or [])
|
||||
if not dry_run and monitor_codes:
|
||||
try:
|
||||
candidate_pub.publish([x.get("ts_code") for x in open_cands])
|
||||
candidate_pub.publish(monitor_codes)
|
||||
except Exception as e:
|
||||
logger.warning("[新建仓] 候选池发布失败 (不影响本轮): %s", e)
|
||||
|
||||
|
|
@ -373,6 +374,7 @@ def _scan_open(view, params, stock_params, skip, mkt, out, now=None,
|
|||
out["skipped"].append({"action": ae.A_OPEN, "why": _no_candidate_why(sel)})
|
||||
return []
|
||||
|
||||
out.setdefault('user_monitor_codes', []).extend(x['ts_code'] for x in items if x.get('user_candidate'))
|
||||
codes = [x["ts_code"] for x in items]
|
||||
prices = market.get_prices(codes)
|
||||
# 行业名一次批量取, 本轮复用。滚动扣减要算行业集中度, 所以必须先有它 ——
|
||||
|
|
@ -541,6 +543,10 @@ def _attach_consensus(cands, out=None, now=None) -> None:
|
|||
codes = [c.get("ts_code") for c in cands if c.get("ts_code")]
|
||||
nightly = consensus_service.nightly_map(codes)
|
||||
tech_states = consensus_service.state_map()
|
||||
missing_user = [r['ts_code'] for r in cands if r.get('user_candidate') and r['ts_code'] not in tech_states]
|
||||
if missing_user:
|
||||
from app.services import tech_service
|
||||
tech_states = dict(tech_states, **tech_service.read_states_for(missing_user))
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("[合议] 批量取数失败, 本轮候选不装配合议: %s", e)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -444,3 +444,18 @@ def status() -> dict:
|
|||
"states": len(m.get("states") or {}), "fresh": bool(state_map(m)),
|
||||
"note": m.get("note"), "error": m.get("error"), "stale": m.get("stale")}
|
||||
return out
|
||||
|
||||
|
||||
def read_states_for(codes):
|
||||
"""盘中新加入的股票读取已有日线,按原规则合成立场,不重算行情或改写整份映射。"""
|
||||
codes = list(dict.fromkeys(codes))
|
||||
if not codes or not enabled():
|
||||
return {}
|
||||
p = _params()
|
||||
dd = tech_repo.latest_date()
|
||||
if not dd or _tdays_elapsed(dd, tradedays.ymd()) > int(p['stale_tdays']):
|
||||
return {}
|
||||
since = tradedays.ymd(tradedays.prev_trade_day(dd, tech_rules.CHOPPY_WINDOW + 5))
|
||||
history = tech_repo.history_multi(codes, since=since)
|
||||
return {code: _compact(tech_rules.synthesize(rows, params=p['rules']))
|
||||
for code, rows in history.items() if rows and int(rows[-1].get('data_date') or 0) == dd}
|
||||
|
|
|
|||
|
|
@ -1014,6 +1014,33 @@ def api_strategy_attach_scan(dry_run: bool = Query(False)):
|
|||
params={"dry_run": dry_run})
|
||||
|
||||
|
||||
@app.get('/api/plan/user-candidates/search')
|
||||
def api_search_user_candidates(q: str = ''):
|
||||
from app.services import plan_candidates
|
||||
return ok(plan_candidates.request, query=q)
|
||||
|
||||
|
||||
@app.get('/api/plan/user-candidates')
|
||||
def api_user_candidates():
|
||||
from app.services import plan_candidates
|
||||
return ok(plan_candidates.request)
|
||||
|
||||
|
||||
@app.post('/api/plan/user-candidates')
|
||||
def api_add_user_candidates(request: Request, payload: dict = Body(...)):
|
||||
from app.services import plan_candidates
|
||||
return ok_logged('add_plan_candidates', plan_candidates.request, 'POST',
|
||||
payload=payload, actor=_actor(request), by=_actor(request),
|
||||
params={k: payload.get(k) for k in ('codes', 'reason', 'expires_on')})
|
||||
|
||||
|
||||
@app.post('/api/plan/user-candidates/{identity}/remove')
|
||||
def api_remove_user_candidate(identity: str, request: Request):
|
||||
from app.services import plan_candidates
|
||||
return ok_logged('remove_plan_candidate', plan_candidates.request, 'POST',
|
||||
identity=identity, actor=_actor(request), by=_actor(request), params={'id': identity})
|
||||
|
||||
|
||||
@app.get("/api/upstream/plan")
|
||||
def api_upstream_plan(limit: int = Query(30), date: str = Query(None),
|
||||
bucket: str = Query("main")):
|
||||
|
|
|
|||
|
|
@ -565,6 +565,16 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
|
|||
.research-source dl{display:grid;grid-template-columns:90px minmax(0,1fr);gap:8px 12px;margin:14px 0 0;}
|
||||
.research-source dt,.research-source dd{margin:0;overflow-wrap:anywhere;line-height:1.65;}
|
||||
.prop-badge{font-size:11px;font-family:ui-monospace,Menlo,monospace;background:var(--surface-2);padding:2px 7px;border-radius:5px;}
|
||||
|
||||
.plan-add-panel{margin:14px 0 18px;padding:18px;background:var(--surface-2);border:1px solid var(--hair);border-radius:10px}
|
||||
.plan-add-panel .el-form-item{margin-bottom:14px}.plan-add-panel .el-select{width:100%}
|
||||
.plan-user-list{margin:16px 0 20px;border:1px solid var(--hair);border-radius:10px;overflow:hidden}
|
||||
.plan-user-head{display:flex;align-items:center;justify-content:space-between;padding:11px 14px;background:var(--surface-2);font-weight:600}
|
||||
.plan-user-item{padding:12px 14px;border-top:1px solid var(--hair)}
|
||||
.plan-user-top{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.plan-user-top .el-button{margin-left:auto}
|
||||
.plan-user-note{margin-top:5px;font-size:12.5px;color:var(--ink-2);overflow-wrap:anywhere}
|
||||
.plan-add-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}
|
||||
@media(max-width:640px){.plan-add-panel{padding:14px}.plan-user-top{gap:6px}.plan-user-item{padding:10px}.plan-add-actions .el-button{flex:1}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -2546,9 +2556,10 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
|
|||
</el-drawer>
|
||||
|
||||
<!-- 上游选股计划抽屉 -->
|
||||
<el-drawer v-model="planDrawer" title="选股计划" size="56%">
|
||||
<el-drawer v-model="planDrawer" title="选股计划" size="min(880px, 100vw)">
|
||||
<div class="row" style="margin-bottom:8px">
|
||||
<el-button v-if="isAdmin" type="primary" :loading="planLoading" @click="refreshPlan">
|
||||
<el-button type="primary" @click="openPlanAdd">添加股票</el-button>
|
||||
<el-button v-if="isAdmin" :loading="planLoading" @click="refreshPlan">
|
||||
更新计划与行业映射</el-button>
|
||||
<el-button :loading="planLoading" @click="loadPlan">刷新显示</el-button>
|
||||
<span class="muted" style="margin-left:8px">
|
||||
|
|
@ -2560,6 +2571,50 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;}
|
|||
<el-alert v-if="planStatus.ok===false" type="error" effect="dark" show-icon :closable="false"
|
||||
:title="planStatus.hint || '不可用'" style="margin-bottom:8px"></el-alert>
|
||||
<div class="muted" v-else style="margin-bottom:8px">行情截至 {{ planStatus.date || '—' }}<template v-if="planFetchedText"> · {{ planFetchedText.replace('拉取','更新') }}</template></div>
|
||||
<div v-if="planUserError" class="plan-user-note" role="alert">{{ planUserError }}</div>
|
||||
<div v-if="planAddOpen" class="plan-add-panel">
|
||||
<div style="font-weight:600;margin-bottom:4px">添加关注股票</div>
|
||||
<div class="muted" style="margin-bottom:16px">添加后按现有规则评估,满足条件时按当前执行档位处理。</div>
|
||||
<el-form label-position="top" @submit.prevent="submitPlanAdd">
|
||||
<el-form-item label="股票">
|
||||
<el-select v-model="planAdd.codes" multiple filterable remote allow-create default-first-option
|
||||
:remote-method="searchPlanStocks" :loading="planSearchBusy" :reserve-keyword="false"
|
||||
placeholder="搜索名称或代码,也可输入代码后回车" :disabled="planUserBusy">
|
||||
<el-option v-for="r in planSearchRows" :key="r.code" :value="r.code" :label="r.name+' '+r.code"></el-option>
|
||||
</el-select>
|
||||
<div class="muted" style="margin-top:5px">仅支持沪深 A 股。批量代码可用空格或逗号分隔,每次最多 30 只。</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="添加理由">
|
||||
<el-input v-model="planAdd.reason" type="textarea" :rows="2" maxlength="300" show-word-limit
|
||||
placeholder="简要说明关注这几只股票的原因" :disabled="planUserBusy"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="关注截止日期">
|
||||
<el-date-picker v-model="planAdd.expires_on" type="date" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
|
||||
placeholder="选择日期" :disabled-date="planDateDisabled" :disabled="planUserBusy"></el-date-picker>
|
||||
<div class="muted" style="margin-top:5px">到期停止人工关注,已有持仓继续按原规则管理。</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="planAddError" class="plan-user-note" style="color:var(--stop)" role="alert">{{ planAddError }}</div>
|
||||
<div class="plan-add-actions">
|
||||
<el-button @click="planAddOpen=false" :disabled="planUserBusy">取消</el-button>
|
||||
<el-button type="primary" @click="submitPlanAdd" :loading="planUserBusy">添加到计划</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="planUserRows.length" class="plan-user-list">
|
||||
<div class="plan-user-head"><span>用户添加 <span class="muted">{{ planUserActiveCount }} 只关注中</span></span>
|
||||
<el-button link @click="planUserHistory=!planUserHistory">{{ planUserHistory ? '收起历史' : '查看历史' }}</el-button>
|
||||
</div>
|
||||
<div v-for="r in planUserShown" :key="r.id" class="plan-user-item">
|
||||
<div class="plan-user-top">
|
||||
<span style="font-weight:600">{{ r.name || r.code }}</span><span v-if="r.name" class="muted mono">{{ r.code }}</span>
|
||||
<span class="muted">{{ planUserState(r) }}</span>
|
||||
<el-button v-if="!r.removed_at && r.status!=='expired'" link type="danger" :disabled="planUserBusy" @click="removePlanUser(r)">移除关注</el-button>
|
||||
</div>
|
||||
<div class="plan-user-note">{{ r.reason }}</div>
|
||||
<div class="plan-user-note">{{ planUserDetail(r) }} <span class="muted">· 截至 {{ r.expires_on }}</span></div>
|
||||
</div>
|
||||
<div v-if="!planUserShown.length" class="plan-user-item muted">暂无关注中的股票</div>
|
||||
</div>
|
||||
<details class="rail-detail" style="margin-bottom:10px"><summary>数据来源与筛选记录</summary>
|
||||
<div class="muted" style="margin-bottom:8px">
|
||||
数据日 <b>{{ planStatus.date }}</b>(上游每个交易日早上用上一交易日收盘后的证据出计划,日龄 {{ planStatus.age_tdays }} 交易日<template
|
||||
|
|
@ -2852,6 +2907,62 @@ createApp({
|
|||
const planStatus = computed(() => planRaw.value.status || {});
|
||||
const planRows = computed(() => planRaw.value.rows || []);
|
||||
const planCand = computed(() => planRaw.value.candidates_raw || null);
|
||||
const planAddOpen = ref(false), planUserBusy = ref(false), planAddError = ref(''), planUserError = ref('');
|
||||
const planUserRows = ref([]), planUserHistory = ref(false), planUserWritable = ref(false);
|
||||
const planSearchRows = ref([]), planSearchBusy = ref(false);
|
||||
const planAdd = reactive({codes: [], reason: '', expires_on: ''});
|
||||
const planUserActiveCount = computed(() => planUserRows.value.filter(r => !r.removed_at && r.status!=='expired').length);
|
||||
const planUserShown = computed(() => planUserRows.value.filter(r => planUserHistory.value || (!r.removed_at && r.status!=='expired')));
|
||||
const planUserState = r => ({pending:'等待评估', evaluated:'已评估', expired:'已到期', removed:'已移除'}[r.status] || '待更新');
|
||||
const planUserDetail = r => r.status==='pending' ? '资料更新完成后进入评估' : r.status==='removed' ? '已停止人工关注' : r.status==='expired' ? '关注已到期' : (r.basis || '继续按现有候选条件筛选');
|
||||
const planDateDisabled = d => {
|
||||
const today = new Date(new Date().toLocaleString('en-US', {timeZone:'Asia/Shanghai'})); today.setHours(0,0,0,0);
|
||||
return d.getTime() < today.getTime() || d.getTime() > today.getTime()+90*86400000;
|
||||
};
|
||||
async function loadPlanUsers() {
|
||||
const d = await call('get', '/api/plan/user-candidates');
|
||||
if (d && d.ok) { planUserRows.value=d.rows||[]; planUserWritable.value=!!d.writable; planUserError.value=''; }
|
||||
else { planUserError.value=(d||{}).error||'添加记录暂不可用'; planUserWritable.value=false; }
|
||||
}
|
||||
async function openPlanAdd() {
|
||||
planAddError.value=''; planAddOpen.value=true;
|
||||
if (!planAdd.expires_on) { const d=new Date(Date.now()+7*86400000); planAdd.expires_on=new Intl.DateTimeFormat('en-CA',{timeZone:'Asia/Shanghai',year:'numeric',month:'2-digit',day:'2-digit'}).format(d); }
|
||||
await loadPlanUsers();
|
||||
if (!planUserWritable.value) planAddError.value=planUserError.value||'添加功能尚未启用,请联系管理员';
|
||||
}
|
||||
let planSearchSerial=0;
|
||||
async function searchPlanStocks(q) {
|
||||
const serial=++planSearchSerial;
|
||||
if (!q || !q.trim()) { planSearchRows.value=[]; planSearchBusy.value=false; return; }
|
||||
planSearchBusy.value=true;
|
||||
const d=await call('get','/api/plan/user-candidates/search?q='+encodeURIComponent(q.trim()));
|
||||
if(serial!==planSearchSerial)return;
|
||||
planSearchRows.value=(d&&d.ok)?(d.items||[]):[]; planSearchBusy.value=false;
|
||||
}
|
||||
async function submitPlanAdd() {
|
||||
if(planUserBusy.value)return;
|
||||
const codes=[...new Set(planAdd.codes.flatMap(x=>String(x).trim().split(/[\s,,;;]+/)).filter(Boolean))];
|
||||
if(!codes.length || codes.length>30){planAddError.value='请选择 1 至 30 只股票';return;}
|
||||
if(!planAdd.reason.trim()){planAddError.value='请填写添加理由';return;}
|
||||
if(!planAdd.expires_on){planAddError.value='请选择关注截止日期';return;}
|
||||
planUserBusy.value=true; planAddError.value='';
|
||||
try {
|
||||
const d=await call('post','/api/plan/user-candidates',{codes,reason:planAdd.reason.trim(),expires_on:planAdd.expires_on});
|
||||
if(!d||!d.ok){planAddError.value=(d||{}).error||'添加未完成,请刷新列表核对';return;}
|
||||
ElementPlus.ElMessage.success(d.added ? '已保存,等待更新评估' : '所选股票已在关注中');
|
||||
planAdd.codes=[];planAdd.reason='';planAddOpen.value=false;
|
||||
await loadPlanUsers();
|
||||
} finally {planUserBusy.value=false;}
|
||||
}
|
||||
async function removePlanUser(row) {
|
||||
if(planUserBusy.value)return;
|
||||
planUserBusy.value=true;
|
||||
try {
|
||||
const d=await call('post','/api/plan/user-candidates/'+row.id+'/remove');
|
||||
if(!d||!d.ok){planUserError.value=(d||{}).error||'移除未完成,请刷新后核对';return;}
|
||||
await loadPlanUsers();
|
||||
} finally {planUserBusy.value=false;}
|
||||
}
|
||||
// 计划拉取时刻 (2026-09-16): fetched_at 是持仓系统自己记的时间戳, 按浏览器本地时区显示, 不猜上游容器的时区。
|
||||
const planFetchedText = computed(() => {
|
||||
const ts = Number((planStatus.value || {}).fetched_at || 0); if (!ts) return '';
|
||||
|
|
@ -3131,6 +3242,7 @@ createApp({
|
|||
// 这些码同时是账本里的字面值, **只改显示不改值**。
|
||||
const OP_CN = {
|
||||
decide_proposal: '处理提议', cancel_command: '撤销这条命令',
|
||||
add_plan_candidates: '添加关注股票', remove_plan_candidate: '移除关注股票',
|
||||
cancel_instruction: '撤销一笔还没执行的下单', replan_command: '重新算这条命令的执行方案',
|
||||
resume_strategy_buy: '恢复这个方案的买入',
|
||||
macro_scan: '重算大盘信号(只算,不下单)', macro_adopt: '采纳今天的大盘建议',
|
||||
|
|
@ -4769,8 +4881,10 @@ createApp({
|
|||
}
|
||||
async function loadPlan() {
|
||||
planLoading.value = true;
|
||||
const users = loadPlanUsers();
|
||||
const d = await call('get', '/api/upstream/plan?limit=50');
|
||||
planRaw.value = (d && d.ok) ? d : { status: { ok: false, hint: (d||{}).error || '取数失败' } };
|
||||
await users;
|
||||
planLoading.value = false;
|
||||
}
|
||||
async function loadChanges() {
|
||||
|
|
@ -5132,6 +5246,9 @@ createApp({
|
|||
cancelCmd, replan, decide, decideDlg, decideCodes, submitDecide, ops, loadSchema, openReport, cancelIns, researchData, researchSections, researchMaterials, researchSource, openResearch,
|
||||
planDrawer, planLoading, planStatus, planFetchedText, planRows, planCand, planResult,
|
||||
loadPlan, openPlan, refreshPlan,
|
||||
planAddOpen, planUserBusy, planAddError, planUserError, planUserRows, planUserHistory,
|
||||
planUserShown, planUserActiveCount, planUserState, planUserDetail, planDateDisabled,
|
||||
planSearchRows, planSearchBusy, planAdd, openPlanAdd, searchPlanStocks, submitPlanAdd, removePlanUser,
|
||||
techStatus, techChipText, techChipCls,
|
||||
chgRaw, chgSt, chgLoading, chgTab, chg, chgHeld, chgLog, chgRevised, chgWatch,
|
||||
loadChanges,
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ class Settings(BaseSettings):
|
|||
# 若日后计划服务搬到别的机器, 这里直接填那台的 IP:端口。空=停用, 候选池恒为空。
|
||||
PMS_PLAN_API_BASE: str = "http://host.docker.internal:8300"
|
||||
PMS_PLAN_API_PATH: str = "/plan"
|
||||
PMS_PLAN_WRITE_KEY: str = "" # 仅环境注入;匹配桥侧写接口密钥,不进入参数中心。
|
||||
PMS_PLAN_TIMEOUT: int = 10 # 单次请求超时 (秒)
|
||||
PMS_PLAN_CACHE_SEC: int = 300 # 计划缓存秒数 (上游日频产出, 没必要每跳都拉)
|
||||
# 下面三个是**发给上游的请求参数** (对方 api.py: top=20/obs_top=10/theme_cap=5 都是
|
||||
|
|
|
|||
|
|
@ -759,6 +759,8 @@ def _():
|
|||
"/api/ops/reconcile", "/api/ops/daily-settle", "/api/ops/report",
|
||||
"/api/ops/downstream-schema", "/api/industry",
|
||||
"/api/upstream/plan", "/api/ops/plan-refresh",
|
||||
"/api/plan/user-candidates", "/api/plan/user-candidates/search",
|
||||
"/api/plan/user-candidates/{identity}/remove",
|
||||
"/api/upstream/signals/{ts_code}", # 2026-09-09 点股票看它今天全部信号
|
||||
"/api/tech/status", "/api/ops/tech-pull", # 2026-09-11 技术面状态与手动拉取
|
||||
"/api/research/{ts_code}", # 2026-09-11 单票研究面 (工作包一给技术面块)
|
||||
|
|
|
|||
Loading…
Reference in New Issue