mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 14:34:18 +08:00
release: v1.29.0 — 借鉴社区 Fork 六项特性:ZIG 策略 + 交易时段感知刷新 + 120M K 线 + 逐 bar 衍生字段 + 159 龙头池 + 多 Provider LLM 直连
- ZIG 右侧突破回补策略:MyTT 新增 ZIG 之字转向(未来函数,含前视偏差警示); 波谷启动建仓挂硬止损(OCO)→ 见顶清仓记前高 → 右侧突破回补;路径依赖不实现 entry_exit_masks(向量化守护测试白名单);含寻优预设网格与 --strategy-file 独立文件 - 交易时段感知刷新:realtime/session.py(09:15~11:30:30 / 13:00~15:05)+ GET /market/session;看板 30/60/120s 轮询休市自动暂停(三态状态栏 + 开关持久化 + 手动刷新不受限);SSE/WS 既有会话语义不动 - 120 分钟 K 线:/bars?category=MIN_120(MAC 原生 Period.MINS×120 优先, 2×60M 相邻聚合兜底,标准客户端上限 400 根);前端周期选择器同步 - 逐 bar 衍生字段:/bars 与 /bars/index 附带 pre_close/change/change_pct/ amplitude_pct(pre_close≤0.01 兜底防除零) - 159 只核心龙头池:数据资产取自 Fork(东财全行业龙头名单,四组分层); universe=core 接入 screen scan / SignalScanner / StrengthRanker / market strength; GET /market/core-leaders + WebUI「龙头池」页(搜索/个股详情) - 多 Provider LLM 直连:easy_tdx.ai + /llm/*(DeepSeek/通义/智谱/Kimi/MiniMax/ OpenAI/Claude/Ollama/自定义,openai 兼容 + anthropic 原生双协议); 配置落盘 ~/.easy_tdx/llm.json(WebUI「AI 设置」页 ⇆ 手工编辑双向兼容, 文件>环境变量>预设;key 脱敏回显/CLEAR 清除);「AI 解读」后台任务化 (复用 task_runner,提交+轮询,不占 HTTP 连接);思考型模型空白正文防御 (reasoning_content 耗尽 max_tokens → 可操作报错;默认 16000); AI 解读历史页(自动归档 Prompt/正文/策略上下文 + 去回测带参引导) - WebUI 加固:SPA fallback 对未知 /api/* 返回 JSON 404(不再 200 HTML 伪装解析错); index.html 一律 Cache-Control: no-store(防缓存旧资源引用);路由兜底重定向; 全局风险提示常驻底栏 + 龙头池/AI 解读针对性免责声明 - 测试:新增 9 个单测文件共 59 例;黄金基线仅新增 zig_breakout 条目(其余零漂移); 全量 1448 例通过
This commit is contained in:
+55
-29
@@ -17,43 +17,69 @@ const sseLabel: Record<string, string> = {
|
||||
|
||||
<template>
|
||||
<div class="app">
|
||||
<aside class="sidebar">
|
||||
<div class="brand">
|
||||
<span class="brand-name">easy-tdx</span>
|
||||
<span class="brand-sub">行情终端</span>
|
||||
</div>
|
||||
<nav class="side-nav">
|
||||
<div class="nav-group">行情</div>
|
||||
<RouterLink to="/" exact-active-class="active">市场看板</RouterLink>
|
||||
<RouterLink to="/watchlist" active-class="active">自选行情</RouterLink>
|
||||
<div class="nav-group">分析</div>
|
||||
<RouterLink to="/backtest" active-class="active">单标的回测</RouterLink>
|
||||
<RouterLink to="/portfolio" active-class="active">组合回测</RouterLink>
|
||||
<RouterLink to="/optimize" active-class="active">参数寻优</RouterLink>
|
||||
<RouterLink to="/compare" active-class="active">结果对比</RouterLink>
|
||||
<RouterLink to="/strategies" active-class="active">策略库</RouterLink>
|
||||
<RouterLink to="/signals" active-class="active">信号雷达</RouterLink>
|
||||
<div class="nav-group">系统</div>
|
||||
<RouterLink to="/settings" active-class="active">服务器设置</RouterLink>
|
||||
</nav>
|
||||
<div class="side-footer">
|
||||
<span class="dot" :class="quoteStore.status"></span>
|
||||
<span class="sse-label">{{ sseLabel[quoteStore.status] ?? '离线' }}</span>
|
||||
<span v-if="quoteStore.lastTs" class="sse-ts">{{ quoteStore.lastTs.slice(11, 19) }}</span>
|
||||
<span v-if="quoteStore.quoteCount" class="sse-n">×{{ quoteStore.quoteCount }}</span>
|
||||
</div>
|
||||
</aside>
|
||||
<main class="app-main">
|
||||
<RouterView />
|
||||
</main>
|
||||
<div class="app-row">
|
||||
<aside class="sidebar">
|
||||
<div class="brand">
|
||||
<span class="brand-name">easy-tdx</span>
|
||||
<span class="brand-sub">行情终端</span>
|
||||
</div>
|
||||
<nav class="side-nav">
|
||||
<div class="nav-group">行情</div>
|
||||
<RouterLink to="/" exact-active-class="active">市场看板</RouterLink>
|
||||
<RouterLink to="/watchlist" active-class="active">自选行情</RouterLink>
|
||||
<RouterLink to="/leaders" active-class="active">龙头池</RouterLink>
|
||||
<div class="nav-group">分析</div>
|
||||
<RouterLink to="/backtest" active-class="active">单标的回测</RouterLink>
|
||||
<RouterLink to="/portfolio" active-class="active">组合回测</RouterLink>
|
||||
<RouterLink to="/optimize" active-class="active">参数寻优</RouterLink>
|
||||
<RouterLink to="/compare" active-class="active">结果对比</RouterLink>
|
||||
<RouterLink to="/strategies" active-class="active">策略库</RouterLink>
|
||||
<RouterLink to="/signals" active-class="active">信号雷达</RouterLink>
|
||||
<RouterLink to="/ai-history" active-class="active">AI 解读历史</RouterLink>
|
||||
<div class="nav-group">系统</div>
|
||||
<RouterLink to="/settings" active-class="active">服务器设置</RouterLink>
|
||||
<RouterLink to="/llm" active-class="active">AI 设置</RouterLink>
|
||||
</nav>
|
||||
<div class="side-footer">
|
||||
<span class="dot" :class="quoteStore.status"></span>
|
||||
<span class="sse-label">{{ sseLabel[quoteStore.status] ?? '离线' }}</span>
|
||||
<span v-if="quoteStore.lastTs" class="sse-ts">{{ quoteStore.lastTs.slice(11, 19) }}</span>
|
||||
<span v-if="quoteStore.quoteCount" class="sse-n">×{{ quoteStore.quoteCount }}</span>
|
||||
</div>
|
||||
</aside>
|
||||
<main class="app-main">
|
||||
<RouterView />
|
||||
</main>
|
||||
</div>
|
||||
<!-- 全局风险提示:所有页面常驻(行情/回测/个股相关内容均在此覆盖范围) -->
|
||||
<footer class="global-disclaimer">
|
||||
本工具输出(行情数据 / 指标 / 回测 / 选股扫描 / AI 解读)仅供量化研究与学习,
|
||||
不构成任何投资建议或个股推荐;历史表现不代表未来,股市有风险,据此操作风险自负。
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
}
|
||||
.app-row {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
}
|
||||
.global-disclaimer {
|
||||
flex-shrink: 0;
|
||||
padding: 5px 16px;
|
||||
background: var(--bg-panel);
|
||||
border-top: 1px solid var(--border);
|
||||
font-size: 10.5px;
|
||||
color: var(--text-dim);
|
||||
text-align: center;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.sidebar {
|
||||
width: 176px;
|
||||
flex-shrink: 0;
|
||||
|
||||
@@ -55,6 +55,7 @@ const CATEGORY_LABELS: Record<Category, string> = {
|
||||
MIN_15: '15 分钟',
|
||||
MIN_30: '30 分钟',
|
||||
MIN_60: '60 分钟',
|
||||
MIN_120: '120 分钟',
|
||||
}
|
||||
|
||||
const EXECUTION_LABELS: Record<ExecutionMode, string> = {
|
||||
|
||||
@@ -8,7 +8,15 @@ import type {
|
||||
Bar,
|
||||
BoardRow,
|
||||
Category,
|
||||
CoreLeaderRow,
|
||||
DataFrameResponse,
|
||||
LlmChatResponse,
|
||||
LlmChatContext,
|
||||
LlmHistoryResponse,
|
||||
LlmConfigResponse,
|
||||
LlmConfigUpdate,
|
||||
LlmTestResult,
|
||||
MarketSessionInfo,
|
||||
MarketStat,
|
||||
MinutePoint,
|
||||
MultiStrategyBacktestRequest,
|
||||
@@ -604,3 +612,137 @@ export async function removeWatchItem(market: string, code: string): Promise<voi
|
||||
const resp = await fetch(`${BASE}/watchlist/${market}/${code}`, { method: 'DELETE' })
|
||||
if (!resp.ok) await throwError(resp)
|
||||
}
|
||||
|
||||
// ── 交易时段(Dashboard 自动刷新门控) ──────────────────────────────────────
|
||||
|
||||
/** 服务器侧交易时段判断(前端本地判断为主,本接口用于校准展示)。 */
|
||||
export async function fetchMarketSession(): Promise<MarketSessionInfo> {
|
||||
const resp = await fetch(`${BASE}/market/session`)
|
||||
if (!resp.ok) await throwError(resp)
|
||||
return (await resp.json()) as MarketSessionInfo
|
||||
}
|
||||
|
||||
// ── LLM 配置与对话(AI 设置页 / AI 解读直连) ───────────────────────────────
|
||||
|
||||
/** 当前 LLM 配置(key 脱敏)+ Provider 预设表。 */
|
||||
export async function fetchLlmConfig(): Promise<LlmConfigResponse> {
|
||||
const resp = await fetch(`${BASE}/llm/config`)
|
||||
if (!resp.ok) await throwError(resp)
|
||||
return (await resp.json()) as LlmConfigResponse
|
||||
}
|
||||
|
||||
/** 保存 LLM 配置(写入 ~/.easy_tdx/llm.json,与手工编辑同一份文件)。 */
|
||||
export async function saveLlmConfig(req: LlmConfigUpdate): Promise<LlmConfigResponse> {
|
||||
const resp = await fetch(`${BASE}/llm/config`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(req),
|
||||
})
|
||||
if (!resp.ok) await throwError(resp)
|
||||
await resp.json() // 丢弃 PUT 响应体,统一以 GET 回读为准(providers/missing 同步刷新)
|
||||
return fetchLlmConfig()
|
||||
}
|
||||
|
||||
/** 连通性测试(用已保存配置或请求体临时配置发一句 ping)。 */
|
||||
export async function testLlm(override?: LlmConfigUpdate): Promise<LlmTestResult> {
|
||||
const resp = await fetch(`${BASE}/llm/test`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(override ?? null),
|
||||
})
|
||||
if (!resp.ok) await throwError(resp)
|
||||
return (await resp.json()) as LlmTestResult
|
||||
}
|
||||
|
||||
/** 一轮 LLM 对话(如把 AI 解读 Prompt 直接发给已配置的模型)。 */
|
||||
export async function chatLlm(
|
||||
prompt: string,
|
||||
systemPrompt?: string | null,
|
||||
): Promise<LlmChatResponse> {
|
||||
const resp = await fetch(`${BASE}/llm/chat`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ prompt, system_prompt: systemPrompt ?? null }),
|
||||
})
|
||||
if (!resp.ok) await throwError(resp)
|
||||
return (await resp.json()) as LlmChatResponse
|
||||
}
|
||||
|
||||
/** 提交 AI 解读后台任务(长耗时模型调用不占 HTTP 连接),返回 task_id。 */
|
||||
export async function submitLlmChatTask(
|
||||
prompt: string,
|
||||
context?: LlmChatContext | null,
|
||||
systemPrompt?: string | null,
|
||||
): Promise<TaskSubmitResponse> {
|
||||
const resp = await fetch(`${BASE}/llm/chat/async`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ prompt, system_prompt: systemPrompt ?? null, context: context ?? null }),
|
||||
})
|
||||
if (!resp.ok) await throwError(resp)
|
||||
return (await resp.json()) as TaskSubmitResponse
|
||||
}
|
||||
|
||||
/** 查询 AI 解读任务状态(轮询用)。 */
|
||||
export async function fetchLlmChatTask(taskId: string): Promise<TaskState> {
|
||||
const resp = await fetch(`${BASE}/llm/chat/tasks/${taskId}`)
|
||||
if (!resp.ok) await throwError(resp)
|
||||
return (await resp.json()) as TaskState
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交 AI 解读并轮询直到 done/failed。
|
||||
*
|
||||
* 大报告解读 1-3 分钟属正常:轮询间隔放宽到 1.5s(回测是 0.3s),
|
||||
* 前端上限 20 分钟兜底(后端 LLM 读超时最大 600s,正常应先于此前返回)。
|
||||
*/
|
||||
export async function runLlmChatWithPolling(
|
||||
prompt: string,
|
||||
context?: LlmChatContext | null,
|
||||
onPoll?: (state: TaskState) => void,
|
||||
intervalMs = 1_500,
|
||||
timeoutMs = 20 * 60_000,
|
||||
): Promise<TaskState> {
|
||||
const { task_id } = await submitLlmChatTask(prompt, context)
|
||||
const start = Date.now()
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
const state = await fetchLlmChatTask(task_id)
|
||||
onPoll?.(state)
|
||||
if (state.status === 'done' || state.status === 'failed') return state
|
||||
if (Date.now() - start > timeoutMs) {
|
||||
throw new Error(`AI 解读任务超时(${timeoutMs / 1000}s),任务仍在后台运行,可稍后重试`)
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, intervalMs))
|
||||
}
|
||||
}
|
||||
|
||||
// ── AI 解读历史 ──────────────────────────────────────────────────────────────
|
||||
|
||||
/** 列出 AI 解读历史(时间倒序,含 Prompt/正文/策略上下文)。 */
|
||||
export async function fetchLlmHistory(limit = 50): Promise<LlmHistoryResponse> {
|
||||
const resp = await fetch(`${BASE}/llm/history?limit=${limit}`)
|
||||
if (!resp.ok) await throwError(resp)
|
||||
return (await resp.json()) as LlmHistoryResponse
|
||||
}
|
||||
|
||||
/** 删除一条历史记录。 */
|
||||
export async function deleteLlmHistory(id: number): Promise<void> {
|
||||
const resp = await fetch(`${BASE}/llm/history/${id}`, { method: 'DELETE' })
|
||||
if (!resp.ok) await throwError(resp)
|
||||
}
|
||||
|
||||
/** 清空全部历史。 */
|
||||
export async function clearLlmHistory(): Promise<number> {
|
||||
const resp = await fetch(`${BASE}/llm/history`, { method: 'DELETE' })
|
||||
if (!resp.ok) await throwError(resp)
|
||||
return (await resp.json()).deleted as number
|
||||
}
|
||||
|
||||
/** 核心龙头池(159 只)。 */
|
||||
export async function fetchCoreLeaders(): Promise<CoreLeaderRow[]> {
|
||||
const resp = await fetch(`${BASE}/market/core-leaders`)
|
||||
if (!resp.ok) await throwError(resp)
|
||||
const body = (await resp.json()) as DataFrameResponse
|
||||
return body.data as unknown as CoreLeaderRow[]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
// 风险提示组件:prominent=true 用于语义重点页(龙头池/AI 解读历史等),
|
||||
// 默认紧凑样式。文案可通过默认插槽整体替换。
|
||||
withDefaults(defineProps<{ prominent?: boolean }>(), { prominent: false })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="prominent" class="risk prominent">
|
||||
<slot>
|
||||
<strong>⚠ 风险提示</strong>
|
||||
<p>
|
||||
本工具提供的全部行情数据、指标计算、回测与扫描结果仅供量化研究与学习,
|
||||
不构成任何投资建议、个股推荐或收益承诺。历史表现不代表未来,数据可能存在
|
||||
缺失或错误。股市有风险,入市需谨慎,据此操作风险自负。
|
||||
</p>
|
||||
</slot>
|
||||
</div>
|
||||
<div v-else class="risk">
|
||||
<slot>
|
||||
仅供研究学习,不构成投资建议;股市有风险,据此操作风险自负。
|
||||
</slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.risk {
|
||||
font-size: 11px;
|
||||
color: var(--text-dim);
|
||||
line-height: 1.6;
|
||||
border-top: 1px solid var(--border);
|
||||
padding-top: 6px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.risk.prominent {
|
||||
background: rgba(255, 193, 7, 0.07);
|
||||
border: 1px solid rgba(255, 193, 7, 0.35);
|
||||
border-radius: var(--radius);
|
||||
padding: 10px 12px;
|
||||
margin-top: 0;
|
||||
}
|
||||
.risk.prominent strong {
|
||||
color: var(--warn, #ffc107);
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.risk.prominent p {
|
||||
margin: 0;
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
</style>
|
||||
@@ -34,7 +34,7 @@ const error = ref('')
|
||||
// loading 由父组件控制(回测/寻优时驱动),组件自身只暴露 loadBars
|
||||
const loading = ref(false)
|
||||
|
||||
const CATEGORIES: Category[] = ['DAY', 'WEEK', 'MONTH', 'MIN_5', 'MIN_15', 'MIN_30', 'MIN_60']
|
||||
const CATEGORIES: Category[] = ['DAY', 'WEEK', 'MONTH', 'MIN_5', 'MIN_15', 'MIN_30', 'MIN_60', 'MIN_120']
|
||||
|
||||
// 智能识别的市场(用于提示展示)
|
||||
const detectedMarket = computed(() => (code.value && /^\d{6}$/.test(code.value)
|
||||
|
||||
+12
-1
@@ -2,7 +2,10 @@ import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
import BacktestView from './views/BacktestView.vue'
|
||||
import CompareView from './views/CompareView.vue'
|
||||
import CoreLeadersView from './views/CoreLeadersView.vue'
|
||||
import DashboardView from './views/DashboardView.vue'
|
||||
import LlmHistoryView from './views/LlmHistoryView.vue'
|
||||
import LlmSettingsView from './views/LlmSettingsView.vue'
|
||||
import OptimizeView from './views/OptimizeView.vue'
|
||||
import PortfolioView from './views/PortfolioView.vue'
|
||||
import ServerSettingsView from './views/ServerSettingsView.vue'
|
||||
@@ -12,7 +15,8 @@ import WatchlistView from './views/WatchlistView.vue'
|
||||
|
||||
// 行情终端:市场看板(/)+ 自选(/watchlist)。
|
||||
// 分析工具:单标的回测(/backtest)+ 组合回测(/portfolio)+ 参数寻优(/optimize)
|
||||
// + 结果对比(/compare)+ 策略库(/strategies)+ 信号雷达(/signals)+ 设置(/settings)。
|
||||
// + 结果对比(/compare)+ 策略库(/strategies)+ 信号雷达(/signals)
|
||||
// + 设置(/settings 服务器 / /llm AI 模型)。
|
||||
const routes = [
|
||||
{ path: '/', name: 'dashboard', component: DashboardView },
|
||||
{ path: '/watchlist', name: 'watchlist', component: WatchlistView },
|
||||
@@ -23,6 +27,13 @@ const routes = [
|
||||
{ path: '/strategies', name: 'strategies', component: StrategiesView },
|
||||
{ path: '/signals', name: 'signals', component: SignalRadarView },
|
||||
{ path: '/settings', name: 'settings', component: ServerSettingsView },
|
||||
{ path: '/llm', name: 'llm', component: LlmSettingsView },
|
||||
// AI 解读历史(每次「直接解读」自动归档)
|
||||
{ path: '/ai-history', name: 'ai-history', component: LlmHistoryView },
|
||||
// 核心龙头池(universe=core 的 159 只名单)
|
||||
{ path: '/leaders', name: 'leaders', component: CoreLeadersView },
|
||||
// 兜底:未注册路径(如把 API 路径当页面访问)回看板,不再渲染空白
|
||||
{ path: '/:pathMatch(.*)*', redirect: '/' },
|
||||
]
|
||||
|
||||
export const router = createRouter({
|
||||
|
||||
+128
-1
@@ -50,7 +50,15 @@ export interface DataFrameResponse {
|
||||
// ── 回测请求(POST /api/v1/backtest/run) ─────────────────────────────────────
|
||||
|
||||
export type ExecutionMode = 'next_open' | 'next_close'
|
||||
export type Category = 'DAY' | 'WEEK' | 'MONTH' | 'MIN_5' | 'MIN_15' | 'MIN_30' | 'MIN_60'
|
||||
export type Category =
|
||||
| 'DAY'
|
||||
| 'WEEK'
|
||||
| 'MONTH'
|
||||
| 'MIN_5'
|
||||
| 'MIN_15'
|
||||
| 'MIN_30'
|
||||
| 'MIN_60'
|
||||
| 'MIN_120'
|
||||
|
||||
export interface BacktestRequest {
|
||||
strategy: string
|
||||
@@ -152,6 +160,7 @@ export interface TaskState {
|
||||
| SignalScanResult
|
||||
| WalkForwardResult
|
||||
| EvaluateReport
|
||||
| LlmChatResult
|
||||
| null
|
||||
error: string | null
|
||||
description: string
|
||||
@@ -635,3 +644,121 @@ export interface EvaluateReport {
|
||||
benchmark: EvaluateBenchmarkReport
|
||||
config: Record<string, unknown>
|
||||
}
|
||||
|
||||
// ── 交易时段(GET /api/v1/market/session) ───────────────────────────────────
|
||||
|
||||
export interface MarketSessionInfo {
|
||||
is_trading_time: boolean
|
||||
sessions: Array<{ start: string; end: string }>
|
||||
session_desc: string
|
||||
server_time: string
|
||||
weekday: number
|
||||
}
|
||||
|
||||
// ── LLM 配置与对话(GET/PUT /api/v1/llm/config 等) ──────────────────────────
|
||||
|
||||
export interface LlmProviderInfo {
|
||||
id: string
|
||||
label: string
|
||||
base_url: string
|
||||
default_model: string
|
||||
api_style: 'openai' | 'anthropic'
|
||||
needs_key: boolean
|
||||
}
|
||||
|
||||
export interface LlmConfigInfo {
|
||||
provider: string
|
||||
/** 脱敏回显(sk-***abcd);提交时空串/原样回传 = 不修改已存 key */
|
||||
api_key: string
|
||||
api_url: string
|
||||
model: string
|
||||
temperature: number
|
||||
max_tokens: number
|
||||
timeout: number
|
||||
system_prompt: string
|
||||
}
|
||||
|
||||
export interface LlmConfigResponse {
|
||||
config: LlmConfigInfo
|
||||
providers: LlmProviderInfo[]
|
||||
configured: boolean
|
||||
missing: string[]
|
||||
config_path: string
|
||||
resolved: { api_url: string; model: string }
|
||||
}
|
||||
|
||||
export interface LlmConfigUpdate {
|
||||
provider: string
|
||||
api_key?: string
|
||||
api_url?: string
|
||||
model?: string
|
||||
temperature?: number
|
||||
max_tokens?: number
|
||||
timeout?: number
|
||||
system_prompt?: string
|
||||
}
|
||||
|
||||
export interface LlmTestResult {
|
||||
ok: boolean
|
||||
latency_ms: number
|
||||
model: string
|
||||
provider: string
|
||||
reply?: string
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface LlmChatResponse {
|
||||
reply: string
|
||||
model: string
|
||||
provider: string
|
||||
}
|
||||
|
||||
/** AI 解读后台任务(POST /llm/chat/async)完成后的 result 结构。 */
|
||||
export interface LlmChatResult {
|
||||
reply: string
|
||||
model: string
|
||||
provider: string
|
||||
elapsed: number
|
||||
}
|
||||
|
||||
// ── AI 解读历史(GET /api/v1/llm/history) ───────────────────────────────────
|
||||
|
||||
/** 策略上下文(随解读落库,供「去回测」引导跳转)。 */
|
||||
export interface LlmChatContext {
|
||||
strategy: string
|
||||
strategy_label: string
|
||||
symbol: string
|
||||
category: string
|
||||
params: Record<string, number | string | boolean>
|
||||
start_date: string
|
||||
end_date: string
|
||||
}
|
||||
|
||||
export interface LlmHistoryItem {
|
||||
id: number
|
||||
created_at: string
|
||||
provider: string
|
||||
model: string
|
||||
prompt: string
|
||||
reply: string
|
||||
elapsed: number
|
||||
strategy: string
|
||||
strategy_label: string
|
||||
symbol: string
|
||||
category: string
|
||||
params: Record<string, number | string | boolean>
|
||||
start_date: string
|
||||
end_date: string
|
||||
}
|
||||
|
||||
export interface LlmHistoryResponse {
|
||||
items: LlmHistoryItem[]
|
||||
count: number
|
||||
}
|
||||
|
||||
/** 核心龙头池条目(GET /api/v1/market/core-leaders)。 */
|
||||
export interface CoreLeaderRow {
|
||||
code: string
|
||||
name: string
|
||||
market: string
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ import StrategyPicker from '../components/StrategyPicker.vue'
|
||||
import SymbolPicker from '../components/SymbolPicker.vue'
|
||||
import TradeTable from '../components/TradeTable.vue'
|
||||
import WalkForwardPanel from '../components/WalkForwardPanel.vue'
|
||||
import { formatError, saveStrategy } from '../api'
|
||||
import { formatError, saveStrategy, fetchLlmConfig, runLlmChatWithPolling } from '../api'
|
||||
import { detectMarket } from '../market'
|
||||
import { GRADE_META, gradePerformance } from '../grading'
|
||||
import { buildAiPrompt } from '../aiPrompt'
|
||||
import type { Category, ExecutionMode } from '../types'
|
||||
import type { Category, ExecutionMode, LlmChatResult } from '../types'
|
||||
import { useBacktestStore } from '../stores/backtest'
|
||||
|
||||
const store = useBacktestStore()
|
||||
@@ -204,6 +204,13 @@ async function onSave() {
|
||||
// ── AI 解读 Prompt(把当前报告组装成提示词,发给任意 LLM 解读)──────────────
|
||||
const showAiModal = ref(false)
|
||||
const aiMsg = ref('')
|
||||
// 直接解读(服务端 LLM 已配置时可用,配置见「AI 设置」页)
|
||||
const llmReady = ref(false)
|
||||
const llmLabel = ref('')
|
||||
const aiRunning = ref(false)
|
||||
const aiElapsed = ref(0)
|
||||
const aiReply = ref('')
|
||||
let aiTimer = 0
|
||||
|
||||
/** 实时组装:附加分析(WF/评估)跑完后内容自动变全 */
|
||||
const aiPromptText = computed(() => {
|
||||
@@ -230,7 +237,60 @@ const aiPromptText = computed(() => {
|
||||
|
||||
function openAiModal() {
|
||||
aiMsg.value = ''
|
||||
aiReply.value = ''
|
||||
showAiModal.value = true
|
||||
// 打开时探测 LLM 是否已配置(失败静默——导出 Prompt 的老路径不依赖后端)
|
||||
fetchLlmConfig()
|
||||
.then((resp) => {
|
||||
llmReady.value = resp.configured
|
||||
const p = resp.providers.find((x) => x.id === resp.config.provider)
|
||||
llmLabel.value = p ? `${p.label} · ${resp.resolved.model}` : resp.resolved.model
|
||||
})
|
||||
.catch(() => {
|
||||
llmReady.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/** 直接解读:把组装好的 Prompt 提交为后台任务并轮询(不占 HTTP 连接)。 */
|
||||
async function runAiInterpret() {
|
||||
if (!aiPromptText.value || aiRunning.value) return
|
||||
aiRunning.value = true
|
||||
aiMsg.value = ''
|
||||
aiReply.value = ''
|
||||
// 后台任务模式:模型生成 1-3 分钟正常——显示已耗时防误判卡死
|
||||
aiElapsed.value = 0
|
||||
aiTimer = window.setInterval(() => {
|
||||
aiElapsed.value += 1
|
||||
}, 1000)
|
||||
try {
|
||||
// 策略上下文随解读落历史库(AI 解读历史页「去回测」引导用)
|
||||
const ctx = {
|
||||
strategy: strategy.value,
|
||||
strategy_label: strategyLabel.value,
|
||||
symbol: code.value,
|
||||
category: category.value,
|
||||
params: { ...params.value },
|
||||
start_date: startDate.value,
|
||||
end_date: endDate.value,
|
||||
}
|
||||
const state = await runLlmChatWithPolling(aiPromptText.value, ctx)
|
||||
// TaskState.result 是多任务类型联合,按 LLM 任务结构收窄
|
||||
const r = state.result as LlmChatResult | null
|
||||
// 后端已保证非空正文(空白正文会以 failed 上浮),前端再拦一道纯空白
|
||||
if (state.status === 'done' && r?.reply?.trim()) {
|
||||
aiReply.value = r.reply
|
||||
aiMsg.value = `✓ ${r.provider} · ${r.model} 已解读(${aiElapsed.value}s)`
|
||||
} else if (state.status === 'done') {
|
||||
aiMsg.value = '解读失败:模型返回了空正文(可能被 Max Tokens 截断),可在「AI 设置」调大后重试'
|
||||
} else {
|
||||
aiMsg.value = `解读失败:${state.error ?? '未知错误'}(可在「AI 设置」检查配置,或复制 Prompt 手动使用)`
|
||||
}
|
||||
} catch (e) {
|
||||
aiMsg.value = `解读失败:${formatError(e)}(可在「AI 设置」检查配置,或复制 Prompt 手动使用)`
|
||||
} finally {
|
||||
window.clearInterval(aiTimer)
|
||||
aiRunning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function copyAiPrompt() {
|
||||
@@ -445,26 +505,45 @@ function downloadAiPrompt() {
|
||||
<!-- AI 解读 Prompt 对话框 -->
|
||||
<div v-if="showAiModal" class="modal-overlay" @click.self="showAiModal = false">
|
||||
<div class="modal modal-wide">
|
||||
<h3>🤖 AI 解读 Prompt</h3>
|
||||
<h3>🤖 AI 解读</h3>
|
||||
<p class="modal-desc">
|
||||
已把当前回测报告组装成提示词。复制后发给任意 AI 助手(ChatGPT / Claude /
|
||||
DeepSeek / 豆包…),即可获得针对性解读与改进建议。
|
||||
已把当前回测报告组装成提示词。
|
||||
<template v-if="llmReady">
|
||||
点击「直接解读」发送给已配置的模型({{ llmLabel }}),
|
||||
</template>
|
||||
<template v-else>
|
||||
在「AI 设置」页配置模型后可一键直接解读;也可
|
||||
</template>
|
||||
复制后发给任意 AI 助手(ChatGPT / Claude / DeepSeek / 豆包…)。
|
||||
<template v-if="wfEnabled || evaluateEnabled">
|
||||
建议等附加分析跑完再复制,Walk-Forward / 一条龙评估的数据会一并打包。
|
||||
建议等附加分析跑完再发,Walk-Forward / 一条龙评估的数据会一并打包。
|
||||
</template>
|
||||
</p>
|
||||
<textarea
|
||||
:value="aiPromptText"
|
||||
class="ai-prompt-area"
|
||||
:class="{ collapsed: !!aiReply }"
|
||||
readonly
|
||||
rows="16"
|
||||
:rows="aiReply ? 6 : 16"
|
||||
spellcheck="false"
|
||||
></textarea>
|
||||
<div v-if="aiReply" class="ai-reply">{{ aiReply }}</div>
|
||||
<div v-if="aiReply" class="ai-note">
|
||||
以上解读由 AI 模型生成,可能存在错误或过时信息,仅供参考,不构成投资建议。
|
||||
</div>
|
||||
<span v-if="aiMsg" class="ai-msg">{{ aiMsg }}</span>
|
||||
<div class="modal-actions">
|
||||
<button class="ghost" @click="showAiModal = false">关闭</button>
|
||||
<button class="ghost" @click="downloadAiPrompt">⬇ 下载 .md</button>
|
||||
<button class="primary" @click="copyAiPrompt">复制 Prompt</button>
|
||||
<button class="ghost" @click="copyAiPrompt">复制 Prompt</button>
|
||||
<button
|
||||
v-if="llmReady"
|
||||
class="primary"
|
||||
:disabled="aiRunning || !aiPromptText"
|
||||
@click="runAiInterpret"
|
||||
>
|
||||
{{ aiRunning ? `解读中… ${aiElapsed}s` : '✨ 直接解读' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -724,8 +803,31 @@ function downloadAiPrompt() {
|
||||
color: var(--text-muted);
|
||||
resize: vertical;
|
||||
}
|
||||
/* 直接解读出结果后 Prompt 区收窄,把版面让给回复 */
|
||||
.ai-prompt-area.collapsed {
|
||||
max-height: 18vh;
|
||||
}
|
||||
.ai-reply {
|
||||
margin-top: 8px;
|
||||
max-height: 38vh;
|
||||
overflow: auto;
|
||||
background: var(--bg-elevated);
|
||||
border: 1px solid var(--border);
|
||||
border-left: 3px solid var(--accent);
|
||||
border-radius: var(--radius);
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
.ai-msg {
|
||||
font-size: 12px;
|
||||
color: var(--up);
|
||||
}
|
||||
.ai-note {
|
||||
margin-top: 4px;
|
||||
font-size: 11px;
|
||||
color: var(--warn, #ffc107);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
<script setup lang="ts">
|
||||
// 核心龙头池页:159 只核心龙头(东财全行业龙头名单,screen universe="core"
|
||||
// 的同一份数据资产)。支持搜索过滤,点击行弹个股详情。
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { fetchCoreLeaders, formatError } from '../api'
|
||||
import type { CoreLeaderRow } from '../types'
|
||||
import RiskDisclaimer from '../components/RiskDisclaimer.vue'
|
||||
import StockDialog from '../components/StockDialog.vue'
|
||||
|
||||
const leaders = ref<CoreLeaderRow[]>([])
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const keyword = ref('')
|
||||
const dialog = ref<{ market: string; code: string; name: string } | null>(null)
|
||||
|
||||
onMounted(load)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
leaders.value = await fetchCoreLeaders()
|
||||
} catch (e) {
|
||||
error.value = formatError(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const filtered = computed(() => {
|
||||
const k = keyword.value.trim().toLowerCase()
|
||||
if (!k) return leaders.value
|
||||
return leaders.value.filter(
|
||||
(r) => r.code.includes(k) || r.name.toLowerCase().includes(k),
|
||||
)
|
||||
})
|
||||
|
||||
function openDialog(row: CoreLeaderRow) {
|
||||
dialog.value = { market: row.market, code: row.code, name: row.name }
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="leaders-view">
|
||||
<div class="toolbar">
|
||||
<h2>核心龙头池 <span class="dim title-sub">({{ leaders.length }} 只 · 东财全行业龙头名单)</span></h2>
|
||||
<input
|
||||
v-model="keyword"
|
||||
class="search"
|
||||
type="text"
|
||||
placeholder="搜代码 / 名称…"
|
||||
spellcheck="false"
|
||||
/>
|
||||
</div>
|
||||
<p class="hint">
|
||||
<strong>这份名单是什么:</strong>按东方财富公开的"全行业龙头股名单"整理的
|
||||
<strong>选股扫描范围</strong>(即离线扫描的 <code>universe="core"</code> 股票池,
|
||||
<code>easy-tdx screen scan --universe core</code> 与
|
||||
<code>/market/strength?universe=core</code> 均按此过滤),四组分层:全球第一 / 国内第一 /
|
||||
科技细分 / 行业冠军。<strong>名单仅描述"这些公司在其行业内规模/市占率领先"这一客观事实,
|
||||
不代表任何买入价值判断</strong>——龙头同样可能高估、滞涨或衰退。点击行查看个股详情。
|
||||
</p>
|
||||
<RiskDisclaimer prominent>
|
||||
<strong>⚠ 风险提示与免责声明</strong>
|
||||
<p>
|
||||
本页面展示的"核心龙头池"仅为<strong>策略扫描的股票范围筛选清单</strong>,
|
||||
<strong>不构成任何形式的个股推荐、买入建议或投资顾问服务</strong>。名单基于第三方公开
|
||||
资料整理,可能存在滞后、遗漏或错误;"行业龙头"是对历史经营地位的描述,
|
||||
不预示未来股价表现。本工具及作者不对任何人依据本名单作出的投资行为及损失承担责任。
|
||||
投资有风险,入市需谨慎,据此操作风险自负。
|
||||
</p>
|
||||
</RiskDisclaimer>
|
||||
<div v-if="error" class="error-banner">⚠ {{ error }}</div>
|
||||
<div v-else-if="loading" class="empty">加载中…</div>
|
||||
<div v-else class="grid">
|
||||
<div
|
||||
v-for="r in filtered"
|
||||
:key="r.market + r.code"
|
||||
class="cell"
|
||||
@click="openDialog(r)"
|
||||
>
|
||||
<span class="c-code mono dim">{{ r.code }}</span>
|
||||
<span class="c-name">{{ r.name }}</span>
|
||||
<span class="c-mkt mono dim">{{ r.market }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!loading && !error && !filtered.length" class="empty">无匹配结果</div>
|
||||
|
||||
<StockDialog
|
||||
v-if="dialog"
|
||||
:market="dialog.market"
|
||||
:code="dialog.code"
|
||||
:name="dialog.name"
|
||||
@close="dialog = null"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.leaders-view {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
padding: 14px 16px;
|
||||
}
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.toolbar h2 {
|
||||
font-size: 16px;
|
||||
}
|
||||
.title-sub {
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
}
|
||||
.search {
|
||||
width: 200px;
|
||||
padding: 6px 10px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
}
|
||||
.search:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.hint {
|
||||
margin: 8px 0 12px;
|
||||
font-size: 12px;
|
||||
color: var(--text-dim);
|
||||
line-height: 1.7;
|
||||
}
|
||||
.hint code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
}
|
||||
.error-banner {
|
||||
padding: 8px 12px;
|
||||
background: rgba(244, 67, 54, 0.1);
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
color: var(--red, #f44336);
|
||||
}
|
||||
.empty {
|
||||
color: var(--text-dim);
|
||||
padding: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
||||
gap: 6px;
|
||||
}
|
||||
.cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 10px;
|
||||
background: var(--bg-panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
font-size: 12.5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.cell:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.cell:hover .c-name {
|
||||
color: var(--accent);
|
||||
}
|
||||
.c-code {
|
||||
font-size: 11px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.c-name {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.c-mkt {
|
||||
font-size: 10px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.dim {
|
||||
color: var(--text-dim);
|
||||
}
|
||||
</style>
|
||||
@@ -406,13 +406,40 @@ function rankExtra(r: RankRow): { text: string; cls: string } {
|
||||
return { text: fmtPctSigned(pct), cls: dirClass(pct) }
|
||||
}
|
||||
|
||||
// ── 轮询调度 ─────────────────────────────────────────────────────────────────
|
||||
// ── 轮询调度(交易时段感知:休市自动暂停,手动刷新不受限) ────────────────────
|
||||
|
||||
let statTimer = 0
|
||||
let slowTimer = 0
|
||||
let distTimer = 0
|
||||
let sessionTimer = 0
|
||||
|
||||
onMounted(() => {
|
||||
/** 仅交易时段自动刷新(localStorage 持久化;勾掉 = 全天候模式)。 */
|
||||
const sessionGated = ref(localStorage.getItem('dash.sessionGated') !== '0')
|
||||
|
||||
function onSessionToggle() {
|
||||
localStorage.setItem('dash.sessionGated', sessionGated.value ? '1' : '0')
|
||||
}
|
||||
|
||||
/** 本地判断当前是否处于 A 股有效行情时段(09:15~11:30、13:00~15:05,周一至五)。 */
|
||||
function isTradeSession(now = new Date()): boolean {
|
||||
const day = now.getDay()
|
||||
if (day === 0 || day === 6) return false
|
||||
const m = now.getHours() * 60 + now.getMinutes()
|
||||
return (m >= 555 && m <= 690) || (m >= 780 && m <= 905)
|
||||
}
|
||||
|
||||
/** 会话状态(每分钟重估):gated 开关 × 是否盘中。 */
|
||||
const inSession = ref(isTradeSession())
|
||||
|
||||
/** 自动刷新是否暂停(全天候模式或盘中 = 不暂停)。 */
|
||||
const autoPaused = computed(() => sessionGated.value && !inSession.value)
|
||||
|
||||
const sessionLabel = computed(() => {
|
||||
if (!sessionGated.value) return '全天候模式'
|
||||
return inSession.value ? '交易中' : '休市 · 自动刷新已暂停'
|
||||
})
|
||||
|
||||
function refreshAll() {
|
||||
loadStat()
|
||||
loadBoards()
|
||||
loadUnusual()
|
||||
@@ -420,20 +447,44 @@ onMounted(() => {
|
||||
loadIdxSparks()
|
||||
loadIndexContext()
|
||||
loadDist()
|
||||
statTimer = window.setInterval(loadStat, 30_000)
|
||||
slowTimer = window.setInterval(() => {
|
||||
loadUnusual()
|
||||
loadRanks()
|
||||
loadBoards()
|
||||
loadIdxSparks()
|
||||
loadIndexContext()
|
||||
}
|
||||
|
||||
function tickIfActive() {
|
||||
// 门控放在 fetch 前:定时器照常触发,休市时只重估会话状态、不发请求
|
||||
inSession.value = isTradeSession()
|
||||
if (autoPaused.value) return
|
||||
loadStat()
|
||||
}
|
||||
|
||||
function slowTickIfActive() {
|
||||
if (autoPaused.value) return
|
||||
loadUnusual()
|
||||
loadRanks()
|
||||
loadBoards()
|
||||
loadIdxSparks()
|
||||
loadIndexContext()
|
||||
}
|
||||
|
||||
function distTickIfActive() {
|
||||
if (autoPaused.value) return
|
||||
loadDist()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
refreshAll()
|
||||
statTimer = window.setInterval(tickIfActive, 30_000)
|
||||
slowTimer = window.setInterval(slowTickIfActive, 60_000)
|
||||
distTimer = window.setInterval(distTickIfActive, 120_000)
|
||||
// 每分钟重估会话状态(跨过 11:30/15:05 边界后状态栏即时切换)
|
||||
sessionTimer = window.setInterval(() => {
|
||||
inSession.value = isTradeSession()
|
||||
}, 60_000)
|
||||
distTimer = window.setInterval(loadDist, 120_000)
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
window.clearInterval(statTimer)
|
||||
window.clearInterval(slowTimer)
|
||||
window.clearInterval(distTimer)
|
||||
window.clearInterval(sessionTimer)
|
||||
})
|
||||
|
||||
// ── 弹窗(个股 / 板块) ──────────────────────────────────────────────────────
|
||||
@@ -456,6 +507,18 @@ function openBoard(code: string | undefined, name: string | undefined) {
|
||||
|
||||
<template>
|
||||
<div class="dash">
|
||||
<!-- 刷新状态条:会话状态 + 手动刷新 + 门控开关 -->
|
||||
<div class="session-bar">
|
||||
<span class="dot" :class="{ live: !autoPaused }"></span>
|
||||
<span class="session-label" :class="{ paused: autoPaused }">{{ sessionLabel }}</span>
|
||||
<span class="dim session-hint">(09:15~11:30, 13:00~15:05)</span>
|
||||
<label class="session-toggle">
|
||||
<input v-model="sessionGated" type="checkbox" @change="onSessionToggle" />
|
||||
仅交易时段自动刷新
|
||||
</label>
|
||||
<button class="manual-refresh" @click="refreshAll">↻ 手动刷新</button>
|
||||
</div>
|
||||
|
||||
<!-- 指数条(内嵌迷你分时) -->
|
||||
<div class="idx-row">
|
||||
<div
|
||||
@@ -715,6 +778,55 @@ function openBoard(code: string | undefined, name: string | undefined) {
|
||||
overflow: auto;
|
||||
padding: 14px 16px;
|
||||
}
|
||||
.session-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.session-bar .dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-dim);
|
||||
}
|
||||
.session-bar .dot.live {
|
||||
background: var(--up);
|
||||
box-shadow: 0 0 4px var(--up);
|
||||
}
|
||||
.session-label {
|
||||
font-weight: 600;
|
||||
}
|
||||
.session-label.paused {
|
||||
color: var(--text-dim);
|
||||
}
|
||||
.session-hint {
|
||||
font-size: 11px;
|
||||
}
|
||||
.session-toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-left: 12px;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
.manual-refresh {
|
||||
margin-left: auto;
|
||||
padding: 3px 12px;
|
||||
font-size: 12px;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
}
|
||||
.manual-refresh:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
.idx-row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
<script setup lang="ts">
|
||||
// AI 解读历史页:历次「直接解读」的提问 Prompt + 模型解读 + 策略上下文。
|
||||
// 每条可展开查看全文,「去回测」带策略/参数/标的/周期/日期一键跳回回测页,
|
||||
// 「重新解读」用原 Prompt 再发起一次(模型更新/换模型后对比)。
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { fetchLlmHistory, deleteLlmHistory, clearLlmHistory, formatError } from '../api'
|
||||
import type { LlmHistoryItem } from '../types'
|
||||
import RiskDisclaimer from '../components/RiskDisclaimer.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const items = ref<LlmHistoryItem[]>([])
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const expandedId = ref<number | null>(null)
|
||||
const showPromptOf = ref<number | null>(null)
|
||||
|
||||
onMounted(load)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const resp = await fetchLlmHistory(100)
|
||||
items.value = resp.items
|
||||
} catch (e) {
|
||||
error.value = formatError(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function toggle(id: number) {
|
||||
expandedId.value = expandedId.value === id ? null : id
|
||||
}
|
||||
|
||||
function togglePrompt(id: number) {
|
||||
showPromptOf.value = showPromptOf.value === id ? null : id
|
||||
}
|
||||
|
||||
/** 本地时间 + 只保留日期时分。 */
|
||||
function fmtTime(iso: string): string {
|
||||
if (!iso) return ''
|
||||
// 后端存 UTC(Z 结尾),转本地展示
|
||||
const d = new Date(iso.endsWith('Z') && iso.length === 17 ? iso.slice(0, 16) + 'Z' : iso)
|
||||
if (Number.isNaN(d.getTime())) return iso
|
||||
const p = (n: number) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
|
||||
}
|
||||
|
||||
/** 标题:策略 @ 标的 · 周期(手工调用无上下文时只显示模型)。 */
|
||||
function title(it: LlmHistoryItem): string {
|
||||
if (!it.strategy_label && !it.symbol) return `AI 对话 · ${it.model}`
|
||||
const sym = it.symbol || '—'
|
||||
const cat = it.category ? ` · ${it.category}` : ''
|
||||
return `${it.strategy_label || it.strategy || '策略'} @ ${sym}${cat}`
|
||||
}
|
||||
|
||||
/** 去回测:带全部上下文跳转(回测页 onMounted 读 query 预填)。 */
|
||||
function goBacktest(it: LlmHistoryItem) {
|
||||
const query: Record<string, string> = {}
|
||||
if (it.strategy) query.strategy = it.strategy
|
||||
if (Object.keys(it.params || {}).length) query.params = JSON.stringify(it.params)
|
||||
if (it.symbol) query.symbol = it.symbol
|
||||
if (it.category) query.category = it.category
|
||||
if (it.start_date) query.startDate = it.start_date
|
||||
if (it.end_date) query.endDate = it.end_date
|
||||
router.push({ path: '/backtest', query })
|
||||
}
|
||||
|
||||
async function onDelete(id: number) {
|
||||
try {
|
||||
await deleteLlmHistory(id)
|
||||
items.value = items.value.filter((i) => i.id !== id)
|
||||
} catch (e) {
|
||||
error.value = formatError(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function onClearAll() {
|
||||
if (!window.confirm('确定清空全部 AI 解读历史?此操作不可恢复。')) return
|
||||
try {
|
||||
await clearLlmHistory()
|
||||
items.value = []
|
||||
} catch (e) {
|
||||
error.value = formatError(e)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="ai-history">
|
||||
<aside class="side-panel">
|
||||
<h2>AI 解读历史</h2>
|
||||
<p class="hint">
|
||||
每次「直接解读」成功后自动归档:提问 Prompt、模型解读、以及当时的策略配置。
|
||||
「去回测」可一键带参数跳回回测页复现当时的场景;「重新解读」适合换模型后对比结论。
|
||||
</p>
|
||||
<button class="btn-ghost" :disabled="!items.length || loading" @click="onClearAll">
|
||||
清空历史
|
||||
</button>
|
||||
<div v-if="error" class="error-banner">⚠ {{ error }}</div>
|
||||
<RiskDisclaimer>
|
||||
历史解读由 AI 生成、基于当时的回测数据,均不构成投资建议;策略过往表现不代表未来。
|
||||
</RiskDisclaimer>
|
||||
</aside>
|
||||
|
||||
<main class="list-panel">
|
||||
<div v-if="loading" class="empty">加载中…</div>
|
||||
<div v-else-if="!items.length" class="empty">
|
||||
暂无解读记录——到「单标的回测」页跑一次回测,点「🤖 AI 解读 → ✨ 直接解读」即可归档。
|
||||
</div>
|
||||
|
||||
<div v-for="it in items" :key="it.id" class="record" :class="{ open: expandedId === it.id }">
|
||||
<div class="record-head" @click="toggle(it.id)">
|
||||
<span class="r-time mono dim">{{ fmtTime(it.created_at) }}</span>
|
||||
<span class="r-title">{{ title(it) }}</span>
|
||||
<span class="r-model mono dim">{{ it.provider }} · {{ it.model }}</span>
|
||||
<span class="r-elapsed mono dim">{{ it.elapsed }}s</span>
|
||||
<span class="r-arrow">{{ expandedId === it.id ? '▾' : '▸' }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="expandedId === it.id" class="record-body">
|
||||
<div class="reply">{{ it.reply }}</div>
|
||||
<div class="ai-note">以上解读由 AI 模型生成,可能存在错误或过时信息,仅供参考,不构成投资建议。</div>
|
||||
|
||||
<div v-if="it.start_date || it.end_date" class="ctx-line dim">
|
||||
回测区间 {{ it.start_date || '…' }} ~ {{ it.end_date || '…' }}
|
||||
<template v-if="Object.keys(it.params || {}).length">
|
||||
· 参数 {{ JSON.stringify(it.params) }}
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<button
|
||||
v-if="it.strategy || it.symbol"
|
||||
class="btn-primary"
|
||||
@click="goBacktest(it)"
|
||||
>
|
||||
→ 去回测(带参数)
|
||||
</button>
|
||||
<button class="btn-ghost" @click="togglePrompt(it.id)">
|
||||
{{ showPromptOf === it.id ? '收起提问' : '查看提问 Prompt' }}
|
||||
</button>
|
||||
<button class="btn-danger" @click="onDelete(it.id)">删除</button>
|
||||
</div>
|
||||
|
||||
<pre v-if="showPromptOf === it.id" class="prompt">{{ it.prompt }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.ai-history {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.side-panel {
|
||||
width: 280px;
|
||||
flex-shrink: 0;
|
||||
padding: 20px;
|
||||
background: var(--bg-panel);
|
||||
border-right: 1px solid var(--border);
|
||||
overflow-y: auto;
|
||||
}
|
||||
.side-panel h2 {
|
||||
font-size: 16px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.hint {
|
||||
font-size: 12px;
|
||||
color: var(--text-dim);
|
||||
line-height: 1.7;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.error-banner {
|
||||
margin-top: 12px;
|
||||
padding: 8px 12px;
|
||||
background: rgba(244, 67, 54, 0.1);
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
color: var(--red, #f44336);
|
||||
}
|
||||
.list-panel {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 14px 16px;
|
||||
}
|
||||
.empty {
|
||||
color: var(--text-dim);
|
||||
padding: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
}
|
||||
.record {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
margin-bottom: 8px;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
.record.open {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.record-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 9px 12px;
|
||||
cursor: pointer;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.record-head:hover .r-title {
|
||||
color: var(--accent);
|
||||
}
|
||||
.r-time {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
}
|
||||
.r-title {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-weight: 600;
|
||||
}
|
||||
.r-model {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
}
|
||||
.r-elapsed {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
}
|
||||
.r-arrow {
|
||||
color: var(--text-dim);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.record-body {
|
||||
border-top: 1px solid var(--border);
|
||||
padding: 12px;
|
||||
}
|
||||
.reply {
|
||||
/* 不设内层滚动:正文完整铺开,由外层 list-panel 页面级滚动(内层限高
|
||||
曾导致"高度太低无滚轴、文字展示不全"的阅读问题) */
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-size: 13px;
|
||||
line-height: 1.75;
|
||||
background: var(--bg-elevated);
|
||||
border-left: 3px solid var(--accent);
|
||||
border-radius: var(--radius);
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.ctx-line {
|
||||
margin-top: 8px;
|
||||
font-size: 11.5px;
|
||||
}
|
||||
.ai-note {
|
||||
margin-top: 6px;
|
||||
font-size: 11px;
|
||||
color: var(--warn, #ffc107);
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.btn-primary {
|
||||
padding: 5px 14px;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
.btn-ghost {
|
||||
padding: 5px 14px;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-muted);
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
.btn-ghost:hover:not(:disabled) {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
.btn-ghost:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.btn-danger {
|
||||
padding: 5px 14px;
|
||||
background: transparent;
|
||||
border: 1px solid rgba(244, 67, 54, 0.5);
|
||||
color: var(--red, #f44336);
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
.btn-danger:hover {
|
||||
background: rgba(244, 67, 54, 0.1);
|
||||
}
|
||||
.prompt {
|
||||
margin-top: 10px;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
line-height: 1.6;
|
||||
color: var(--text-dim);
|
||||
background: var(--bg);
|
||||
border: 1px dashed var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 8px 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,406 @@
|
||||
<script setup lang="ts">
|
||||
// AI 设置页:LLM Provider 配置(WebUI 表单 ⇆ ~/.easy_tdx/llm.json 同一份文件)。
|
||||
// 选 Provider 自动填充预设 base_url / 默认模型,均可手工覆盖;API Key 脱敏
|
||||
// 回显,留空或原样回传不覆盖已存 key。支持「测试连接」即时验证。
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { fetchLlmConfig, saveLlmConfig, testLlm, formatError } from '../api'
|
||||
import type { LlmProviderInfo } from '../types'
|
||||
|
||||
const providers = ref<LlmProviderInfo[]>([])
|
||||
const configPath = ref('')
|
||||
const configured = ref(false)
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const testing = ref(false)
|
||||
const message = ref('')
|
||||
const error = ref('')
|
||||
const testResult = ref<string>('')
|
||||
|
||||
const form = reactive({
|
||||
provider: 'deepseek',
|
||||
api_url: '',
|
||||
api_key: '',
|
||||
model: '',
|
||||
temperature: 0.3,
|
||||
max_tokens: 16000,
|
||||
timeout: 180,
|
||||
system_prompt: '',
|
||||
})
|
||||
|
||||
/** 当前选中 Provider 的预设(填充提示用)。 */
|
||||
const currentPreset = computed(
|
||||
() => providers.value.find((p) => p.id === form.provider) ?? null,
|
||||
)
|
||||
|
||||
onMounted(load)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const resp = await fetchLlmConfig()
|
||||
providers.value = resp.providers
|
||||
configPath.value = resp.config_path
|
||||
configured.value = resp.configured
|
||||
form.provider = resp.config.provider
|
||||
form.api_url = resp.config.api_url
|
||||
form.api_key = resp.config.api_key
|
||||
form.model = resp.config.model
|
||||
form.temperature = resp.config.temperature
|
||||
form.max_tokens = resp.config.max_tokens
|
||||
form.timeout = resp.config.timeout
|
||||
form.system_prompt = resp.config.system_prompt
|
||||
} catch (e) {
|
||||
error.value = formatError(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 切换 Provider:清空 key 与空字段,让预设兜底(已有自定义值不覆盖)。 */
|
||||
function onProviderChange() {
|
||||
form.api_key = ''
|
||||
form.api_url = ''
|
||||
form.model = ''
|
||||
message.value = ''
|
||||
error.value = ''
|
||||
testResult.value = ''
|
||||
}
|
||||
|
||||
async function save() {
|
||||
saving.value = true
|
||||
error.value = ''
|
||||
message.value = ''
|
||||
testResult.value = ''
|
||||
try {
|
||||
const resp = await saveLlmConfig({
|
||||
provider: form.provider,
|
||||
api_url: form.api_url,
|
||||
// 脱敏串原样回传 = 不覆盖已存 key;后端再判一次
|
||||
api_key: form.api_key,
|
||||
model: form.model,
|
||||
temperature: form.temperature,
|
||||
max_tokens: form.max_tokens,
|
||||
timeout: form.timeout,
|
||||
system_prompt: form.system_prompt,
|
||||
})
|
||||
configured.value = resp.configured
|
||||
// 回填脱敏 key,避免明文留在表单里
|
||||
form.api_key = resp.config.api_key
|
||||
message.value = `已保存到 ${resp.config_path}`
|
||||
} catch (e) {
|
||||
error.value = formatError(e)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function test() {
|
||||
testing.value = true
|
||||
error.value = ''
|
||||
message.value = ''
|
||||
testResult.value = ''
|
||||
try {
|
||||
// 先保存再测(保存时脱敏串回传不会覆盖真 key),保证测的就是落盘配置
|
||||
await save()
|
||||
const r = await testLlm()
|
||||
if (r.ok) {
|
||||
testResult.value = `✓ 连通成功 · ${r.model} · ${r.latency_ms} ms · 回复「${r.reply}」`
|
||||
} else {
|
||||
testResult.value = `✗ 失败 · ${r.error}`
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = formatError(e)
|
||||
} finally {
|
||||
testing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="llm-settings">
|
||||
<aside class="config-panel">
|
||||
<h2>AI 设置</h2>
|
||||
<p class="hint">
|
||||
配置 LLM 后,回测页的「AI 解读」可直接把报告发给模型解读,无需复制粘贴。
|
||||
配置同时落盘到 <code>{{ configPath || '~/.easy_tdx/llm.json' }}</code>
|
||||
,手工编辑该文件与此处保存完全等效。
|
||||
</p>
|
||||
|
||||
<label class="field">
|
||||
<span>Provider</span>
|
||||
<select v-model="form.provider" @change="onProviderChange">
|
||||
<option v-for="p in providers" :key="p.id" :value="p.id">
|
||||
{{ p.label }}{{ p.needs_key ? '' : '(免Key)' }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label class="field">
|
||||
<span>API 地址</span>
|
||||
<input
|
||||
v-model="form.api_url"
|
||||
type="text"
|
||||
:placeholder="currentPreset?.base_url || 'https://...(OpenAI 兼容地址)'"
|
||||
spellcheck="false"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="field">
|
||||
<span>API Key</span>
|
||||
<input
|
||||
v-model="form.api_key"
|
||||
type="password"
|
||||
:placeholder="form.api_key ? '已保存(留空不修改,填 CLEAR 清除)' : 'sk-…'"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="field">
|
||||
<span>模型</span>
|
||||
<input
|
||||
v-model="form.model"
|
||||
type="text"
|
||||
:placeholder="currentPreset?.default_model || '模型名'"
|
||||
spellcheck="false"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div class="row-2">
|
||||
<label class="field">
|
||||
<span>Temperature</span>
|
||||
<input v-model.number="form.temperature" type="number" min="0" max="2" step="0.1" />
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>Max Tokens——思考型模型的思考链计入此预算,建议 ≥16000</span>
|
||||
<input v-model.number="form.max_tokens" type="number" min="64" max="128000" step="512" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label class="field">
|
||||
<span>超时(秒)——报告解读需等模型生成完整段回复,建议 ≥120</span>
|
||||
<input v-model.number="form.timeout" type="number" min="5" max="600" step="10" />
|
||||
</label>
|
||||
|
||||
<label class="field">
|
||||
<span>系统提示词(AI 解读的默认角色设定)</span>
|
||||
<textarea v-model="form.system_prompt" rows="4" spellcheck="false"></textarea>
|
||||
</label>
|
||||
|
||||
<div class="actions">
|
||||
<button class="btn-primary" :disabled="saving || loading" @click="save">
|
||||
{{ saving ? '保存中…' : '保存配置' }}
|
||||
</button>
|
||||
<button class="btn-ghost" :disabled="testing || loading" @click="test">
|
||||
{{ testing ? '测试中…' : '保存并测试' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="message" class="message">{{ message }}</div>
|
||||
<div v-if="testResult" class="test-result" :class="{ ok: testResult.startsWith('✓') }">
|
||||
{{ testResult }}
|
||||
</div>
|
||||
<div v-if="error" class="error-banner">⚠ {{ error }}</div>
|
||||
<div v-if="!loading && !configured" class="warn-banner">
|
||||
尚未配置可用的 API Key——「AI 解读」仍可导出 Prompt 手动使用。
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="info-panel">
|
||||
<h3>支持的 Provider</h3>
|
||||
<table class="provider-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Provider</th>
|
||||
<th>默认地址</th>
|
||||
<th>默认模型</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="p in providers" :key="p.id" :class="{ current: p.id === form.provider }">
|
||||
<td>{{ p.label }}</td>
|
||||
<td class="mono">{{ p.base_url || '—' }}</td>
|
||||
<td class="mono">{{ p.default_model || '—' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="hint">
|
||||
除 Claude 走 Anthropic 原生协议外,其余均走 OpenAI 兼容接口;「自定义」可填任意
|
||||
兼容网关(如 OpenRouter、one-api、vLLM)。Ollama 本地服务无需 API Key。
|
||||
环境变量 LLM_PROVIDER / LLM_API_KEY / LLM_BASE_URL / LLM_MODEL 在配置文件
|
||||
缺字段时兜底生效。
|
||||
</p>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.llm-settings {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.config-panel {
|
||||
width: 360px;
|
||||
flex-shrink: 0;
|
||||
padding: 20px;
|
||||
background: var(--bg-panel);
|
||||
border-right: 1px solid var(--border);
|
||||
overflow-y: auto;
|
||||
}
|
||||
.config-panel h2 {
|
||||
font-size: 16px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.hint {
|
||||
font-size: 12px;
|
||||
color: var(--text-dim);
|
||||
line-height: 1.6;
|
||||
}
|
||||
.hint code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
word-break: break-all;
|
||||
}
|
||||
.field {
|
||||
display: block;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.field span {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.field input,
|
||||
.field select,
|
||||
.field textarea {
|
||||
width: 100%;
|
||||
padding: 6px 8px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.field textarea {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
resize: vertical;
|
||||
}
|
||||
.row-2 {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
.btn-primary {
|
||||
flex: 1;
|
||||
padding: 9px;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.btn-ghost {
|
||||
flex: 1;
|
||||
padding: 9px;
|
||||
background: transparent;
|
||||
border: 1px solid var(--accent);
|
||||
color: var(--accent);
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
}
|
||||
.btn-ghost:hover:not(:disabled) {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
}
|
||||
.btn-primary:disabled,
|
||||
.btn-ghost:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.message {
|
||||
margin-top: 12px;
|
||||
padding: 8px 12px;
|
||||
background: var(--accent-bg, rgba(0, 120, 212, 0.1));
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
color: var(--accent);
|
||||
word-break: break-all;
|
||||
}
|
||||
.test-result {
|
||||
margin-top: 10px;
|
||||
padding: 8px 12px;
|
||||
background: rgba(244, 67, 54, 0.08);
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
color: var(--red, #f44336);
|
||||
word-break: break-all;
|
||||
}
|
||||
.test-result.ok {
|
||||
background: rgba(76, 175, 80, 0.12);
|
||||
color: var(--green, #4caf50);
|
||||
}
|
||||
.error-banner {
|
||||
margin-top: 12px;
|
||||
padding: 8px 12px;
|
||||
background: rgba(244, 67, 54, 0.1);
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
color: var(--red, #f44336);
|
||||
}
|
||||
.warn-banner {
|
||||
margin-top: 12px;
|
||||
padding: 8px 12px;
|
||||
background: rgba(255, 193, 7, 0.1);
|
||||
border-radius: var(--radius);
|
||||
font-size: 12px;
|
||||
color: var(--warn, #ffc107);
|
||||
}
|
||||
.info-panel {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
padding: 20px;
|
||||
}
|
||||
.info-panel h3 {
|
||||
font-size: 14px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.provider-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 12.5px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.provider-table th {
|
||||
text-align: left;
|
||||
padding: 7px 10px;
|
||||
border-bottom: 2px solid var(--border);
|
||||
color: var(--text-dim);
|
||||
font-weight: 500;
|
||||
}
|
||||
.provider-table td {
|
||||
padding: 7px 10px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.provider-table tr.current {
|
||||
background: var(--accent-bg, rgba(0, 120, 212, 0.06));
|
||||
}
|
||||
.mono {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11.5px;
|
||||
}
|
||||
</style>
|
||||
@@ -30,7 +30,7 @@ const EXECUTIONS: { value: ExecutionMode; label: string }[] = [
|
||||
{ value: 'next_open', label: '开盘价' },
|
||||
{ value: 'next_close', label: '收盘价' },
|
||||
]
|
||||
const CATEGORIES: Category[] = ['DAY', 'WEEK', 'MONTH', 'MIN_5', 'MIN_15', 'MIN_30', 'MIN_60']
|
||||
const CATEGORIES: Category[] = ['DAY', 'WEEK', 'MONTH', 'MIN_5', 'MIN_15', 'MIN_30', 'MIN_60', 'MIN_120']
|
||||
|
||||
// 日期默认(复用单标的逻辑)
|
||||
function isoDaysFromNow(days: number): string {
|
||||
|
||||
Reference in New Issue
Block a user