Restructure into modules/ with single-process CTP and config/ layout.
Move business code under modules/, env template to config/, PM2 single qihuo process, and _legacy shims for old imports. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}AI 消息 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/ai_messages.css') }}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="card ai-page">
|
||||
<h2>AI 分析 · 使用说明</h2>
|
||||
<div class="card-body">
|
||||
<details class="ai-usage" open>
|
||||
<summary>使用说明</summary>
|
||||
<div class="ai-usage-body">
|
||||
<ul>
|
||||
<li>在 <a href="{{ url_for('settings') }}">系统设置</a> →「AI 分析 · 使用说明」中配置 Ollama 或 OpenAI 并启用</li>
|
||||
<li><strong>开仓 / 平仓</strong>:成交后自动生成简要复盘(本页下方列表)</li>
|
||||
<li><strong>日终报告</strong>:每个交易日按设定时刻汇总当日盈亏与持仓</li>
|
||||
<li>配置企业微信后,日终报告摘要会同步推送到群</li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
<h3 class="ai-section-label">分析消息</h3>
|
||||
<div class="ai-msg-list card-scroll">
|
||||
{% for m in messages %}
|
||||
<article class="ai-msg" data-kind="{{ m.kind }}">
|
||||
<header class="ai-msg-head">
|
||||
<span class="ai-msg-kind">{{ m.kind }}</span>
|
||||
<time>{{ m.created_at }}</time>
|
||||
</header>
|
||||
{% if m.title %}<h3 class="ai-msg-title">{{ m.title }}</h3>{% endif %}
|
||||
<pre class="ai-msg-body">{{ m.content }}</pre>
|
||||
</article>
|
||||
{% else %}
|
||||
<p class="text-muted empty-hint">暂无 AI 消息。开启 AI 并完成一笔交易,或等待日终报告后此处会显示分析。</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,115 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" data-theme="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||
<meta name="theme-color" content="#050508" id="meta-theme-color">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="期货监控">
|
||||
<meta name="application-name" content="期货监控">
|
||||
<link rel="manifest" href="{{ url_for('web_manifest') }}">
|
||||
<link rel="icon" href="{{ url_for('static', filename='icons/icon.svg') }}" type="image/svg+xml">
|
||||
<link rel="apple-touch-icon" href="{{ url_for('static', filename='icons/icon-192.png') }}">
|
||||
<title>{% block title %}国内期货 · 交易复盘系统{% endblock %}</title>
|
||||
<script>
|
||||
try {
|
||||
var _t = localStorage.getItem('qihuo-theme');
|
||||
if (_t === 'light' || _t === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', _t);
|
||||
document.documentElement.style.colorScheme = _t;
|
||||
document.documentElement.style.background = _t === 'light' ? '#e8eef8' : '#050508';
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
</script>
|
||||
<script>
|
||||
(function () {
|
||||
var ua = navigator.userAgent || '';
|
||||
var isIpad = /iPad/i.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
||||
var isTabletUa = isIpad || (/Android/i.test(ua) && !/Mobile/i.test(ua));
|
||||
var isPhoneUa = !isTabletUa && (/iPhone|iPod|Android.*Mobile|HarmonyOS|OpenHarmony|Mobile/i.test(ua));
|
||||
var s = Math.min(window.screen.width || 0, window.screen.height || 0);
|
||||
var coarse = window.matchMedia('(hover: none) and (pointer: coarse)').matches;
|
||||
var layout = 'desktop';
|
||||
if (isPhoneUa || (s > 0 && s < 600)) layout = 'phone';
|
||||
else if (isTabletUa || (s >= 600 && s <= 1100 && coarse)) layout = 'tablet';
|
||||
else if (window.innerWidth <= 767) layout = 'phone';
|
||||
var root = document.documentElement;
|
||||
root.dataset.layout = layout;
|
||||
root.dataset.mobile = layout === 'phone' ? '1' : '0';
|
||||
root.dataset.orientation = layout === 'phone' ? 'portrait' : (window.innerWidth >= window.innerHeight ? 'landscape' : 'portrait');
|
||||
if (layout === 'phone') root.classList.add('layout-phone');
|
||||
else if (layout === 'tablet') root.classList.add('layout-tablet');
|
||||
})();
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/theme.js') }}?v={{ asset_v }}"></script>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}?v={{ asset_v }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/tech.css') }}?v={{ asset_v }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/responsive.css') }}?v={{ asset_v }}">
|
||||
{% block extra_css %}{% endblock %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/mobile.css') }}?v={{ asset_v }}">
|
||||
</head>
|
||||
<body>
|
||||
<div class="tech-bg" aria-hidden="true">
|
||||
<div class="tech-grid"></div>
|
||||
<div class="tech-glow"></div>
|
||||
<div class="tech-glow-2"></div>
|
||||
<div class="tech-scanline"></div>
|
||||
</div>
|
||||
<div class="page-wrap">
|
||||
<header class="site-header">
|
||||
<div class="header-bar">
|
||||
<button type="button" class="nav-toggle" id="nav-toggle" aria-label="打开菜单" aria-expanded="false" aria-controls="site-nav">
|
||||
<span></span><span></span><span></span>
|
||||
</button>
|
||||
<h1 class="site-title">
|
||||
<span class="site-title-mobile">期货监控</span>
|
||||
<span class="site-title-desktop">国内期货 · 交易复盘系统<span class="site-title-sub">Position Management · Disciplined Execution</span></span>
|
||||
</h1>
|
||||
<div class="header-tools">
|
||||
<div class="theme-switch" role="group" aria-label="主题模式">
|
||||
<button type="button" class="theme-switch-btn" data-theme-pick="dark">深色</button>
|
||||
<button type="button" class="theme-switch-btn" data-theme-pick="light">浅色</button>
|
||||
</div>
|
||||
<button type="button" class="pwa-install-btn" id="pwa-install-btn" hidden>安装 App</button>
|
||||
</div>
|
||||
<div class="user-bar">{{ session.username or '用户' }}<a href="{{ url_for('logout') }}">退出</a></div>
|
||||
</div>
|
||||
<p class="pwa-ios-hint" id="pwa-ios-hint">iOS 安装:Safari 浏览器点击底部分享按钮,选择「添加到主屏幕」。</p>
|
||||
<button type="button" class="nav-backdrop" id="nav-backdrop" aria-label="关闭菜单" hidden></button>
|
||||
<nav class="site-nav" id="site-nav">
|
||||
<a href="{{ url_for('positions') }}" class="{% if request.endpoint in ('positions', 'trade_page', 'recommend_page') %}active{% endif %}">下单监控</a>
|
||||
{% if nav_items.dashboard %}<a href="{{ url_for('dashboard') }}" class="{% if request.endpoint == 'dashboard' %}active{% endif %}">数据看板</a>{% endif %}
|
||||
{% if nav_items.risk_guide %}<a href="{{ url_for('risk_guide') }}" class="{% if request.endpoint == 'risk_guide' %}active{% endif %}">风控说明</a>{% endif %}
|
||||
{% if nav_items.strategy %}<a href="{{ url_for('strategy_page') }}" class="{% if request.endpoint in ('strategy_page', 'strategy_records_page') %}active{% endif %}">策略交易</a>{% endif %}
|
||||
{% if nav_items.plans %}<a href="{{ url_for('plans') }}" class="{% if request.endpoint == 'plans' %}active{% endif %}">开单计划</a>{% endif %}
|
||||
<a href="{{ url_for('keys') }}" class="{% if request.endpoint == 'keys' %}active{% endif %}">关键位监控</a>
|
||||
{% if nav_items.ai %}<a href="{{ url_for('ai_messages_page') }}" class="{% if request.endpoint == 'ai_messages_page' %}active{% endif %}">AI 分析</a>{% endif %}
|
||||
{% if nav_items.market %}<a href="{{ url_for('market_page') }}" class="{% if request.endpoint == 'market_page' %}active{% endif %}">行情K线</a>{% endif %}
|
||||
<a href="{{ url_for('records') }}" class="{% if request.endpoint in ('records', 'trades') %}active{% endif %}">交易记录与复盘</a>
|
||||
<a href="{{ url_for('trade_calendar') }}" class="{% if request.endpoint == 'trade_calendar' %}active{% endif %}">交易日历</a>
|
||||
<a href="{{ url_for('stats') }}" class="{% if request.endpoint == 'stats' %}active{% endif %}">统计分析</a>
|
||||
{% if nav_items.fees %}<a href="{{ url_for('fees') }}" class="{% if request.endpoint == 'fees' %}active{% endif %}">手续费配置</a>{% endif %}
|
||||
<a href="{{ url_for('settings') }}" class="{% if request.endpoint == 'settings' %}active{% endif %}">系统设置</a>
|
||||
</nav>
|
||||
</header>
|
||||
<main class="main">
|
||||
{% with msg=get_flashed_messages() %}{% if msg %}<div class="flash">{{ msg[0] }}</div>{% endif %}{% endwith %}
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</div>
|
||||
<div id="orientation-lock" class="orientation-lock" hidden>
|
||||
<div class="orientation-lock-box">
|
||||
<div class="orientation-lock-icon" aria-hidden="true">↻</div>
|
||||
<p id="orientation-lock-msg">请旋转设备</p>
|
||||
</div>
|
||||
</div>
|
||||
<script src="{{ url_for('static', filename='js/orientation.js') }}?v={{ asset_v }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/symbol.js') }}?v={{ asset_v }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/nav.js') }}?v={{ asset_v }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/pwa.js') }}?v={{ asset_v }}"></script>
|
||||
{% block extra_js %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,148 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}交易日历 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
.trade-cal-page .trade-cal-card{margin-bottom:0}
|
||||
.trade-cal-head{
|
||||
display:flex;align-items:center;justify-content:space-between;gap:.75rem;
|
||||
flex-wrap:wrap;margin-bottom:.85rem;
|
||||
}
|
||||
.trade-cal-head h2{margin:0}
|
||||
.trade-cal-nav{display:flex;align-items:center;gap:.5rem}
|
||||
.trade-cal-nav button{
|
||||
border:1px solid var(--card-border);background:var(--card-inner);color:var(--text-title);
|
||||
border-radius:8px;padding:.35rem .65rem;cursor:pointer;font:inherit;font-size:.85rem;
|
||||
}
|
||||
.trade-cal-nav button:hover{border-color:var(--accent)}
|
||||
.trade-cal-title{font-size:1rem;font-weight:600;color:var(--text-title);min-width:10rem;text-align:center;line-height:1.35}
|
||||
.trade-cal-weekdays{
|
||||
display:grid;grid-template-columns:repeat(7,1fr);gap:.4rem;margin-bottom:.4rem;
|
||||
}
|
||||
.trade-cal-weekdays span{
|
||||
text-align:center;font-size:.78rem;color:var(--text-muted);padding:.2rem 0;
|
||||
}
|
||||
.trade-cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:.4rem}
|
||||
.trade-cal-cell{
|
||||
min-height:5.1rem;border:1px solid var(--card-border);border-radius:10px;
|
||||
background:var(--card-inner);padding:.42rem .48rem;text-align:left;cursor:default;
|
||||
transition:border-color .2s,box-shadow .2s;
|
||||
}
|
||||
.trade-cal-cell.is-empty{background:transparent;border-color:transparent}
|
||||
.trade-cal-cell.is-clickable{cursor:pointer}
|
||||
.trade-cal-cell.is-clickable:hover{border-color:var(--accent)}
|
||||
.trade-cal-cell.is-selected{
|
||||
border-color:var(--accent);box-shadow:0 0 0 1px rgba(56,189,248,.25);
|
||||
}
|
||||
.trade-cal-cell.is-today .trade-cal-day-solar{color:var(--accent);font-weight:700}
|
||||
.trade-cal-cell.is-emotion{
|
||||
border-color:rgba(251,146,60,.65);
|
||||
background:linear-gradient(145deg,rgba(251,146,60,.12),var(--card-inner));
|
||||
}
|
||||
.trade-cal-cell.is-emotion.is-selected{
|
||||
border-color:rgba(251,146,60,.9);
|
||||
box-shadow:0 0 0 1px rgba(251,146,60,.35);
|
||||
}
|
||||
.trade-cal-day-head{
|
||||
display:flex;align-items:baseline;justify-content:space-between;gap:.3rem;line-height:1.25;
|
||||
}
|
||||
.trade-cal-day-solar{font-size:.95rem;font-weight:600;color:var(--text-title)}
|
||||
.trade-cal-day-lunar{
|
||||
font-size:.72rem;color:var(--text-muted);white-space:nowrap;flex-shrink:0;
|
||||
}
|
||||
.trade-cal-day-lunar.is-month-start{color:#c4a35a;font-weight:600;font-size:.74rem}
|
||||
.trade-cal-cell.is-today .trade-cal-day-lunar{color:var(--accent);opacity:.85}
|
||||
.trade-cal-meta{margin-top:.25rem;font-size:.72rem;line-height:1.4;color:var(--text-muted)}
|
||||
.trade-cal-count{font-variant-numeric:tabular-nums}
|
||||
.trade-cal-pnl{font-weight:600;font-size:.76rem;font-variant-numeric:tabular-nums;margin-top:.1rem}
|
||||
.trade-cal-pnl.is-profit{color:var(--profit)}
|
||||
.trade-cal-pnl.is-loss{color:var(--loss)}
|
||||
.trade-cal-emotion{
|
||||
display:inline-block;margin-top:.14rem;padding:.06rem .32rem;border-radius:4px;
|
||||
font-size:.65rem;font-weight:600;color:#fb923c;background:rgba(251,146,60,.15);
|
||||
}
|
||||
.trade-cal-day-detail{margin-top:1rem;padding-top:.85rem;border-top:1px solid var(--table-border)}
|
||||
.trade-cal-day-detail-head{
|
||||
display:flex;align-items:center;justify-content:space-between;gap:.75rem;
|
||||
flex-wrap:wrap;margin-bottom:.65rem;
|
||||
}
|
||||
.trade-cal-day-detail-head h3{margin:0;font-size:.95rem}
|
||||
.trade-cal-day-summary{font-size:.78rem;color:var(--text-muted)}
|
||||
.trade-cal-day-list{display:flex;flex-direction:column;gap:.55rem}
|
||||
.trade-cal-day-item{
|
||||
border:1px solid var(--card-border);border-radius:12px;background:var(--card-inner);
|
||||
padding:.65rem .75rem;
|
||||
}
|
||||
.trade-cal-day-item.is-emotion{
|
||||
border-color:rgba(251,146,60,.55);
|
||||
background:linear-gradient(145deg,rgba(251,146,60,.1),var(--card-inner));
|
||||
}
|
||||
.trade-cal-day-item-head{
|
||||
display:flex;align-items:center;justify-content:space-between;gap:.5rem;margin-bottom:.35rem;
|
||||
}
|
||||
.trade-cal-day-item-symbol{font-weight:600;font-size:.88rem;color:var(--text-title)}
|
||||
.trade-cal-day-item-pnl{font-weight:600;font-size:.88rem;font-variant-numeric:tabular-nums}
|
||||
.trade-cal-day-item-pnl.is-profit{color:var(--profit)}
|
||||
.trade-cal-day-item-pnl.is-loss{color:var(--loss)}
|
||||
.trade-cal-day-item-meta{
|
||||
display:flex;flex-wrap:wrap;gap:.35rem .55rem;font-size:.72rem;color:var(--text-muted);
|
||||
}
|
||||
.trade-cal-badge{
|
||||
display:inline-block;padding:.08rem .35rem;border-radius:4px;font-size:.65rem;font-weight:600;
|
||||
}
|
||||
.trade-cal-badge.review{background:rgba(56,189,248,.15);color:var(--accent)}
|
||||
.trade-cal-badge.emotion{background:rgba(251,146,60,.18);color:#fb923c}
|
||||
.trade-cal-day-item-notes{
|
||||
margin-top:.4rem;font-size:.72rem;color:var(--text-muted);line-height:1.45;
|
||||
}
|
||||
.trade-cal-day-item-shot{margin-top:.45rem}
|
||||
.trade-cal-day-item-shot img{
|
||||
max-width:100%;max-height:180px;border-radius:8px;border:1px solid var(--card-border);
|
||||
}
|
||||
@media (min-width:768px){
|
||||
.trade-cal-cell{min-height:5.6rem;padding:.5rem .55rem}
|
||||
.trade-cal-day-solar{font-size:1.05rem}
|
||||
.trade-cal-day-lunar{font-size:.78rem}
|
||||
.trade-cal-day-lunar.is-month-start{font-size:.8rem}
|
||||
.trade-cal-meta{font-size:.76rem}
|
||||
.trade-cal-pnl{font-size:.8rem}
|
||||
.trade-cal-weekdays span{font-size:.82rem}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<div class="trade-cal-page">
|
||||
<div class="card trade-cal-card">
|
||||
<div class="trade-cal-head">
|
||||
<h2>交易日历</h2>
|
||||
<div class="trade-cal-nav">
|
||||
<button type="button" id="trade-cal-prev" aria-label="上个月">‹</button>
|
||||
<span class="trade-cal-title" id="trade-cal-title">—</span>
|
||||
<button type="button" id="trade-cal-next" aria-label="下个月">›</button>
|
||||
<button type="button" id="trade-cal-today">本月</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint" style="margin:0 0 .75rem">公历与农历对照;按平仓日汇总笔数与净盈亏。橙色日期含情绪单复盘,点击日期查看当日记录(已复盘优先)。</p>
|
||||
<div class="trade-cal-weekdays">
|
||||
<span>一</span><span>二</span><span>三</span><span>四</span><span>五</span><span>六</span><span>日</span>
|
||||
</div>
|
||||
<div class="trade-cal-grid" id="trade-cal-grid">
|
||||
<div class="text-muted" style="grid-column:1/-1;padding:.5rem 0">加载日历…</div>
|
||||
</div>
|
||||
<div class="trade-cal-day-detail" id="trade-cal-day-detail" hidden>
|
||||
<div class="trade-cal-day-detail-head">
|
||||
<h3 id="trade-cal-day-detail-title">当日交易</h3>
|
||||
<span class="trade-cal-day-summary" id="trade-cal-day-summary"></span>
|
||||
</div>
|
||||
<div class="trade-cal-day-list" id="trade-cal-day-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/lunar.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/calendar.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,48 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}品种简介 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block content %}
|
||||
<div class="card profile-page">
|
||||
<h2>品种简介</h2>
|
||||
<div class="card-body">
|
||||
<form id="contract-search-form" class="form-row" method="get" action="{{ url_for('contract_profile_page') }}">
|
||||
<div class="symbol-wrap" style="flex:1;min-width:220px;max-width:360px">
|
||||
<input type="text" class="symbol-input" id="contract-symbol-input"
|
||||
placeholder="输入品种或合约,如 螺纹钢 / rb2510" autocomplete="off" required>
|
||||
<input type="hidden" name="symbol" id="contract-symbol-hidden" value="{{ symbol or '' }}">
|
||||
<div class="symbol-dropdown"></div>
|
||||
<div class="symbol-selected"></div>
|
||||
</div>
|
||||
<button type="submit" class="btn-primary">查询</button>
|
||||
</form>
|
||||
<p class="hint">展示交易所合约规格:交易单位、最小变动、保证金、交割规则等(数据来源:东方财富 / 新浪)。</p>
|
||||
|
||||
{% if error %}
|
||||
<div class="flash" style="margin-top:1rem">{{ error }}</div>
|
||||
{% elif profile %}
|
||||
<div class="profile-head">
|
||||
<strong>{{ profile.symbol_name or profile.ths_code }}</strong>
|
||||
<span class="text-muted">{{ profile.ths_code }}</span>
|
||||
{% if profile.exchange %}<span class="badge active">{{ profile.exchange }}</span>{% endif %}
|
||||
<span class="profile-source">来源:{{ profile.source }}</span>
|
||||
</div>
|
||||
<div class="profile-spec">
|
||||
{% for row in profile.rows %}
|
||||
<div class="profile-row">
|
||||
<div class="profile-label">{{ row.label }}</div>
|
||||
<div class="profile-value">
|
||||
{{ row.value }}
|
||||
{% if row.hint %}<div class="profile-hint">{{ row.hint }}</div>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% elif symbol %}
|
||||
<p class="text-muted" style="margin-top:1rem">未查询到该合约简介,请检查合约代码是否正确。</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/contract.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,138 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}数据看板 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/dashboard.css') }}?v={{ asset_v }}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<div class="dashboard-page">
|
||||
<div class="dashboard-top">
|
||||
<div class="dashboard-top-left">
|
||||
<span class="badge planned" id="dash-mode-badge">—</span>
|
||||
<span class="badge planned" id="dash-ctp-badge">CTP 检测中…</span>
|
||||
<span class="text-muted dash-updated" id="dash-updated">正在加载…</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card dashboard-account-card">
|
||||
<div class="stat-grid stat-grid-summary dashboard-account-grid">
|
||||
<div class="stat-item">
|
||||
<div class="label">账户权益</div>
|
||||
<div class="value" id="dash-equity">—</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="label">占用保证金</div>
|
||||
<div class="value" id="dash-margin">—</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="label">可用权益</div>
|
||||
<div class="value" id="dash-available">—</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card dashboard-section dashboard-risk-card" id="dash-risk-card">
|
||||
<h2 class="dashboard-risk-heading dash-section-toggle" id="dash-risk-toggle" role="button" tabindex="0" aria-expanded="false" aria-controls="dash-risk-body">
|
||||
<span class="dash-section-toggle-label">风控说明</span>
|
||||
{% if nav_items.risk_guide %}
|
||||
<a class="dash-risk-doc-link" href="{{ url_for('risk_guide') }}" onclick="event.stopPropagation()">完整说明</a>
|
||||
{% else %}
|
||||
<span class="text-muted dash-risk-doc-ref">· 详见 <code>docs/风控说明.md</code></span>
|
||||
{% endif %}
|
||||
<span class="dash-toggle-icon" aria-hidden="true">▼</span>
|
||||
</h2>
|
||||
<div class="dash-risk-body" id="dash-risk-body">
|
||||
<p class="dashboard-risk-reason" id="dash-risk-reason">加载中…</p>
|
||||
<div class="stat-grid stat-grid-summary dashboard-risk-grid" id="dash-risk-grid"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card dashboard-section">
|
||||
<h2>持仓信息</h2>
|
||||
<div class="dash-mobile-list" id="dash-pos-mobile-list"></div>
|
||||
<div class="dash-pos-table-wrap card-scroll">
|
||||
<table class="dashboard-table" id="dash-positions-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>品种</th>
|
||||
<th>方向</th>
|
||||
<th>手数</th>
|
||||
<th>均价</th>
|
||||
<th>现价</th>
|
||||
<th>浮盈亏</th>
|
||||
<th>保证金</th>
|
||||
<th>止损</th>
|
||||
<th>止盈</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="dash-positions-body">
|
||||
<tr><td colspan="9" class="text-muted">加载中…</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card dashboard-section">
|
||||
<h2>关键位监控</h2>
|
||||
<div class="dash-mobile-list" id="dash-keys-mobile-list"></div>
|
||||
<div class="dash-keys-table-wrap card-scroll">
|
||||
<table class="dashboard-table" id="dash-keys-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>品种</th>
|
||||
<th>类型</th>
|
||||
<th>周期</th>
|
||||
<th>上沿</th>
|
||||
<th>下沿</th>
|
||||
<th>现价</th>
|
||||
<th>距上沿</th>
|
||||
<th>距下沿</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="dash-keys-body">
|
||||
<tr><td colspan="8" class="text-muted">加载中…</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card dashboard-section">
|
||||
<h2>平仓记录</h2>
|
||||
<div class="dash-mobile-list" id="dash-closes-mobile-list"></div>
|
||||
<div class="card-scroll dash-closes-table-wrap">
|
||||
<table class="dashboard-table" id="dash-closes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>品种</th>
|
||||
<th>方向</th>
|
||||
<th>手数</th>
|
||||
<th>开仓</th>
|
||||
<th>平仓</th>
|
||||
<th>盈亏</th>
|
||||
<th>净盈亏</th>
|
||||
<th>平仓时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="dash-closes-body">
|
||||
<tr><td colspan="8" class="text-muted">加载中…</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-mask" id="dash-detail-modal" hidden>
|
||||
<div class="modal-box dash-detail-modal">
|
||||
<h3 id="dash-detail-title">详情</h3>
|
||||
<div class="modal-grid" id="dash-detail-grid"></div>
|
||||
<div class="modal-actions">
|
||||
<button type="button" class="btn-primary" id="dash-detail-close">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/dashboard.js') }}?v={{ asset_v }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,121 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}手续费配置 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
.fees-status-card .card-body{display:flex;flex-wrap:wrap;gap:.75rem 1.25rem;align-items:center}
|
||||
.fees-status-card .fees-meta{font-size:.85rem;color:var(--text-muted)}
|
||||
.fees-table-card .card-body{padding:.75rem 1rem 1rem}
|
||||
.fees-table-card .trade-table-wrap{
|
||||
max-height:min(70vh,560px);
|
||||
width:100%;
|
||||
overflow:auto;
|
||||
-webkit-overflow-scrolling:touch;
|
||||
border:1px solid var(--table-border);
|
||||
border-radius:10px;
|
||||
background:var(--card-inner);
|
||||
}
|
||||
.fees-table-card .trade-table{
|
||||
width:100%;
|
||||
min-width:0;
|
||||
table-layout:fixed;
|
||||
font-size:.8rem;
|
||||
}
|
||||
.fees-table-card .trade-table thead th{
|
||||
position:sticky;
|
||||
top:0;
|
||||
z-index:2;
|
||||
background:var(--card-inner);
|
||||
box-shadow:0 1px 0 var(--table-border);
|
||||
}
|
||||
.fees-table-card .trade-table th,
|
||||
.fees-table-card .trade-table td{
|
||||
padding:.5rem .4rem;
|
||||
white-space:nowrap;
|
||||
overflow:hidden;
|
||||
text-overflow:ellipsis;
|
||||
}
|
||||
.fees-table-card .trade-table th:last-child,
|
||||
.fees-table-card .trade-table td:last-child{
|
||||
position:static;
|
||||
box-shadow:none;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="card fees-status-card">
|
||||
<h2>CTP 手续费</h2>
|
||||
<div class="card-body">
|
||||
<p class="fees-meta" style="margin:0;flex:1;min-width:220px">
|
||||
费率由后台从 <strong>CTP 柜台</strong> 同步写入数据库,<strong>每日自动更新一次</strong>,本页只读展示。
|
||||
</p>
|
||||
{% if ctp_connected %}
|
||||
<span class="badge profit">CTP 已连接</span>
|
||||
{% else %}
|
||||
<span class="badge planned">CTP 未连接</span>
|
||||
{% endif %}
|
||||
{% if fee_synced_today %}
|
||||
<span class="badge profit">今日已同步</span>
|
||||
{% else %}
|
||||
<span class="badge planned">今日未同步</span>
|
||||
{% endif %}
|
||||
{% if fee_last_sync %}
|
||||
<span class="text-muted" style="font-size:.8rem">上次:{{ fee_last_sync[:16] }}</span>
|
||||
{% endif %}
|
||||
{% if fee_sync_running %}
|
||||
<span class="badge planned">同步中…</span>
|
||||
{% endif %}
|
||||
{% if fee_counts.get('ctp') %}
|
||||
<span class="text-muted" style="font-size:.8rem">共 {{ fee_counts.ctp }} 个品种</span>
|
||||
{% endif %}
|
||||
<form action="{{ url_for('fees') }}" method="post" style="display:inline">
|
||||
<input type="hidden" name="action" value="sync_ctp">
|
||||
<input type="hidden" name="force" value="1">
|
||||
<button type="submit" class="btn-primary" {% if not ctp_connected %}disabled title="请先连接 CTP"{% endif %}>立即同步</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card fees-table-card">
|
||||
<h2>品种费率表</h2>
|
||||
<div class="card-body">
|
||||
<div class="trade-table-wrap">
|
||||
<table class="trade-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>品种</th><th>交易所</th><th>乘数</th>
|
||||
<th>开仓(元/手)</th><th>开仓(比例)</th>
|
||||
<th>平昨(元/手)</th><th>平昨(比例)</th>
|
||||
<th>平今(元/手)</th><th>平今(比例)</th>
|
||||
<th>更新</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for r in rates %}
|
||||
<tr>
|
||||
<td><strong>{{ r.product }}</strong></td>
|
||||
<td class="cell-readonly">{{ r.exchange or '—' }}</td>
|
||||
<td class="cell-readonly">{{ r.mult }}</td>
|
||||
<td class="cell-readonly">{{ r.open_fixed }}</td>
|
||||
<td class="cell-readonly">{{ r.open_ratio }}</td>
|
||||
<td class="cell-readonly">{{ r.close_yesterday_fixed }}</td>
|
||||
<td class="cell-readonly">{{ r.close_yesterday_ratio }}</td>
|
||||
<td class="cell-readonly">{{ r.close_today_fixed }}</td>
|
||||
<td class="cell-readonly">{{ r.close_today_ratio }}</td>
|
||||
<td class="text-muted" style="font-size:.72rem">{{ (r.updated_at or '')[:16] }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="10" class="text-muted">暂无 CTP 费率,请连接 CTP 后等待自动同步或点击「立即同步」</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint" style="margin-top:.75rem;padding:0 1rem 1rem">
|
||||
公式:单边 = 固定(元/手)×手数 + 比例×价格×乘数×手数;往返 = 开仓 + 平仓(平今/平昨自动判断)。
|
||||
{% if ctp_connected and not fee_counts.get('ctp') %}
|
||||
<br><strong class="text-loss">数据库尚无 CTP 费率,请点击「立即同步」或等待后台每日任务。</strong>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,175 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}关键位监控 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/keys.css') }}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="split-grid">
|
||||
<div class="card">
|
||||
<h2>新增监控</h2>
|
||||
<div class="card-body">
|
||||
<details class="module-rules">
|
||||
<summary>规则说明</summary>
|
||||
<div class="module-rules-body">
|
||||
<p><strong>箱体突破 / 收敛突破(自动单)</strong></p>
|
||||
<ul>
|
||||
<li>触发:<strong>上周期 K 线收盘</strong>收在上沿或下沿之外(默认 5 分)</li>
|
||||
<li>箱体突破须选<strong>上方向</strong>,仅当突破后下单方向一致时才自动开仓</li>
|
||||
<li>顺势:上破做多、下破做空;反转:上破做空、下破做多</li>
|
||||
<li>自动<strong>市价开仓</strong>;止损 = 突破 K 线极值 ± 2 跳</li>
|
||||
<li>盈亏比默认 2(可改);开启移动保本时默认 3,达目标价自动止盈</li>
|
||||
</ul>
|
||||
<p><strong>关键支阻区(仅提醒)</strong></p>
|
||||
<ul>
|
||||
<li>上沿 = 阻力,下沿 = 支撑,合并为一个区间</li>
|
||||
<li>上周期 K 线收盘突破 → 微信推送(最多 3 次,间隔约 5 分钟)</li>
|
||||
<li>推送完毕后自动结案,<strong>不参与自动开仓</strong></li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
<form action="{{ url_for('add_key') }}" method="post" id="key-add-form">
|
||||
<div class="key-form-rows">
|
||||
<div class="key-form-line line-3">
|
||||
<div class="key-field symbol-wrap symbol-mains">
|
||||
<label class="text-label">品种</label>
|
||||
<input type="text" class="symbol-input" placeholder="输入中文或代码,选择主力合约" autocomplete="off" required>
|
||||
<input type="hidden" name="symbol" required>
|
||||
<input type="hidden" name="symbol_name">
|
||||
<input type="hidden" name="market_code" required>
|
||||
<input type="hidden" name="sina_code">
|
||||
<div class="symbol-dropdown"></div>
|
||||
<div class="symbol-selected"></div>
|
||||
</div>
|
||||
<div class="key-field">
|
||||
<label class="text-label">类型</label>
|
||||
<select name="type" id="key-type" required>
|
||||
<option value="箱体突破">箱体突破</option>
|
||||
<option value="收敛突破">收敛突破</option>
|
||||
<option value="关键支阻区">关键支阻区</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="key-field">
|
||||
<label class="text-label">上周期</label>
|
||||
<select name="bar_period" id="key-bar-period">
|
||||
{% for p in key_periods %}
|
||||
<option value="{{ p.key }}"{% if p.key == '5m' %} selected{% endif %}>{{ p.label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="key-form-line line-3" id="key-row-auto">
|
||||
<div class="key-field" id="key-trade-mode-wrap">
|
||||
<label class="text-label">模式</label>
|
||||
<select name="trade_mode" id="key-trade-mode">
|
||||
<option value="顺势">顺势</option>
|
||||
<option value="反转">反转</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="key-field" id="key-direction-wrap">
|
||||
<label class="text-label">上方向</label>
|
||||
<select name="direction" id="key-direction">
|
||||
<option value="long">做多</option>
|
||||
<option value="short">做空</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="key-field" id="key-rr-wrap">
|
||||
<label class="text-label">盈亏比</label>
|
||||
<input name="risk_reward" id="key-rr" type="number" step="0.1" min="0.5" max="10" value="2">
|
||||
</div>
|
||||
</div>
|
||||
<div class="key-form-line line-2" id="key-row-prices">
|
||||
<div class="key-field">
|
||||
<label class="text-label">上沿(阻力)</label>
|
||||
<input name="upper" type="number" step="0.0001" required>
|
||||
</div>
|
||||
<div class="key-field">
|
||||
<label class="text-label">下沿(支撑)</label>
|
||||
<input name="lower" type="number" step="0.0001" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="key-action-row" id="key-row-actions">
|
||||
<label class="trailing-be-toggle" id="key-trailing-wrap">
|
||||
<input type="checkbox" name="trailing_be" id="key-trailing" value="1">
|
||||
<span>移动保本</span>
|
||||
</label>
|
||||
<p class="hint key-trailing-hint" id="key-trailing-hint">开启后盈亏比默认 3,达 3R 自动止盈并启用移动止损</p>
|
||||
<button type="submit" class="btn-primary key-submit-btn">添加</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<h3 class="section-label">监控列表</h3>
|
||||
<div class="list card-scroll" id="key-monitor-list">
|
||||
{% for k in keys %}
|
||||
<div class="list-item key-item" data-key-id="{{ k.id }}" style="padding:.75rem;font-size:.85rem">
|
||||
<div>
|
||||
<strong>{{ k.symbol_name or k.symbol }}</strong> {{ k.monitor_type }}
|
||||
<span class="badge planned">{{ k.bar_period or '5m' }}</span>
|
||||
{% if k.monitor_type in ('箱体突破', '收敛突破') %}
|
||||
<span class="badge planned">{{ k.trade_mode or '顺势' }}</span>
|
||||
{% if k.monitor_type == '箱体突破' and k.direction %}
|
||||
<span class="badge profit">{{ '做多' if k.direction == 'long' else '做空' }}</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if k.trailing_be %}
|
||||
<span class="badge profit">移动保本</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="key-live">
|
||||
<span class="live-price-line">现价:<span class="live-price">--</span></span>
|
||||
<span class="live-dist">距上<span class="dist-up">--</span> 距下<span class="dist-down">--</span></span>
|
||||
</div>
|
||||
<div>上沿 {{ k.upper }} · 下沿 {{ k.lower }}
|
||||
{% if k.monitor_type in ('箱体突破', '收敛突破') %}
|
||||
· 盈亏比 {{ k.risk_reward or 2 }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<a href="{{ url_for('del_key', pid=k.id) }}" class="btn-del" onclick="return confirm('移入历史?')">删</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="empty-hint">暂无监控</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>监控历史</h2>
|
||||
<div class="card-body card-scroll">
|
||||
<table>
|
||||
<thead><tr><th>品种</th><th>类型</th><th>周期</th><th>模式</th><th>上沿</th><th>下沿</th><th>归档</th></tr></thead>
|
||||
<tbody>
|
||||
{% for k in history %}
|
||||
<tr>
|
||||
<td>{{ k.symbol_name or k.symbol }}</td>
|
||||
<td>{{ k.monitor_type }}</td>
|
||||
<td>{{ k.bar_period or '5m' }}</td>
|
||||
<td>
|
||||
{% if k.monitor_type in ('箱体突破', '收敛突破') %}
|
||||
{{ k.trade_mode or '顺势' }}
|
||||
{% if k.monitor_type == '箱体突破' and k.direction %}
|
||||
· {{ '做多' if k.direction == 'long' else '做空' }}
|
||||
{% endif %}
|
||||
{% if k.trailing_be %} · 移动保本{% endif %}
|
||||
{% elif k.monitor_type in ('关键阻力位', '关键支撑位') %}
|
||||
支阻区
|
||||
{% else %}
|
||||
提醒
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ k.upper }}</td>
|
||||
<td>{{ k.lower }}</td>
|
||||
<td>{{ k.archived_at[:16] if k.archived_at else '' }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="7" class="text-muted">暂无历史</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/keys.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,206 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" data-theme="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||
<meta name="theme-color" content="#050508" id="meta-theme-color">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="期货监控">
|
||||
<link rel="manifest" href="{{ url_for('web_manifest') }}">
|
||||
<link rel="icon" href="{{ url_for('static', filename='icons/icon.svg') }}" type="image/svg+xml">
|
||||
<link rel="apple-touch-icon" href="{{ url_for('static', filename='icons/icon-192.png') }}">
|
||||
<title>系统登录</title>
|
||||
<script>
|
||||
try {
|
||||
var _t = localStorage.getItem('qihuo-theme');
|
||||
if (_t === 'light' || _t === 'dark') document.documentElement.setAttribute('data-theme', _t);
|
||||
} catch (e) { /* ignore */ }
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/theme.js') }}"></script>
|
||||
<style>
|
||||
html:not([data-theme="light"]){
|
||||
--bg-page:#050508;
|
||||
--bg-grid:rgba(76,194,255,.045);
|
||||
--card-bg:rgba(10,12,22,.88);
|
||||
--card-border:rgba(76,194,255,.25);
|
||||
--card-border-hover:rgba(76,194,255,.45);
|
||||
--card-glow:rgba(76,194,255,.12);
|
||||
--ambient-glow:rgba(76,194,255,.14);
|
||||
--ambient-glow-2:rgba(123,66,255,.1);
|
||||
--scanline:rgba(76,194,255,.03);
|
||||
--text-primary:#e8eaf6;
|
||||
--text-label:#a8b4ff;
|
||||
--text-muted:#7a82a0;
|
||||
--accent:#4cc2ff;
|
||||
--accent-2:#9d6bff;
|
||||
--input-bg:rgba(12,14,26,.95);
|
||||
--input-border:rgba(76,194,255,.2);
|
||||
--focus-ring:rgba(76,194,255,.25);
|
||||
--focus-glow:rgba(76,194,255,.2);
|
||||
--btn-glow:rgba(76,194,255,.35);
|
||||
--btn-glow-strong:rgba(123,66,255,.4);
|
||||
--loss-bg:rgba(255,107,122,.12);
|
||||
--loss:#ff6b7a;
|
||||
--shadow:0 16px 48px rgba(0,0,0,.5),0 0 24px var(--card-glow);
|
||||
--toggle-bg:rgba(14,16,28,.9);
|
||||
--toggle-border:rgba(76,194,255,.2);
|
||||
--nav-hover-glow:rgba(76,194,255,.15);
|
||||
}
|
||||
[data-theme="light"]{
|
||||
--bg-page:#e8eef8;
|
||||
--bg-grid:rgba(37,99,235,.07);
|
||||
--card-bg:rgba(255,255,255,.94);
|
||||
--card-border:rgba(37,99,235,.22);
|
||||
--card-border-hover:rgba(37,99,235,.4);
|
||||
--card-glow:rgba(37,99,235,.1);
|
||||
--ambient-glow:rgba(37,99,235,.12);
|
||||
--ambient-glow-2:rgba(124,58,237,.08);
|
||||
--scanline:rgba(37,99,235,.04);
|
||||
--text-primary:#1a2233;
|
||||
--text-label:#1d4ed8;
|
||||
--text-muted:#5c6578;
|
||||
--accent:#2563eb;
|
||||
--accent-2:#7c3aed;
|
||||
--input-bg:#ffffff;
|
||||
--input-border:#b8c5d6;
|
||||
--focus-ring:rgba(37,99,235,.2);
|
||||
--focus-glow:rgba(37,99,235,.15);
|
||||
--btn-glow:rgba(37,99,235,.25);
|
||||
--btn-glow-strong:rgba(37,99,235,.35);
|
||||
--loss-bg:#fee2e2;
|
||||
--loss:#dc2626;
|
||||
--shadow:0 16px 40px rgba(15,23,42,.12),0 0 20px var(--card-glow);
|
||||
--toggle-bg:#ffffff;
|
||||
--toggle-border:#c5d0dc;
|
||||
--nav-hover-glow:rgba(37,99,235,.12);
|
||||
}
|
||||
*{margin:0;padding:0;box-sizing:border-box}
|
||||
body{
|
||||
background:var(--bg-page);
|
||||
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"PingFang SC","Microsoft YaHei",sans-serif;
|
||||
display:flex;align-items:center;justify-content:center;
|
||||
min-height:100vh;color:var(--text-primary);
|
||||
padding:1rem;
|
||||
}
|
||||
.login-wrap{width:100%;max-width:400px;position:relative;z-index:1}
|
||||
.theme-row{display:flex;justify-content:flex-end;margin-bottom:.75rem}
|
||||
.theme-switch{
|
||||
display:inline-flex;border-radius:999px;
|
||||
border:1px solid var(--toggle-border);
|
||||
background:var(--toggle-bg);padding:3px;gap:2px;
|
||||
}
|
||||
.theme-switch-btn{
|
||||
padding:.38rem .75rem;border:none;border-radius:999px;
|
||||
background:transparent;color:var(--text-muted);
|
||||
font-size:.75rem;cursor:pointer;transition:.2s;width:auto;
|
||||
}
|
||||
.theme-switch-btn:hover{color:var(--text-primary)}
|
||||
.theme-switch-btn.active{
|
||||
background:linear-gradient(135deg,var(--accent),var(--accent-2));
|
||||
color:#fff;box-shadow:0 0 12px var(--btn-glow);
|
||||
}
|
||||
.login-box{
|
||||
background:var(--card-bg);
|
||||
padding:2.5rem 2rem 2rem;border-radius:14px;
|
||||
border:1px solid var(--card-border);
|
||||
box-shadow:var(--shadow);
|
||||
position:relative;overflow:hidden;
|
||||
backdrop-filter:blur(12px);
|
||||
transition:border-color .25s,box-shadow .25s;
|
||||
}
|
||||
.login-box:hover{
|
||||
border-color:var(--card-border-hover);
|
||||
}
|
||||
.login-box::after{
|
||||
content:"";position:absolute;top:0;left:12%;right:12%;height:1px;
|
||||
background:linear-gradient(90deg,transparent,var(--accent),var(--accent-2),transparent);
|
||||
opacity:.75;
|
||||
}
|
||||
.login-box h2{
|
||||
margin-bottom:.35rem;text-align:center;font-size:1.45rem;font-weight:700;
|
||||
letter-spacing:.04em;
|
||||
background:linear-gradient(135deg,var(--text-primary),var(--accent),var(--accent-2));
|
||||
-webkit-background-clip:text;-webkit-text-fill-color:transparent;
|
||||
filter:drop-shadow(0 0 20px var(--focus-glow));
|
||||
}
|
||||
.login-sub{
|
||||
text-align:center;font-size:.68rem;letter-spacing:.12em;
|
||||
text-transform:uppercase;color:var(--text-muted);margin-bottom:2rem;
|
||||
}
|
||||
.form-group{margin-bottom:1.25rem}
|
||||
.form-group label{
|
||||
display:block;margin-bottom:.5rem;font-size:.85rem;
|
||||
color:var(--text-label);letter-spacing:.03em;
|
||||
}
|
||||
.form-group input{
|
||||
width:100%;padding:.85rem 1rem;border-radius:10px;
|
||||
border:1px solid var(--input-border);
|
||||
background:var(--input-bg);color:var(--text-primary);
|
||||
font-size:.95rem;outline:none;
|
||||
transition:border-color .2s,box-shadow .2s;
|
||||
}
|
||||
.form-group input:focus{
|
||||
border-color:var(--accent);
|
||||
box-shadow:0 0 0 3px var(--focus-ring),0 0 16px var(--focus-glow);
|
||||
}
|
||||
button[type="submit"]{
|
||||
width:100%;padding:.9rem;border-radius:10px;border:none;
|
||||
background:linear-gradient(135deg,var(--accent),var(--accent-2));
|
||||
color:#fff;font-size:1rem;font-weight:600;cursor:pointer;
|
||||
letter-spacing:.06em;
|
||||
box-shadow:0 4px 24px var(--btn-glow);
|
||||
transition:transform .15s,box-shadow .2s;
|
||||
}
|
||||
button[type="submit"]:hover{
|
||||
transform:translateY(-1px);
|
||||
box-shadow:0 6px 28px var(--btn-glow-strong);
|
||||
}
|
||||
.flash{
|
||||
padding:.8rem;margin-bottom:1rem;
|
||||
background:var(--loss-bg);color:var(--loss);
|
||||
border-radius:8px;text-align:center;font-size:.85rem;
|
||||
border:1px solid rgba(255,107,122,.25);
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/tech.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/responsive.css') }}">
|
||||
</head>
|
||||
<body class="login-page">
|
||||
<div class="tech-bg" aria-hidden="true">
|
||||
<div class="tech-grid"></div>
|
||||
<div class="tech-glow"></div>
|
||||
<div class="tech-glow-2"></div>
|
||||
<div class="tech-scanline"></div>
|
||||
</div>
|
||||
<div class="login-wrap">
|
||||
<div class="theme-row">
|
||||
<div class="theme-switch" role="group" aria-label="主题模式">
|
||||
<button type="button" class="theme-switch-btn" data-theme-pick="dark">深色</button>
|
||||
<button type="button" class="theme-switch-btn" data-theme-pick="light">浅色</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login-box">
|
||||
<h2>国内期货 · 交易复盘系统</h2>
|
||||
<p class="login-sub">Position Management · Disciplined Execution</p>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}<div class="flash">{{ messages[0] }}</div>{% endif %}
|
||||
{% endwith %}
|
||||
<form method="POST">
|
||||
<div class="form-group">
|
||||
<label>账号</label>
|
||||
<input type="text" name="username" required placeholder="请输入账号">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>密码</label>
|
||||
<input type="password" name="password" required placeholder="请输入密码">
|
||||
</div>
|
||||
<button type="submit">登录系统</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script src="{{ url_for('static', filename='js/pwa.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,172 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}行情K线 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<div class="card market-card">
|
||||
<h2>行情 K 线</h2>
|
||||
<form class="market-toolbar" id="market-form" onsubmit="return false;">
|
||||
<div class="symbol-wrap market-symbol-wrap">
|
||||
<input type="text" class="symbol-input" id="market-symbol-input" placeholder="点击选择主力合约,或输入搜索" autocomplete="off" value="{{ symbol }}">
|
||||
<input type="hidden" name="symbol" id="market-symbol-hidden" value="{{ symbol }}">
|
||||
<input type="hidden" name="symbol_name" id="market-symbol-name">
|
||||
<input type="hidden" name="market_code" id="market-market-code">
|
||||
<input type="hidden" name="sina_code" id="market-sina-code">
|
||||
<div class="symbol-dropdown"></div>
|
||||
<div class="symbol-selected" id="market-symbol-selected"></div>
|
||||
</div>
|
||||
<div class="market-period-tabs" id="market-period-tabs">
|
||||
{% for p in market_periods %}
|
||||
<button type="button" class="period-tab{% if p.key == period %} active{% endif %}" data-period="{{ p.key }}">{{ p.label }}</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<button type="button" class="btn-primary" id="market-load-btn">查看</button>
|
||||
</form>
|
||||
<div class="market-quote" id="market-quote">
|
||||
<span class="market-quote-name" id="market-quote-name">—</span>
|
||||
<span class="market-quote-price" id="market-quote-price">—</span>
|
||||
<span class="market-quote-prev text-muted" id="market-quote-prev"></span>
|
||||
<span class="market-quote-meta text-muted" id="market-quote-meta"></span>
|
||||
</div>
|
||||
<div class="market-chart-toolbar">
|
||||
<div class="market-chart-options">
|
||||
<label class="chart-opt"><input type="checkbox" id="chart-opt-prev-close">昨收线</label>
|
||||
<label class="chart-opt"><input type="checkbox" id="chart-opt-ma">EMA</label>
|
||||
<span class="chart-ema-periods" id="chart-ema-periods">
|
||||
<input type="number" class="chart-ema-input" id="chart-ema-fast" value="21" min="2" max="500" step="1" title="快线周期" aria-label="EMA快线周期">
|
||||
<span class="chart-ema-sep">/</span>
|
||||
<input type="number" class="chart-ema-input" id="chart-ema-slow" value="55" min="2" max="500" step="1" title="慢线周期" aria-label="EMA慢线周期">
|
||||
</span>
|
||||
<label class="chart-opt"><input type="checkbox" id="chart-opt-gap-day">间隔日</label>
|
||||
</div>
|
||||
<div class="market-chart-zoom">
|
||||
<button type="button" class="chart-zoom-btn" id="chart-zoom-in" title="放大">+</button>
|
||||
<button type="button" class="chart-zoom-btn" id="chart-zoom-out" title="缩小">-</button>
|
||||
<button type="button" class="chart-zoom-btn chart-zoom-reset" id="chart-zoom-reset">重置</button>
|
||||
</div>
|
||||
<span class="market-refresh-hint text-muted" id="market-refresh-hint"></span>
|
||||
</div>
|
||||
<div class="market-chart-auto-row">
|
||||
<button type="button" class="chart-auto-btn is-active" id="market-auto-btn" title="开启后自动跟随最新 K 线">自动</button>
|
||||
<span class="hint market-auto-hint">关闭后可自由拖动查看历史,刷新时只更新最新 K 线,不重置视图</span>
|
||||
</div>
|
||||
<div class="market-chart-wrap" id="market-chart-wrap">
|
||||
<div id="market-chart" class="market-chart" aria-label="K线图"></div>
|
||||
<div class="market-chart-empty" id="market-chart-empty">请选择合约并点击「查看」</div>
|
||||
<div class="market-chart-loading" id="market-chart-loading">连接中…</div>
|
||||
</div>
|
||||
<p class="hint">图表引擎:TradingView Lightweight Charts(红跌绿涨)。K 线与报价均使用<strong>新浪</strong>数据。滚轮缩放、拖拽平移;关闭「自动」后拖动查看历史时,推送更新不会重置画面。</p>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.market-card{overflow:visible}
|
||||
.market-card h2{margin-bottom:.75rem}
|
||||
.market-toolbar{
|
||||
display:flex;flex-wrap:wrap;gap:.65rem;align-items:flex-end;
|
||||
margin-bottom:.75rem;position:relative;z-index:2;
|
||||
min-height:2.5rem;
|
||||
}
|
||||
.market-symbol-wrap{flex:1;min-width:200px;max-width:360px;z-index:3}
|
||||
.market-symbol-wrap .symbol-dropdown{max-height:min(70vh,420px)}
|
||||
.market-symbol-wrap .symbol-selected{display:none}
|
||||
.market-period-tabs{display:flex;flex-wrap:wrap;gap:.35rem;align-items:center}
|
||||
.period-tab{
|
||||
padding:.4rem .65rem;border-radius:999px;
|
||||
border:1px solid var(--input-border);
|
||||
background:var(--toggle-bg);color:var(--text-muted);
|
||||
font-size:.78rem;cursor:pointer;width:auto;white-space:nowrap;
|
||||
}
|
||||
.period-tab:hover{border-color:var(--accent);color:var(--accent)}
|
||||
.period-tab.active{
|
||||
background:linear-gradient(135deg,var(--accent),var(--accent-2));
|
||||
border-color:transparent;color:#fff;
|
||||
}
|
||||
#market-load-btn{width:auto;padding:.55rem 1.25rem;font-size:.85rem}
|
||||
.market-quote{
|
||||
display:flex;flex-wrap:wrap;align-items:baseline;gap:.5rem 1rem;
|
||||
margin-bottom:.75rem;padding:.65rem .85rem;
|
||||
background:var(--card-inner);border-radius:10px;border:1px solid var(--card-border);
|
||||
min-height:2.75rem;
|
||||
}
|
||||
.market-quote-name{font-weight:600;color:var(--text-title)}
|
||||
.market-quote-price{font-size:1.35rem;font-weight:700;color:var(--accent);font-variant-numeric:tabular-nums}
|
||||
.market-quote-prev{font-size:.78rem}
|
||||
.market-chart-toolbar{
|
||||
display:flex;align-items:center;justify-content:space-between;gap:.75rem;
|
||||
margin-bottom:.5rem;flex-wrap:wrap;
|
||||
min-height:2rem;
|
||||
}
|
||||
.market-chart-options{display:flex;flex-wrap:wrap;gap:.5rem .85rem;align-items:center}
|
||||
.chart-opt{
|
||||
display:flex;align-items:center;gap:.35rem;font-size:.78rem;
|
||||
color:var(--text-muted);cursor:pointer;user-select:none;
|
||||
}
|
||||
.chart-opt input{width:auto;margin:0;cursor:pointer}
|
||||
.chart-ema-periods{display:flex;align-items:center;gap:.25rem;font-size:.78rem;color:var(--text-muted)}
|
||||
.chart-ema-input{
|
||||
width:3.1rem;padding:.28rem .35rem;border-radius:6px;
|
||||
border:1px solid var(--input-border);background:var(--toggle-bg);
|
||||
color:var(--text-primary);font-size:.78rem;font-variant-numeric:tabular-nums;
|
||||
}
|
||||
.chart-ema-input:disabled{opacity:.45;cursor:not-allowed}
|
||||
.chart-ema-sep{opacity:.6}
|
||||
.market-chart-zoom{display:flex;gap:.35rem;align-items:center}
|
||||
.chart-zoom-btn{
|
||||
width:32px;height:32px;padding:0;border-radius:8px;
|
||||
border:1px solid var(--input-border);background:var(--toggle-bg);
|
||||
color:var(--text-primary);font-size:1rem;line-height:1;cursor:pointer;
|
||||
}
|
||||
.chart-zoom-btn:hover{border-color:var(--accent);color:var(--accent)}
|
||||
.chart-zoom-reset{width:auto;padding:0 .65rem;font-size:.75rem}
|
||||
.market-refresh-hint{font-size:.72rem}
|
||||
.market-chart-auto-row{
|
||||
display:flex;align-items:center;gap:.65rem;flex-wrap:wrap;
|
||||
margin-bottom:.5rem;
|
||||
}
|
||||
.chart-auto-btn{
|
||||
padding:.38rem .85rem;border-radius:999px;
|
||||
border:1px solid var(--input-border);background:var(--toggle-bg);
|
||||
color:var(--text-muted);font-size:.78rem;cursor:pointer;width:auto;
|
||||
}
|
||||
.chart-auto-btn:hover{border-color:var(--accent);color:var(--accent)}
|
||||
.chart-auto-btn.is-active{
|
||||
background:linear-gradient(135deg,var(--accent),var(--accent-2));
|
||||
border-color:transparent;color:#fff;
|
||||
}
|
||||
.market-auto-hint{font-size:.72rem;margin:0}
|
||||
.market-chart-wrap{
|
||||
position:relative;border-radius:12px;border:1px solid var(--card-border);
|
||||
background:var(--card-inner);
|
||||
height:min(68vh,560px);min-height:420px;
|
||||
}
|
||||
.market-chart{width:100%;height:100%}
|
||||
.market-chart-empty,
|
||||
.market-chart-loading{
|
||||
position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
|
||||
color:var(--text-muted);font-size:.9rem;pointer-events:none;
|
||||
}
|
||||
.market-chart-loading{display:none}
|
||||
html[data-theme="light"] .market-chart-loading{background:rgba(244,247,252,.75)}
|
||||
.market-chart-wrap.has-data .market-chart-empty{display:none}
|
||||
.market-chart-wrap.loading .market-chart-loading{
|
||||
display:flex;background:rgba(10,12,20,.35);
|
||||
}
|
||||
html[data-theme="light"] .market-chart-wrap.loading .market-chart-loading{background:rgba(244,247,252,.75)}
|
||||
.market-chart-wrap.loading .market-chart-empty{display:none}
|
||||
@media(max-width:767px){
|
||||
.market-toolbar{align-items:stretch}
|
||||
.market-symbol-wrap{max-width:none}
|
||||
.market-period-tabs{order:3;width:100%}
|
||||
#market-load-btn{order:4;width:100%}
|
||||
.market-chart-wrap{min-height:300px;height:50vh}
|
||||
.market-chart-toolbar{flex-direction:column;align-items:stretch}
|
||||
.market-chart-options{order:1}
|
||||
.market-chart-zoom{order:2}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
|
||||
<script src="{{ url_for('static', filename='js/market.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,102 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}开单计划 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block content %}
|
||||
<div class="split-grid">
|
||||
<div class="card">
|
||||
<h2>今日计划 <span class="text-muted" style="font-size:.8rem;font-weight:normal">今日 {{ today }}</span></h2>
|
||||
<div class="card-body">
|
||||
<p class="hint" style="margin-bottom:.75rem">开盘前制定,当日有效;请先选择<strong>主力合约</strong>,下方为进行中计划。</p>
|
||||
<form action="{{ url_for('add_plan') }}" method="post" class="form-compact">
|
||||
<div class="form-line line-plan-1">
|
||||
<div class="symbol-wrap symbol-mains">
|
||||
<input type="text" class="symbol-input" placeholder="主力合约" autocomplete="off" required>
|
||||
<input type="hidden" name="symbol" required>
|
||||
<input type="hidden" name="symbol_name">
|
||||
<input type="hidden" name="market_code" required>
|
||||
<input type="hidden" name="sina_code">
|
||||
<div class="symbol-dropdown"></div>
|
||||
<div class="symbol-selected"></div>
|
||||
</div>
|
||||
<select name="direction" class="field-short" required>
|
||||
<option value="">方向</option>
|
||||
<option value="long">做多</option>
|
||||
<option value="short">做空</option>
|
||||
</select>
|
||||
<input name="decision_reason" type="text" placeholder="决策理由">
|
||||
</div>
|
||||
<div class="form-line line-plan-2">
|
||||
<input name="zone_lower" type="number" step="0.0001" placeholder="决策区间下限" required>
|
||||
<input name="zone_upper" type="number" step="0.0001" placeholder="决策区间上限" required>
|
||||
<input name="stop_loss" type="number" step="0.0001" placeholder="止损" required>
|
||||
<input name="take_profit" type="number" step="0.0001" placeholder="止盈" required>
|
||||
<button type="submit" class="btn-primary">添加</button>
|
||||
</div>
|
||||
</form>
|
||||
<h3 class="section-label">进行中</h3>
|
||||
<div class="list card-scroll" id="plan-monitor-list">
|
||||
{% for p in plans %}
|
||||
<div class="list-item key-item plan-item" data-plan-id="{{ p.id }}" style="padding:.75rem;font-size:.85rem">
|
||||
<div>
|
||||
<strong>{{ p.symbol_name or p.symbol }}</strong>
|
||||
<span class="badge dir">{{ '多' if p.direction == 'long' else '空' }}</span>
|
||||
{% if p.status == 'planned' %}<span class="badge planned">待触发</span>
|
||||
{% else %}<span class="badge active">已激活</span>{% endif %}
|
||||
</div>
|
||||
<div class="key-live">
|
||||
<span class="live-price-line">现价:<span class="live-price">--</span></span>
|
||||
<span class="live-dist">距上<span class="dist-up">--</span> 距下<span class="dist-down">--</span></span>
|
||||
</div>
|
||||
<div>
|
||||
区间{{ p.zone_lower }}~{{ p.zone_upper }}
|
||||
{% if p.decision_reason %} · {{ p.decision_reason }}{% endif %}
|
||||
· 损{{ p.stop_loss }} 盈{{ p.take_profit }}
|
||||
</div>
|
||||
<a href="{{ url_for('del_plan', pid=p.id) }}" class="btn-del" onclick="return confirm('删除?')">删</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="empty-hint">今日暂无进行中的计划</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>历史计划</h2>
|
||||
<div class="card-body">
|
||||
<form method="get" class="filter-row">
|
||||
<div class="field"><label>开始</label><input type="date" name="start" value="{{ start }}"></div>
|
||||
<div class="field"><label>结束</label><input type="date" name="end" value="{{ end }}"></div>
|
||||
<button type="submit" class="btn-primary">筛选</button>
|
||||
<a href="{{ url_for('plans') }}" class="text-muted" style="font-size:.85rem;padding:.7rem">重置</a>
|
||||
</form>
|
||||
<div class="card-scroll">
|
||||
<table>
|
||||
<thead><tr><th>日期</th><th>品种</th><th>方向</th><th>决策区间</th><th>决策理由</th><th>状态</th></tr></thead>
|
||||
<tbody>
|
||||
{% for p in history %}
|
||||
<tr>
|
||||
<td>{{ p.plan_date or '' }}</td>
|
||||
<td>{{ p.symbol_name or p.symbol }}</td>
|
||||
<td><span class="badge dir">{{ '多' if p.direction == 'long' else '空' }}</span></td>
|
||||
<td>{{ p.zone_lower }}~{{ p.zone_upper }}</td>
|
||||
<td>{{ p.decision_reason or '—' }}</td>
|
||||
<td>
|
||||
{% if p.status == 'closed' %}<span class="badge profit">完成</span>
|
||||
{% elif p.status == 'expired' %}<span class="badge expired">失效</span>
|
||||
{% else %}{{ p.status }}{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="6" class="text-muted">暂无历史</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/plans.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,48 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}持仓监控 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block content %}
|
||||
<div class="split-grid">
|
||||
<div class="card">
|
||||
<h2>持仓录入</h2>
|
||||
<div class="card-body">
|
||||
<form action="{{ url_for('add_position') }}" method="post" class="form-compact">
|
||||
<div class="form-line line-3">
|
||||
<div class="symbol-wrap">
|
||||
<input type="text" class="symbol-input" placeholder="主力合约" autocomplete="off" required>
|
||||
<input type="hidden" name="symbol" required>
|
||||
<input type="hidden" name="symbol_name">
|
||||
<input type="hidden" name="market_code" required>
|
||||
<input type="hidden" name="sina_code">
|
||||
<div class="symbol-dropdown"></div>
|
||||
<div class="symbol-selected"></div>
|
||||
</div>
|
||||
<input type="datetime-local" name="open_time" required title="开仓时间">
|
||||
<input name="lots" type="number" step="1" min="1" value="1" placeholder="张数" required>
|
||||
</div>
|
||||
<div class="form-line line-3">
|
||||
<input name="entry_price" type="number" step="0.0001" placeholder="成交价格" required>
|
||||
<input name="stop_loss" type="number" step="0.0001" placeholder="止损" required>
|
||||
<input name="take_profit" type="number" step="0.0001" placeholder="止盈" required>
|
||||
</div>
|
||||
<div class="form-line line-btn">
|
||||
<button type="submit" class="btn-primary">添加持仓</button>
|
||||
</div>
|
||||
</form>
|
||||
<p class="hint" style="margin-top:.5rem">方向根据止损与成交价自动判断;风险比例依赖系统设置中的实盘资金。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>实时持仓</h2>
|
||||
<div class="card-body card-scroll" id="position-live-list">
|
||||
{% if not positions %}
|
||||
<div class="empty-hint">暂无持仓,左侧录入后显示</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/positions.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,33 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}可开仓品种 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block content %}
|
||||
<div class="card">
|
||||
<h2>可开仓品种 · 按资金筛选</h2>
|
||||
<p class="hint">当前权益 <strong class="text-accent">{{ '%.2f'|format(capital) }}</strong> 元({{ trading_mode_label }})。
|
||||
优先展示可开 1 手且 1% 风险规则下较友好的品种;灰色为保证金不足。</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="trade-table-wrap">
|
||||
<table class="trade-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>品种</th><th>交易所</th><th>参考价</th><th>1手保证金</th><th>建议最低资金</th><th>状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for r in rows %}
|
||||
<tr class="rec-{{ r.status }}">
|
||||
<td><strong>{{ r.name }}</strong> <span class="text-muted">{{ r.ths }}</span></td>
|
||||
<td>{{ r.exchange }}</td>
|
||||
<td>{% if r.price %}{{ r.price }}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.margin_one_lot %}{{ r.margin_one_lot }}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.min_capital_one_lot %}{{ r.min_capital_one_lot }}{% else %}—{% endif %}</td>
|
||||
<td><span class="badge {% if r.status=='ok' %}profit{% elif r.status=='blocked' %}loss{% else %}planned{% endif %}">{{ r.status_label }}</span></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,529 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}交易记录与复盘 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/records.css') }}?v={{ asset_v }}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% macro trade_detail_json(t) -%}
|
||||
{{ {
|
||||
"id": t.id,
|
||||
"symbol": t.symbol_name or t.symbol,
|
||||
"symbol_code": t.symbol,
|
||||
"symbol_name": t.symbol_name or t.symbol,
|
||||
"monitor_type": t.monitor_type,
|
||||
"source": "柜台" if t.source == "ctp" else "本地",
|
||||
"direction": "做多" if t.direction == "long" else "做空",
|
||||
"direction_code": t.direction,
|
||||
"entry_price": t.entry_price,
|
||||
"close_price": t.close_price,
|
||||
"stop_loss": t.stop_loss,
|
||||
"take_profit": t.take_profit,
|
||||
"lots": t.lots,
|
||||
"margin": t.margin,
|
||||
"margin_pct": t.margin_pct,
|
||||
"holding_minutes": t.holding_minutes or 0,
|
||||
"open_time": t.open_time,
|
||||
"close_time": t.close_time,
|
||||
"pnl": t.pnl,
|
||||
"fee": t.fee,
|
||||
"pnl_net": t.pnl_net,
|
||||
"equity_after": t.equity_after,
|
||||
"result": t.result,
|
||||
"verified": t.verified,
|
||||
"fill_review_url": url_for("fill_review_from_trade", tid=t.id),
|
||||
"del_url": url_for("del_trade", tid=t.id)
|
||||
} | tojson }}
|
||||
{%- endmacro %}
|
||||
{% macro trade_symbol_cell(t) %}
|
||||
<div class="dash-symbol-cell">
|
||||
<div class="dash-symbol-title">
|
||||
{{ t.symbol_name or t.symbol }}
|
||||
{% if t.symbol_exchange %}<span class="dash-symbol-ex text-muted">{{ t.symbol_exchange }}</span>{% endif %}
|
||||
{% if t.symbol_is_main %}<span class="badge planned dash-main-badge">主力</span>{% endif %}
|
||||
{% if t.symbol and (t.symbol_name or '')|lower != (t.symbol or '')|lower %}
|
||||
<span class="text-accent">{{ t.symbol }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
{% macro trade_pnl_cell(v) %}
|
||||
{% if v is not none %}{% set n = v|float %}<span class="{% if n > 0 %}pnl-pos{% elif n < 0 %}pnl-neg{% endif %}">{{ ('+' if n > 0 else '') ~ ('%.2f'|format(n)) }} 元</span>{% else %}—{% endif %}
|
||||
{% endmacro %}
|
||||
{% macro trade_edit_json(t) -%}
|
||||
{{ {
|
||||
"id": t.id,
|
||||
"symbol_name": t.symbol_name or t.symbol,
|
||||
"monitor_type": t.monitor_type,
|
||||
"direction": t.direction,
|
||||
"entry_price": t.entry_price,
|
||||
"close_price": t.close_price,
|
||||
"stop_loss": t.stop_loss,
|
||||
"take_profit": t.take_profit,
|
||||
"lots": t.lots,
|
||||
"margin": t.margin,
|
||||
"holding_minutes": t.holding_minutes or 0,
|
||||
"open_time": t.open_time,
|
||||
"close_time": t.close_time,
|
||||
"pnl": t.pnl,
|
||||
"result": t.result,
|
||||
}|tojson }}
|
||||
{%- endmacro %}
|
||||
{% macro trade_review_edit_btn(t) %}
|
||||
<button
|
||||
type="button"
|
||||
class="btn-records-action review-edit-btn"
|
||||
data-trade-edit='{{ trade_edit_json(t)|trim }}'
|
||||
disabled
|
||||
>核对修改</button>
|
||||
{% endmacro %}
|
||||
{% macro trade_verify_form(t) %}
|
||||
{{ trade_review_edit_btn(t) }}
|
||||
{% endmacro %}
|
||||
{% macro trade_row_actions(t, detail_class) %}
|
||||
<div class="trade-actions records-trade-row-actions">
|
||||
<button type="button" class="btn-link {{ detail_class }}">详情</button>
|
||||
<a href="{{ url_for('fill_review_from_trade', tid=t.id) }}" class="btn-records-action">填入复盘</a>
|
||||
{{ trade_review_edit_btn(t) }}
|
||||
<a href="{{ url_for('del_trade', tid=t.id) }}" class="btn-records-del" onclick="return confirm('删除?')">删除</a>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
<div class="records-page">
|
||||
<div class="card records-equity-card" style="margin-bottom:1.25rem">
|
||||
<h2>资金曲线</h2>
|
||||
<div class="card-body">
|
||||
<div id="equity-curve-chart" style="width:100%;min-height:220px;overflow:hidden"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card records-trade-card" style="margin-bottom:1.25rem">
|
||||
<h2>交易记录</h2>
|
||||
<div class="card-body">
|
||||
{% if ctp_sync_info and ctp_sync_info.connected %}
|
||||
<p class="hint" style="margin-top:0">
|
||||
已连接 CTP,本页已自动同步柜台成交(新增 {{ ctp_sync_info.synced or 0 }} 条,更新 {{ ctp_sync_info.updated or 0 }} 条)。
|
||||
带来源「柜台」的记录以交易所成交为准;「本地」为程序写入,可手动删除错误项。
|
||||
</p>
|
||||
{% else %}
|
||||
<p class="hint" style="margin-top:0">CTP 未连接时仅显示本地数据库记录;连接后打开本页会自动同步柜台成交。</p>
|
||||
{% endif %}
|
||||
<p class="hint" style="margin-top:0;margin-bottom:.75rem">
|
||||
跨日持仓的盈亏以<strong>平仓价</strong>与柜台结算为准;表格中「开仓价」为程序记录,「平仓价」为成交回报,二者不一致时请以平仓价核对净盈亏。
|
||||
</p>
|
||||
<label class="trade-switch-label records-verify-toggle">
|
||||
<input type="checkbox" id="trade-edit-switch">
|
||||
<span>修改/核对开关(开启后可点击各行「核对修改」)</span>
|
||||
</label>
|
||||
<div class="records-mobile-list records-phone-only" id="records-trade-mobile">
|
||||
{% for t in trades %}
|
||||
{% set trade_pnl = t.pnl_net if t.pnl_net is not none else t.pnl %}
|
||||
{% set trade_px = t.close_price if t.close_price else t.entry_price %}
|
||||
{% set pnl_cls = 'is-profit' if trade_pnl and trade_pnl > 0 else ('is-loss' if trade_pnl and trade_pnl < 0 else 'is-flat') %}
|
||||
<div class="records-trade-row" data-trade-id="{{ t.id }}" data-trade='{{ trade_detail_json(t)|trim }}'>
|
||||
<div class="records-trade-main">
|
||||
<div class="records-trade-head">
|
||||
<span class="records-trade-title">
|
||||
<span class="records-mobile-symbol">{{ t.symbol_name or t.symbol }}</span>
|
||||
{% if t.symbol and (t.symbol_name or '')|lower != (t.symbol or '')|lower %}
|
||||
<span class="text-accent records-trade-code">{{ t.symbol }}</span>
|
||||
{% endif %}
|
||||
<span class="badge dir">{{ '做多' if t.direction == 'long' else '做空' }}</span>
|
||||
{% if t.verified %}<span class="badge active records-verified-badge">已核对</span>{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<div class="records-trade-summary">
|
||||
{{ (t.lots or 0)|int }}手 平仓 {{ trade_px if trade_px is not none else '-' }}
|
||||
盈亏 <span class="records-mobile-pnl {{ pnl_cls }}">{{ trade_pnl if trade_pnl is not none else '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="records-trade-phone-foot">
|
||||
<span class="records-mobile-chevron">详情 ›</span>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="records-mobile-empty">暂无交易记录</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="card-scroll records-trade-table-wrap records-tablet-only">
|
||||
<table class="dashboard-table records-trade-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>品种</th>
|
||||
<th>方向</th>
|
||||
<th>手数</th>
|
||||
<th>开仓</th>
|
||||
<th>平仓</th>
|
||||
<th>盈亏</th>
|
||||
<th>净盈亏</th>
|
||||
<th>平仓时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for t in trades %}
|
||||
<tr data-trade-id="{{ t.id }}" data-trade='{{ trade_detail_json(t)|trim }}'>
|
||||
<td>{{ trade_symbol_cell(t) }}</td>
|
||||
<td>
|
||||
<span class="badge dir {% if t.direction == 'long' %}dir-long{% else %}dir-short{% endif %}">
|
||||
{{ '做多' if t.direction == 'long' else '做空' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{% if t.lots is not none %}{{ '%.2f'|format(t.lots|float) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if t.entry_price is not none %}{{ '%.2f'|format(t.entry_price|float) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if t.close_price is not none %}{{ '%.2f'|format(t.close_price|float) }}{% elif t.entry_price is not none %}{{ '%.2f'|format(t.entry_price|float) }}{% else %}—{% endif %}</td>
|
||||
<td>{{ trade_pnl_cell(t.pnl) }}</td>
|
||||
<td>{{ trade_pnl_cell(t.pnl_net) }}</td>
|
||||
<td>{{ (t.close_time or '')[:16].replace('T', ' ') or '—' }}</td>
|
||||
<td>{{ trade_row_actions(t, 'records-tablet-detail-btn') }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="9" class="text-muted">暂无交易记录</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="trade-table-wrap records-desktop-only">
|
||||
<table class="trade-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>品种</th><th>类型</th><th>方向</th>
|
||||
<th>开仓价</th><th>平仓价</th><th>止损(开仓)</th><th>止盈</th>
|
||||
<th>手数</th><th>保证金</th><th>保证金占比</th><th>持仓分钟</th>
|
||||
<th>开仓时间</th><th>平仓时间</th>
|
||||
<th>盈亏(元)</th><th>手续费</th><th>净盈亏</th><th>最新资金</th><th>结果</th><th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for t in trades %}
|
||||
<tr id="trade-row-{{ t.id }}" data-trade-id="{{ t.id }}">
|
||||
<td><span class="cell-readonly">{{ t.symbol_name or t.symbol }}</span></td>
|
||||
<td>
|
||||
<span class="cell-readonly">{{ t.monitor_type }}</span>
|
||||
{% if t.source == 'ctp' %}
|
||||
<span class="badge records-src-badge">柜台</span>
|
||||
{% else %}
|
||||
<span class="text-muted records-src-badge">本地</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge dir {% if t.direction == 'long' %}dir-long{% else %}dir-short{% endif %}">
|
||||
{{ '做多' if t.direction == 'long' else '做空' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{% if t.entry_price is not none %}{{ '%.2f'|format(t.entry_price|float) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if t.close_price is not none %}{{ '%.2f'|format(t.close_price|float) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if t.stop_loss is not none %}{{ '%.2f'|format(t.stop_loss|float) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if t.take_profit is not none %}{{ '%.2f'|format(t.take_profit|float) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if t.lots is not none %}{{ '%.2f'|format(t.lots|float) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if t.margin is not none %}{{ '%.2f'|format(t.margin|float) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if t.margin_pct is not none %}{{ t.margin_pct }}%{% else %}—{% endif %}</td>
|
||||
<td>{{ t.holding_minutes or 0 }}</td>
|
||||
<td>{{ (t.open_time or '')[:16].replace('T',' ') or '—' }}</td>
|
||||
<td>{{ (t.close_time or '')[:16].replace('T',' ') or '—' }}</td>
|
||||
<td>
|
||||
<span class="{% if t.pnl and t.pnl > 0 %}text-profit{% elif t.pnl and t.pnl < 0 %}text-loss{% endif %}">
|
||||
{{ t.pnl if t.pnl is not none else '—' }}
|
||||
</span>
|
||||
</td>
|
||||
<td><span class="text-muted">{{ t.fee if t.fee is not none else '—' }}</span></td>
|
||||
<td>
|
||||
<span class="{% if t.pnl_net and t.pnl_net > 0 %}text-profit{% elif t.pnl_net and t.pnl_net < 0 %}text-loss{% endif %}">
|
||||
{{ t.pnl_net if t.pnl_net is not none else '—' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ t.equity_after if t.equity_after is not none else '—' }}</td>
|
||||
<td>
|
||||
{% if t.result == '止盈' %}<span class="badge profit">{{ t.result }}</span>
|
||||
{% elif t.result == '止损' %}<span class="badge loss">{{ t.result }}</span>
|
||||
{% elif t.result == '移动止盈' %}<span class="badge profit">{{ t.result }}</span>
|
||||
{% elif t.result == '保本止盈' %}<span class="badge profit">{{ t.result }}</span>
|
||||
{% elif t.result == '手动平仓' %}<span class="badge result-manual">{{ t.result }}</span>
|
||||
{% else %}<span class="badge result-external">{{ t.result }}</span>{% endif %}
|
||||
{% if t.verified %}<span class="badge active records-verified-inline">已核对</span>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="trade-actions records-trade-actions">
|
||||
<a href="{{ url_for('fill_review_from_trade', tid=t.id) }}" class="btn-records-action">填入复盘</a>
|
||||
{{ trade_review_edit_btn(t) }}
|
||||
<a href="{{ url_for('del_trade', tid=t.id) }}" class="btn-records-del" onclick="return confirm('删除?')">删除</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="19" class="text-muted">暂无交易记录</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="split-grid records-split">
|
||||
<div class="card" id="review-panel">
|
||||
<h2>复盘上传</h2>
|
||||
<div class="card-body">
|
||||
<form id="review-form" action="{{ url_for('add_review') }}" method="post" enctype="multipart/form-data" class="form-compact form-compact-review line-tight">
|
||||
<div class="form-line line-4">
|
||||
<div class="symbol-wrap">
|
||||
<input type="text" class="symbol-input" placeholder="品种" autocomplete="off" required>
|
||||
<input type="hidden" name="symbol" required>
|
||||
<input type="hidden" name="symbol_name">
|
||||
<input type="hidden" name="market_code" required>
|
||||
<input type="hidden" name="sina_code">
|
||||
<div class="symbol-dropdown"></div>
|
||||
<div class="symbol-selected"></div>
|
||||
</div>
|
||||
<select name="direction" required>
|
||||
<option value="">方向</option>
|
||||
<option value="long">做多</option>
|
||||
<option value="short">做空</option>
|
||||
</select>
|
||||
<input name="lots" type="number" step="1" min="1" value="1" placeholder="张数" required>
|
||||
<input name="timeframe" value="5m" placeholder="周期">
|
||||
</div>
|
||||
<div class="form-line line-4">
|
||||
<input name="entry_price" type="number" step="0.0001" placeholder="成交价" required>
|
||||
<input name="stop_loss" type="number" step="0.0001" placeholder="止损" required>
|
||||
<input name="take_profit" type="number" step="0.0001" placeholder="止盈" required>
|
||||
<input name="close_price" type="number" step="0.0001" placeholder="平仓价" required>
|
||||
</div>
|
||||
<div class="form-line line-4">
|
||||
<div class="mini-field"><span>开仓时间</span><input type="datetime-local" name="open_time" required></div>
|
||||
<div class="mini-field"><span>平仓时间</span><input type="datetime-local" name="close_time" required></div>
|
||||
<input id="holding_duration" type="text" readonly class="calc-readonly" placeholder="持仓时长(自动)">
|
||||
<input name="pnl" type="number" step="0.01" placeholder="盈亏金额(手动)">
|
||||
</div>
|
||||
<div class="form-line line-2">
|
||||
<input id="initial_rr" type="text" readonly class="calc-readonly" placeholder="初始盈亏比(自动)">
|
||||
<input id="actual_rr" type="text" readonly class="calc-readonly" placeholder="实际盈亏比(自动)">
|
||||
</div>
|
||||
<div class="form-line line-4">
|
||||
<select name="open_type" required>
|
||||
<option value="">开仓类型</option>
|
||||
{% for t in open_types %}<option value="{{ t }}">{{ t }}</option>{% endfor %}
|
||||
</select>
|
||||
<select name="exit_trigger" required>
|
||||
<option value="">离场触发</option>
|
||||
{% for t in exit_triggers %}<option value="{{ t }}">{{ t }}</option>{% endfor %}
|
||||
</select>
|
||||
<input name="exit_supplement" placeholder="离场补充">
|
||||
<select name="watch_after_breakeven" title="保本后盯盘">
|
||||
<option value="否">保本盯盘:否</option>
|
||||
<option value="是">保本盯盘:是</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-line line-4">
|
||||
<select name="new_position_while_occupied" title="占用时新开仓">
|
||||
<option value="否">占用新开:否</option>
|
||||
<option value="是">占用新开:是</option>
|
||||
</select>
|
||||
<input type="file" name="screenshot" accept="image/*" title="截图上传">
|
||||
<textarea name="notes" placeholder="备注" rows="1"></textarea>
|
||||
<button type="submit" class="btn-primary">保存</button>
|
||||
</div>
|
||||
<div class="kline-row">
|
||||
<label><input type="checkbox" name="auto_kline" value="1" checked> 自动K线</label>
|
||||
<select name="kline_period1" title="周期1">{% for p in kline_periods %}<option value="{{ p }}" {% if p=='15m' %}selected{% endif %}>{{ p }}</option>{% endfor %}</select>
|
||||
<select name="kline_period2" title="周期2">{% for p in kline_periods %}<option value="{{ p }}" {% if p=='1h' %}selected{% endif %}>{{ p }}</option>{% endfor %}</select>
|
||||
<input name="kline_count" type="number" value="300" placeholder="K线数" title="K线数">
|
||||
<select name="kline_cutoff" title="K线截止">{% for c in kline_cutoffs %}<option value="{{ c }}">{{ c }}</option>{% endfor %}</select>
|
||||
</div>
|
||||
<p class="section-hint">勾选行为标签即为情绪单</p>
|
||||
<div class="tag-grid">
|
||||
{% for tag in behavior_tags %}
|
||||
<label><input type="checkbox" name="tag_{{ tag }}" value="1"> {{ tag }}</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>复盘历史</h2>
|
||||
<div class="card-body">
|
||||
<div class="preset-tabs">
|
||||
<a href="{{ url_for('records', preset='today') }}" class="{% if preset=='today' %}active{% endif %}">本日</a>
|
||||
<a href="{{ url_for('records', preset='week') }}" class="{% if preset=='week' %}active{% endif %}">本周</a>
|
||||
<a href="{{ url_for('records', preset='month') }}" class="{% if preset=='month' %}active{% endif %}">本月</a>
|
||||
<a href="{{ url_for('records', preset='custom') }}" class="{% if preset=='custom' %}active{% endif %}">自定义</a>
|
||||
</div>
|
||||
{% if preset == 'custom' or start or end %}
|
||||
<form method="get" class="filter-row">
|
||||
<input type="hidden" name="preset" value="custom">
|
||||
<div class="field"><label>开始</label><input type="date" name="start" value="{{ start }}"></div>
|
||||
<div class="field"><label>结束</label><input type="date" name="end" value="{{ end }}"></div>
|
||||
<button type="submit" class="btn-primary">筛选</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
<div class="records-mobile-list records-review-mobile">
|
||||
{% for r in reviews %}
|
||||
<button type="button" class="records-mobile-item review-view-btn{% if r.is_emotion %} is-emotion{% endif %}" data-review='{{ {
|
||||
"symbol": r.symbol_name or r.symbol, "symbol_code": r.symbol,
|
||||
"direction": "做多" if r.direction=="long" else "做空",
|
||||
"lots": r.lots, "timeframe": r.timeframe,
|
||||
"entry_price": r.entry_price, "stop_loss": r.stop_loss, "take_profit": r.take_profit,
|
||||
"close_price": r.close_price,
|
||||
"open_time": r.open_time, "close_time": r.close_time,
|
||||
"holding_duration": r.holding_duration,
|
||||
"initial_pnl": r.initial_pnl, "actual_pnl": r.actual_pnl, "pnl": r.pnl,
|
||||
"fee": r.fee, "pnl_net": r.pnl_net,
|
||||
"open_type": r.open_type,
|
||||
"exit_trigger": r.exit_trigger, "exit_supplement": r.exit_supplement,
|
||||
"watch_after_breakeven": r.watch_after_breakeven,
|
||||
"new_position_while_occupied": r.new_position_while_occupied,
|
||||
"is_emotion": r.is_emotion, "behavior_tags": r.behavior_tags,
|
||||
"notes": r.notes, "screenshot": r.screenshot
|
||||
} | tojson }}'>
|
||||
<div class="records-mobile-item-head">
|
||||
<span class="records-mobile-symbol">{{ r.symbol_name or r.symbol }}</span>
|
||||
<span class="badge dir">{{ '多' if r.direction == 'long' else '空' }}</span>
|
||||
</div>
|
||||
<div class="records-mobile-item-meta">
|
||||
<span>{{ r.close_time[:16].replace('T', ' ') if r.close_time else '' }}</span>
|
||||
{% if r.is_emotion %}<span class="badge emotion">情绪单</span>{% endif %}
|
||||
</div>
|
||||
<div class="records-mobile-item-foot">
|
||||
<span class="records-mobile-pnl {{ 'is-profit' if r.pnl_net and r.pnl_net > 0 else ('is-loss' if r.pnl_net and r.pnl_net < 0 else 'is-flat') }}">
|
||||
<span class="records-mobile-pnl-lbl">净盈亏 </span>{{ r.pnl_net if r.pnl_net is not none else '-' }}
|
||||
</span>
|
||||
<span class="records-mobile-chevron">详情 ›</span>
|
||||
</div>
|
||||
</button>
|
||||
{% else %}
|
||||
<p class="records-mobile-empty">暂无复盘记录</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="card-scroll records-desktop-only">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>平仓</th><th>品种</th><th>方向</th><th>盈亏</th><th>手续费</th><th>净盈亏</th><th>情绪单</th><th>详情</th><th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for r in reviews %}
|
||||
<tr class="{% if r.is_emotion %}row-emotion{% endif %}">
|
||||
<td>{{ r.close_time[:16] if r.close_time else '' }}</td>
|
||||
<td>{{ r.symbol_name or r.symbol }}</td>
|
||||
<td><span class="badge dir">{{ '多' if r.direction == 'long' else '空' }}</span></td>
|
||||
<td>
|
||||
{% if r.pnl and r.pnl > 0 %}<span class="badge profit">{{ r.pnl }}</span>
|
||||
{% elif r.pnl and r.pnl < 0 %}<span class="badge loss">{{ r.pnl }}</span>
|
||||
{% else %}{{ r.actual_pnl or '-' }}{% endif %}
|
||||
</td>
|
||||
<td class="text-muted">{{ r.fee if r.fee is not none else '-' }}</td>
|
||||
<td>
|
||||
{% if r.pnl_net and r.pnl_net > 0 %}<span class="badge profit">{{ r.pnl_net }}</span>
|
||||
{% elif r.pnl_net and r.pnl_net < 0 %}<span class="badge loss">{{ r.pnl_net }}</span>
|
||||
{% else %}-{% endif %}
|
||||
</td>
|
||||
<td>{% if r.is_emotion %}<span class="badge emotion">情绪单</span>{% else %}-{% endif %}</td>
|
||||
<td>
|
||||
<button type="button" class="btn-link review-view-btn" data-review='{{ {
|
||||
"symbol": r.symbol_name or r.symbol, "symbol_code": r.symbol,
|
||||
"direction": "做多" if r.direction=="long" else "做空",
|
||||
"lots": r.lots, "timeframe": r.timeframe,
|
||||
"entry_price": r.entry_price, "stop_loss": r.stop_loss, "take_profit": r.take_profit,
|
||||
"close_price": r.close_price,
|
||||
"open_time": r.open_time, "close_time": r.close_time,
|
||||
"holding_duration": r.holding_duration,
|
||||
"initial_pnl": r.initial_pnl, "actual_pnl": r.actual_pnl, "pnl": r.pnl,
|
||||
"fee": r.fee, "pnl_net": r.pnl_net,
|
||||
"open_type": r.open_type,
|
||||
"exit_trigger": r.exit_trigger, "exit_supplement": r.exit_supplement,
|
||||
"watch_after_breakeven": r.watch_after_breakeven,
|
||||
"new_position_while_occupied": r.new_position_while_occupied,
|
||||
"is_emotion": r.is_emotion, "behavior_tags": r.behavior_tags,
|
||||
"notes": r.notes, "screenshot": r.screenshot
|
||||
} | tojson }}'>放大查看</button>
|
||||
</td>
|
||||
<td><a href="{{ url_for('del_review', rid=r.id) }}" class="btn-del" onclick="return confirm('删除?')">删</a></td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="9" class="text-muted">暂无复盘记录</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="review-modal" class="modal-mask">
|
||||
<div class="modal-box review-modal-fullscreen">
|
||||
<span class="modal-close">✕</span>
|
||||
<h3>复盘详情</h3>
|
||||
<div id="review-modal-body" class="review-modal-body"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="trade-detail-modal" class="modal-mask">
|
||||
<div class="modal-box review-modal-fullscreen">
|
||||
<span class="modal-close">✕</span>
|
||||
<h3>交易详情</h3>
|
||||
<div id="trade-detail-modal-body" class="review-modal-body"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if auto_records %}
|
||||
<div class="card" style="margin-top:1rem">
|
||||
<h2>系统自动记录(止盈/止损)</h2>
|
||||
<table>
|
||||
<thead><tr><th>品种</th><th>类型</th><th>方向</th><th>触发价</th><th>结果</th><th>时间</th></tr></thead>
|
||||
<tbody>
|
||||
{% for r in auto_records %}
|
||||
<tr>
|
||||
<td>{{ r.symbol_name or r.symbol }}</td>
|
||||
<td>{{ r.monitor_type }}</td>
|
||||
<td><span class="badge dir">{{ '多' if r.direction == 'long' else '空' }}</span></td>
|
||||
<td>{{ r.trigger_price }}</td>
|
||||
<td>{% if r.result == '止盈' %}<span class="badge profit">止盈</span>{% else %}<span class="badge loss">止损</span>{% endif %}</td>
|
||||
<td>{{ r.created_at[:16] if r.created_at else '' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
|
||||
<script>window.__EQUITY_CURVE__ = {{ equity_curve | default([]) | tojson }};</script>
|
||||
<script src="{{ url_for('static', filename='js/equity_curve.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/review.js') }}?v={{ asset_v }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/records.js') }}?v={{ asset_v }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/trades.js') }}?v={{ asset_v }}"></script>
|
||||
{% if prefill %}
|
||||
<script>
|
||||
function bootReviewPrefill() {
|
||||
var form = document.getElementById('review-form');
|
||||
var panel = document.getElementById('review-panel');
|
||||
if (!form) return;
|
||||
var map = {{ prefill | tojson }};
|
||||
Object.keys(map).forEach(function (k) {
|
||||
var el = form.querySelector('[name="' + k + '"]');
|
||||
if (el && map[k] != null && map[k] !== '') el.value = map[k];
|
||||
});
|
||||
var symInput = form.querySelector('.symbol-input');
|
||||
if (symInput && map.symbol_name) symInput.value = map.symbol_name;
|
||||
if (typeof recalc === 'function') recalc();
|
||||
if (panel) panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
if (window.qihuoOnPageLoad) window.qihuoOnPageLoad(bootReviewPrefill);
|
||||
else document.addEventListener('DOMContentLoaded', bootReviewPrefill);
|
||||
</script>
|
||||
{% endif %}
|
||||
<script>
|
||||
(function () {
|
||||
function scrollReviewPanel() {
|
||||
if (window.location.hash === '#review-panel') {
|
||||
var panel = document.getElementById('review-panel');
|
||||
if (panel) panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
}
|
||||
if (window.qihuoOnPageLoad) window.qihuoOnPageLoad(scrollReviewPanel);
|
||||
else document.addEventListener('DOMContentLoaded', scrollReviewPanel);
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,13 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}风控说明 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/doc.css') }}?v={{ asset_v }}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="card doc-page">
|
||||
<article class="doc-content">
|
||||
{{ doc_html|safe }}
|
||||
</article>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,614 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}系统设置 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
.settings-page{display:flex;flex-direction:column;gap:1.25rem}
|
||||
.settings-page .split-grid{margin-bottom:0;align-items:start}
|
||||
.settings-page .split-grid .card:not(.settings-fold){margin-bottom:0;min-height:100%;height:100%;display:flex;flex-direction:column}
|
||||
.settings-page .split-grid .settings-fold.card,
|
||||
.settings-page .split-grid .settings-ctp-fold.card{
|
||||
margin-bottom:0;min-height:auto !important;height:auto !important;align-self:start;
|
||||
display:flex;flex-direction:column;
|
||||
}
|
||||
.settings-page .split-grid .card > form,
|
||||
.settings-page .split-grid .card > .card-inner,
|
||||
.settings-page .split-grid .settings-fold-body > form,
|
||||
.settings-page .split-grid .settings-fold-body > .card-inner{flex:1;display:flex;flex-direction:column}
|
||||
.settings-password-form{display:grid;grid-template-columns:1fr 1fr;gap:.65rem .75rem}
|
||||
.settings-password-form .field-full{grid-column:1/-1}
|
||||
.settings-password-form .field label{font-size:.78rem}
|
||||
.settings-password-form input{padding:.55rem .7rem;font-size:.85rem}
|
||||
.settings-tips{flex:1;display:flex;flex-direction:column;justify-content:center;gap:.5rem;margin:0;padding:0;list-style:none;font-size:.85rem;color:var(--text-muted);line-height:1.55}
|
||||
.settings-tips li{padding-left:1rem;position:relative}
|
||||
.settings-tips li::before{content:"";position:absolute;left:0;top:.55em;width:5px;height:5px;border-radius:50%;background:var(--accent)}
|
||||
.settings-ctp-grid{display:grid;grid-template-columns:1fr 1fr;gap:.65rem .75rem}
|
||||
.settings-ctp-grid .field-full{grid-column:1/-1}
|
||||
.settings-ctp-wrap .card-body{padding-top:0}
|
||||
.settings-ctp-cards-row{
|
||||
display:grid;grid-template-columns:1fr 1fr;gap:.75rem;
|
||||
align-items:start;margin-bottom:.75rem;
|
||||
}
|
||||
.settings-ctp-cards-row .settings-ctp-fold.card{margin-bottom:0;height:100%}
|
||||
.settings-ctp-cards-row .settings-ctp-grid{
|
||||
grid-template-columns:repeat(6,minmax(0,1fr));
|
||||
gap:.5rem .6rem;
|
||||
}
|
||||
.settings-ctp-cards-row .settings-ctp-grid .field{grid-column:span 2}
|
||||
.settings-ctp-cards-row .settings-ctp-grid .field-ctp-front-span{grid-column:span 3}
|
||||
.settings-ctp-cards-row .settings-ctp-grid .field label{font-size:.75rem}
|
||||
.settings-ctp-cards-row .settings-ctp-grid input,
|
||||
.settings-ctp-cards-row .settings-ctp-grid select{
|
||||
padding:.45rem .55rem;font-size:.8rem;
|
||||
}
|
||||
.settings-ctp-fold.card{
|
||||
margin-bottom:.75rem;padding:0;overflow:hidden;
|
||||
border:1px solid var(--border);border-radius:8px;background:var(--card-inner);
|
||||
}
|
||||
.settings-ctp-fold.card:last-of-type{margin-bottom:0}
|
||||
.settings-ctp-fold-head{
|
||||
width:100%;display:flex;align-items:center;justify-content:space-between;gap:.75rem;
|
||||
padding:.7rem 1rem;margin:0;border:none;background:transparent;cursor:pointer;
|
||||
font-size:.92rem;font-weight:600;color:var(--text-title);text-align:left;
|
||||
}
|
||||
.settings-ctp-fold-head:hover{color:var(--accent)}
|
||||
.settings-ctp-fold-title{display:flex;align-items:center;gap:.5rem}
|
||||
.settings-ctp-fold-chevron{
|
||||
flex-shrink:0;font-size:.72rem;color:var(--text-muted);
|
||||
transition:transform .2s ease;
|
||||
}
|
||||
.settings-ctp-fold.is-collapsed .settings-ctp-fold-chevron{transform:rotate(-90deg)}
|
||||
.settings-ctp-fold-body{padding:0 1rem .85rem}
|
||||
.settings-ctp-fold.is-collapsed .settings-ctp-fold-body{display:none}
|
||||
.settings-ctp-status{font-size:.82rem;color:var(--text-muted);margin-top:.75rem;line-height:1.5}
|
||||
.settings-backup-table{width:100%;border-collapse:collapse;font-size:.82rem;margin-top:.65rem}
|
||||
.settings-backup-table th,.settings-backup-table td{padding:.45rem .5rem;border-bottom:1px solid var(--border);text-align:left}
|
||||
.settings-backup-table th{color:var(--text-muted);font-weight:600}
|
||||
.settings-backup-restore{
|
||||
margin-top:.85rem;padding:.75rem .85rem;border-radius:8px;
|
||||
border:1px solid var(--border);background:var(--card-inner);
|
||||
font-size:.82rem;color:var(--text-muted);line-height:1.6;
|
||||
}
|
||||
.settings-backup-restore summary{cursor:pointer;color:var(--text-title);font-weight:600}
|
||||
.settings-backup-meta{font-size:.82rem;color:var(--text-muted);line-height:1.55;margin:.35rem 0 .65rem}
|
||||
.settings-backup-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem .65rem}
|
||||
.settings-backup-download{color:var(--accent);text-decoration:none;font-weight:600}
|
||||
.settings-backup-download:hover{text-decoration:underline}
|
||||
.settings-admin-row .settings-compact-card{font-size:.78rem}
|
||||
.settings-admin-row .settings-compact-card .hint,
|
||||
.settings-admin-row .settings-backup-meta,
|
||||
.settings-admin-row .settings-backup-restore{font-size:.72rem;line-height:1.5}
|
||||
.settings-admin-row .settings-backup-table{font-size:.7rem}
|
||||
.settings-admin-row .settings-backup-table th,
|
||||
.settings-admin-row .settings-backup-table td{padding:.35rem .4rem}
|
||||
.settings-admin-row .settings-backup-table td:first-child code{word-break:break-all;font-size:.68rem}
|
||||
.settings-admin-row .field label{font-size:.72rem}
|
||||
.settings-admin-row .field input{padding:.4rem .55rem;font-size:.78rem}
|
||||
.settings-admin-row .settings-backup-config{display:grid;grid-template-columns:1fr;gap:.45rem;margin-bottom:.55rem}
|
||||
.settings-admin-row .settings-backup-actions{margin-top:.35rem}
|
||||
.settings-admin-row .settings-backup-actions .btn-primary,
|
||||
.settings-admin-row .settings-compact-card > form .btn-primary{padding:.42rem .7rem;font-size:.78rem}
|
||||
.settings-admin-row .settings-password-form{grid-template-columns:1fr;gap:.45rem .55rem}
|
||||
.settings-admin-row .settings-password-form input{padding:.4rem .55rem;font-size:.78rem}
|
||||
.settings-ai-full{margin-bottom:1.25rem}
|
||||
.settings-ai-full .settings-fold.card{min-height:auto;height:auto}
|
||||
.settings-ai-usage{margin-bottom:1rem;font-size:.84rem;color:var(--text-muted)}
|
||||
.settings-ai-usage summary{cursor:pointer;color:var(--accent);font-weight:600;margin-bottom:.4rem}
|
||||
.settings-ai-usage-body ul{margin:.25rem 0 0 1.1rem;padding:0;line-height:1.55}
|
||||
.settings-ai-usage-body li{margin:.2rem 0}
|
||||
.settings-ai-form{max-width:none}
|
||||
.settings-ai-form input[type="checkbox"]{width:auto;flex-shrink:0;margin:0}
|
||||
.settings-ai-form label.check-inline{
|
||||
display:inline-flex;align-items:center;gap:.45rem;width:auto;
|
||||
cursor:pointer;margin-bottom:0;font-size:.85rem;color:var(--text-muted)
|
||||
}
|
||||
.settings-ai-cards-row{
|
||||
display:grid;grid-template-columns:1fr 1fr;gap:.85rem;margin-bottom:.85rem
|
||||
}
|
||||
.settings-ai-card{
|
||||
border:1px solid var(--border);border-radius:10px;
|
||||
padding:.85rem 1rem;background:var(--card-inner)
|
||||
}
|
||||
.settings-ai-card.is-active{border-color:var(--accent);box-shadow:0 0 0 1px rgba(56,189,248,.25)}
|
||||
.settings-ai-card-head{
|
||||
display:flex;align-items:center;justify-content:space-between;gap:.5rem;
|
||||
margin-bottom:.65rem;font-size:.92rem;font-weight:600;color:var(--text-title)
|
||||
}
|
||||
.settings-ai-card .field{margin-bottom:.55rem}
|
||||
.settings-ai-card .field:last-child{margin-bottom:0}
|
||||
.settings-ai-daily{
|
||||
border:1px solid var(--border);border-radius:10px;
|
||||
padding:.85rem 1rem;background:var(--card-inner);margin-bottom:.85rem
|
||||
}
|
||||
.settings-ai-daily-grid{display:grid;grid-template-columns:auto 1fr 1fr;gap:.65rem .75rem;align-items:end}
|
||||
.settings-ai-daily-grid .check-inline{align-self:center}
|
||||
@media (max-width:768px){
|
||||
.settings-ai-cards-row{grid-template-columns:1fr}
|
||||
.settings-ai-daily-grid{grid-template-columns:1fr}
|
||||
}
|
||||
.settings-page .settings-fold.card{padding:0;overflow:hidden}
|
||||
.settings-page .split-grid .settings-fold.card{min-height:auto;height:auto;align-self:start}
|
||||
.settings-fold-head{
|
||||
width:100%;display:flex;align-items:center;justify-content:space-between;gap:.75rem;
|
||||
padding:1rem 1rem .85rem;margin:0;border:none;background:transparent;cursor:pointer;
|
||||
text-align:left;
|
||||
}
|
||||
.settings-fold-head:hover .settings-fold-title{color:var(--accent)}
|
||||
.settings-fold-title{
|
||||
display:flex;align-items:center;gap:.5rem;font-size:1.15rem;font-weight:600;
|
||||
color:var(--text-label);letter-spacing:.03em;
|
||||
}
|
||||
.settings-fold-title:before{
|
||||
content:"";width:4px;height:16px;flex-shrink:0;
|
||||
background:linear-gradient(180deg,var(--accent),var(--accent-2));
|
||||
border-radius:2px;box-shadow:0 0 8px var(--card-glow);
|
||||
}
|
||||
.settings-fold-chevron{flex-shrink:0;font-size:.72rem;color:var(--text-muted);transition:transform .2s ease}
|
||||
.settings-fold.is-collapsed .settings-fold-chevron{transform:rotate(-90deg)}
|
||||
.settings-fold-body{padding:0 1rem 1rem;display:flex;flex-direction:column}
|
||||
.settings-fold.is-collapsed .settings-fold-body{display:none}
|
||||
.settings-admin-row .settings-fold-head{padding:.75rem .85rem .6rem}
|
||||
.settings-admin-row .settings-fold-title{font-size:.95rem}
|
||||
.settings-admin-row .settings-fold-body{padding:0 .85rem .85rem}
|
||||
@media(max-width:900px){
|
||||
.settings-admin-row{grid-template-columns:1fr}
|
||||
.settings-password-form{grid-template-columns:1fr}
|
||||
.settings-ctp-cards-row{grid-template-columns:1fr}
|
||||
.settings-ctp-grid{grid-template-columns:1fr}
|
||||
.settings-ctp-cards-row .settings-ctp-grid .field,
|
||||
.settings-ctp-cards-row .settings-ctp-grid .field-ctp-front-span{grid-column:span 1}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% macro settings_card(key, title, extra_class='') %}
|
||||
<div class="card settings-fold is-collapsed {{ extra_class }}" data-settings-fold="{{ key }}">
|
||||
<button type="button" class="settings-fold-head" aria-expanded="false">
|
||||
<span class="settings-fold-title">{{ title }}</span>
|
||||
<span class="settings-fold-chevron" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
<div class="settings-fold-body">
|
||||
{{ caller() }}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
<div class="settings-page">
|
||||
|
||||
<div class="split-grid">
|
||||
{% call settings_card('nav', '导航显示') %}
|
||||
<form action="{{ url_for('settings') }}" method="post">
|
||||
<input type="hidden" name="action" value="nav">
|
||||
<p class="hint" style="margin-bottom:.75rem">关闭后顶栏隐藏对应入口,直接访问 URL 也会跳转回下单监控。</p>
|
||||
<div class="check-row">
|
||||
{% for key, label in nav_toggles.items() %}
|
||||
<label style="display:flex;align-items:center;gap:.5rem;cursor:pointer;white-space:nowrap">
|
||||
<input type="checkbox" name="nav_{{ key }}" {% if nav_items[key] %}checked{% endif %}>
|
||||
<span>{{ label }}</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<button type="submit" class="btn-primary" style="margin-top:.75rem">保存导航</button>
|
||||
</form>
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_card('trading', '交易模式') %}
|
||||
<form action="{{ url_for('settings') }}" method="post">
|
||||
<input type="hidden" name="action" value="trading">
|
||||
<div class="form-grid">
|
||||
<div class="field">
|
||||
<label>交易通道</label>
|
||||
<select name="trading_mode">
|
||||
<option value="simulation" {% if trading_mode == 'simulation' %}selected{% endif %}>SimNow(vnpy CTP)</option>
|
||||
<option value="live" {% if trading_mode == 'live' %}selected{% endif %}>期货公司 CTP(后期接入)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>计仓模式</label>
|
||||
<select name="position_sizing_mode" id="position-sizing-mode">
|
||||
<option value="fixed" {% if position_sizing_mode == 'fixed' %}selected{% endif %}>固定手数</option>
|
||||
<option value="amount" {% if position_sizing_mode in ('amount', 'risk') %}selected{% endif %}>固定金额</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field" id="field-fixed-lots" {% if position_sizing_mode in ('amount', 'risk') %}hidden{% endif %}>
|
||||
<label>固定手数(手)</label>
|
||||
<input name="fixed_lots" type="number" step="1" min="1" value="{{ fixed_lots }}">
|
||||
</div>
|
||||
<div class="field" id="field-fixed-amount" {% if position_sizing_mode not in ('amount', 'risk') %}hidden{% endif %}>
|
||||
<label>固定金额(元)</label>
|
||||
<input name="fixed_amount" type="number" step="1" min="1" value="{{ fixed_amount }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>单仓保证金上限(%)</label>
|
||||
<input name="max_margin_pct" type="number" step="1" min="1" max="100" value="{{ max_margin_pct }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>综合保证金上限(%)</label>
|
||||
<input name="roll_max_margin_pct" type="number" step="1" min="1" max="100" value="{{ roll_max_margin_pct }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>移动保本缓冲(最小变动价位倍数)</label>
|
||||
<input name="trailing_be_tick_buffer" type="number" step="1" min="1" max="20" value="{{ trailing_be_tick_buffer }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>开仓挂单超时(分钟)</label>
|
||||
<input name="pending_order_timeout_min" type="number" step="1" min="1" max="60" value="{{ pending_order_timeout_min }}">
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn-primary" style="margin-top:.75rem">保存交易设置</button>
|
||||
<p class="hint" style="margin-top:.75rem;margin-bottom:0">
|
||||
单仓保证金上限(默认 30%)用于<strong>新开仓</strong>校验与最大手数估算;综合保证金上限(默认 50%)在单仓模式下为滚仓合计上限、多仓模式下为全部持仓合计上限。固定金额计仓时<strong>先按止损算手数,再按单仓上限收紧</strong>。
|
||||
<strong>移动保本</strong>:达 1R 后止损移至开仓价 ± N 跳。
|
||||
<strong>挂单超时</strong>:限价开仓未成交时,超过设定分钟数自动向柜台撤单(1~60 分钟)。
|
||||
<span class="text-muted">{{ small_account_margin_rec.label }}。</span>
|
||||
CTP 账号与前置在下方「CTP 连接」中配置。
|
||||
</p>
|
||||
</form>
|
||||
{% endcall %}
|
||||
</div>
|
||||
|
||||
{% call settings_card('ctp', 'CTP 连接', 'settings-ctp-wrap') %}
|
||||
<p class="hint" style="margin-bottom:.85rem">
|
||||
投资者代码、密码、前置地址在此维护(优先于 <code>.env</code>)。保存后将自动断开并用新地址重连 CTP(须开启下方自动连接)。
|
||||
{% if ctp_status.connected %}
|
||||
<span class="badge profit" style="margin-left:.35rem">已连接</span>
|
||||
{% elif ctp_status.connecting %}
|
||||
<span class="badge planned" style="margin-left:.35rem">连接中</span>
|
||||
{% elif ctp_status.disabled_hint %}
|
||||
<span class="text-muted" style="display:block;margin-top:.35rem">{{ ctp_status.disabled_hint }}</span>
|
||||
{% elif ctp_status.last_error %}
|
||||
<span class="text-loss" style="display:block;margin-top:.35rem">{{ ctp_status.last_error }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
<form action="{{ url_for('settings') }}" method="post" id="ctp-settings-form" data-simnow-pwd-set="{{ '1' if ctp_cfg.simnow_password_set else '0' }}">
|
||||
<input type="hidden" name="action" value="ctp">
|
||||
|
||||
<div class="settings-ctp-auto card" style="margin-bottom:.85rem;padding:.75rem 1rem">
|
||||
<label class="settings-ctp-auto-label" style="display:flex;align-items:flex-start;gap:.65rem;cursor:pointer;margin:0">
|
||||
<input type="checkbox" name="ctp_auto_connect" value="1" {% if ctp_auto_connect %}checked{% endif %}
|
||||
style="margin-top:.2rem;width:auto">
|
||||
<span>
|
||||
<strong>CTP 自动连接</strong>
|
||||
<span class="hint" style="display:block;margin:.25rem 0 0;font-size:.78rem;line-height:1.55">
|
||||
开启:盘前 30 分钟检查连接(已连则不重复发起)、交易时段断线自动重连、持仓页可连 CTP。关闭:立即断开,非交易时段不再重连;开盘前 30 分钟及交易时段仍会自动连接。系统不会自动强制断线,休盘后请按需手动断开。
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="settings-ctp-cards-row">
|
||||
<div class="settings-ctp-fold card is-collapsed" data-ctp-fold="simnow">
|
||||
<button type="button" class="settings-ctp-fold-head" aria-expanded="false">
|
||||
<span class="settings-ctp-fold-title">
|
||||
SimNow 模拟盘
|
||||
{% if trading_mode == 'simulation' %}<span class="badge planned" style="font-size:.7rem">当前通道</span>{% endif %}
|
||||
</span>
|
||||
<span class="settings-ctp-fold-chevron" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
<div class="settings-ctp-fold-body">
|
||||
<div class="settings-ctp-grid">
|
||||
<div class="field">
|
||||
<label>投资者代码</label>
|
||||
<input name="simnow_user" value="{{ ctp_cfg.simnow_user }}" placeholder="非手机号">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>交易密码</label>
|
||||
<input id="simnow_password" name="simnow_password" type="password"
|
||||
autocomplete="off" spellcheck="false"
|
||||
placeholder="{% if ctp_cfg.simnow_password_set %}已设置:须重新输入才会更新{% else %}SimNow 交易密码(必填){% endif %}">
|
||||
<p class="hint" style="margin:.25rem 0 0;font-size:.75rem">
|
||||
与快期相同密码,保存前须在此<strong>手打</strong>;留空则不改。下方「修改密码」是网页登录密码,不是 SimNow。
|
||||
</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>经纪商代码</label>
|
||||
<input name="simnow_broker_id" value="{{ ctp_cfg.simnow_broker_id }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>柜台环境</label>
|
||||
<select name="simnow_env">
|
||||
<option value="实盘" {% if ctp_cfg.simnow_env == '实盘' %}selected{% endif %}>实盘(看穿式,推荐)</option>
|
||||
<option value="测试" {% if ctp_cfg.simnow_env == '测试' %}selected{% endif %}>测试</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>AppID</label>
|
||||
<input name="simnow_app_id" value="{{ ctp_cfg.simnow_app_id }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>授权编码</label>
|
||||
<input name="simnow_auth_code" value="{{ ctp_cfg.simnow_auth_code }}">
|
||||
</div>
|
||||
<div class="field field-ctp-front-span">
|
||||
<label>行情前置</label>
|
||||
<input name="simnow_md_address" value="{{ ctp_cfg.simnow_md_address }}" placeholder="tcp://180.168.146.187:10211">
|
||||
</div>
|
||||
<div class="field field-ctp-front-span">
|
||||
<label>交易前置</label>
|
||||
<input name="simnow_td_address" value="{{ ctp_cfg.simnow_td_address }}" placeholder="tcp://180.168.146.187:10201">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-ctp-fold card is-collapsed" data-ctp-fold="live">
|
||||
<button type="button" class="settings-ctp-fold-head" aria-expanded="false">
|
||||
<span class="settings-ctp-fold-title">
|
||||
期货公司实盘
|
||||
{% if trading_mode == 'live' %}<span class="badge planned" style="font-size:.7rem">当前通道</span>{% endif %}
|
||||
</span>
|
||||
<span class="settings-ctp-fold-chevron" aria-hidden="true">▼</span>
|
||||
</button>
|
||||
<div class="settings-ctp-fold-body">
|
||||
<div class="settings-ctp-grid">
|
||||
<div class="field">
|
||||
<label>投资者代码</label>
|
||||
<input name="ctp_live_user" value="{{ ctp_cfg.ctp_live_user }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>交易密码</label>
|
||||
<input name="ctp_live_password" type="password" autocomplete="new-password"
|
||||
placeholder="{% if ctp_cfg.ctp_live_password_set %}已设置,留空不修改{% else %}实盘密码{% endif %}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>经纪商代码</label>
|
||||
<input name="ctp_live_broker_id" value="{{ ctp_cfg.ctp_live_broker_id }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>柜台环境</label>
|
||||
<select name="ctp_live_env">
|
||||
<option value="实盘" {% if ctp_cfg.ctp_live_env == '实盘' %}selected{% endif %}>实盘</option>
|
||||
<option value="测试" {% if ctp_cfg.ctp_live_env == '测试' %}selected{% endif %}>测试</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>AppID</label>
|
||||
<input name="ctp_live_app_id" value="{{ ctp_cfg.ctp_live_app_id }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>授权编码</label>
|
||||
<input name="ctp_live_auth_code" value="{{ ctp_cfg.ctp_live_auth_code }}">
|
||||
</div>
|
||||
<div class="field field-ctp-front-span">
|
||||
<label>行情前置</label>
|
||||
<input name="ctp_live_md_address" value="{{ ctp_cfg.ctp_live_md_address }}" placeholder="tcp://...">
|
||||
</div>
|
||||
<div class="field field-ctp-front-span">
|
||||
<label>交易前置</label>
|
||||
<input name="ctp_live_td_address" value="{{ ctp_cfg.ctp_live_td_address }}" placeholder="tcp://...">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn-primary">保存 CTP 配置</button>
|
||||
<p class="settings-ctp-status">
|
||||
官方第一套:<code>180.168.146.187:10201/10211</code>;
|
||||
第二套(云服务器常用):<code>182.254.243.31:30001/30011</code>;
|
||||
7×24:<code>182.254.243.31:40001/40011</code>(部分账号在 40001 会报「不合法登录」,与快期前置保持一致)。
|
||||
详见 <code>docs/SIMNOW.md</code>。
|
||||
</p>
|
||||
</form>
|
||||
{% endcall %}
|
||||
|
||||
<div class="split-grid">
|
||||
{% call settings_card('quote', '行情说明') %}
|
||||
<div class="card-inner">
|
||||
<p class="hint" style="font-size:.88rem;line-height:1.6;margin:0">
|
||||
当前行情源:<strong class="text-accent">{{ quote_label }}</strong><br>
|
||||
CTP 已连接时使用<strong>柜台行情</strong>;未连接时回退新浪接口。<br>
|
||||
合约代码按同花顺格式(如 ag2608、IF2606)。
|
||||
</p>
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_card('wechat', '企业微信推送') %}
|
||||
<form action="{{ url_for('settings') }}" method="post">
|
||||
<input type="hidden" name="action" value="wechat">
|
||||
<div class="field" style="margin-bottom:.75rem">
|
||||
<label>Webhook 地址</label>
|
||||
<input name="wechat_webhook" type="url" placeholder="https://qyapi.weixin.qq.com/..." value="{{ webhook }}">
|
||||
</div>
|
||||
<button type="submit" class="btn-primary">保存</button>
|
||||
<p class="hint" style="margin-top:.75rem;margin-bottom:0">在企业微信群添加机器人后,粘贴 Webhook 地址保存。</p>
|
||||
</form>
|
||||
{% endcall %}
|
||||
</div>
|
||||
|
||||
<div class="settings-ai-full">
|
||||
{% call settings_card('ai', 'AI 分析 · 使用说明') %}
|
||||
<details class="settings-ai-usage" open>
|
||||
<summary>使用说明</summary>
|
||||
<div class="settings-ai-usage-body">
|
||||
<ul>
|
||||
<li><strong>触发时机</strong>:开仓成交、平仓入账、日终报告(默认日盘 15:05,可在下方修改)</li>
|
||||
<li><strong>Ollama</strong>:服务器需能访问填写的地址(如本机 <code>127.0.0.1:11434</code>)</li>
|
||||
<li><strong>OpenAI 兼容</strong>:支持 DeepSeek、硅基流动等 OpenAI 格式 API</li>
|
||||
<li><strong>输出位置</strong>:分析写入导航「AI 消息」;若已配置企业微信,日终报告会同步推送摘要</li>
|
||||
<li><strong>不替代交易</strong>:AI 仅作复盘与风险提示,下单仍以系统规则与 CTP 为准</li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
<form action="{{ url_for('settings') }}" method="post" class="settings-ai-form">
|
||||
<input type="hidden" name="action" value="ai">
|
||||
<div class="field" style="margin-bottom:.75rem">
|
||||
<label class="check-inline">
|
||||
<input type="checkbox" name="ai_enabled" value="1" {% if ai_enabled %}checked{% endif %}>
|
||||
<span>启用 AI 分析</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="field" style="margin-bottom:.85rem;max-width:280px">
|
||||
<label>当前使用的提供商</label>
|
||||
<select name="ai_provider" id="ai-provider-select">
|
||||
<option value="ollama" {% if ai_provider == 'ollama' %}selected{% endif %}>本地 Ollama</option>
|
||||
<option value="openai" {% if ai_provider == 'openai' %}selected{% endif %}>OpenAI 兼容 API</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="settings-ai-cards-row">
|
||||
<div class="settings-ai-card{% if ai_provider == 'ollama' %} is-active{% endif %}" data-ai-provider="ollama">
|
||||
<div class="settings-ai-card-head">
|
||||
<span>本地 Ollama</span>
|
||||
{% if ai_provider == 'ollama' %}<span class="badge profit">当前</span>{% endif %}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>接口地址</label>
|
||||
<input name="ai_ollama_base_url" type="url" placeholder="http://127.0.0.1:11434" value="{{ ai_ollama_base_url }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>模型名</label>
|
||||
<input name="ai_ollama_model" type="text" placeholder="qwen2.5:7b" value="{{ ai_ollama_model }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-ai-card{% if ai_provider == 'openai' %} is-active{% endif %}" data-ai-provider="openai">
|
||||
<div class="settings-ai-card-head">
|
||||
<span>OpenAI 兼容</span>
|
||||
{% if ai_provider == 'openai' %}<span class="badge profit">当前</span>{% endif %}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>API Base URL</label>
|
||||
<input name="ai_openai_base_url" type="url" placeholder="https://api.openai.com/v1" value="{{ ai_openai_base_url }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>API Key</label>
|
||||
<input name="ai_openai_api_key" type="password" placeholder="sk-..." value="{{ ai_openai_api_key }}" autocomplete="off">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>模型名</label>
|
||||
<input name="ai_openai_model" type="text" placeholder="gpt-4o-mini" value="{{ ai_openai_model }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-ai-daily">
|
||||
<p class="hint" style="margin:0 0 .65rem">日终报告(国内期货日盘收盘后推送一次)</p>
|
||||
<div class="settings-ai-daily-grid">
|
||||
<label class="check-inline">
|
||||
<input type="checkbox" name="ai_daily_report_enabled" value="1" {% if ai_daily_report_enabled %}checked{% endif %}>
|
||||
<span>启用</span>
|
||||
</label>
|
||||
<div class="field" style="margin:0">
|
||||
<label>报告时刻(时)</label>
|
||||
<input name="ai_daily_report_hour" type="number" min="0" max="23" step="1" value="{{ ai_daily_report_hour }}">
|
||||
</div>
|
||||
<div class="field" style="margin:0">
|
||||
<label>报告时刻(分)</label>
|
||||
<input name="ai_daily_report_minute" type="number" min="0" max="59" step="1" value="{{ ai_daily_report_minute }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn-primary">保存 AI 配置</button>
|
||||
</form>
|
||||
{% endcall %}
|
||||
</div>
|
||||
|
||||
<div class="split-grid settings-admin-row">
|
||||
{% call settings_card('backup', '数据备份与恢复', 'settings-compact-card') %}
|
||||
<p class="settings-backup-meta">
|
||||
自动备份目录:<code>{{ backup_dir }}</code>
|
||||
{% if backup_last_at %} · 上次备份 {{ backup_last_at.replace('T', ' ') }}{% else %} · 尚未备份{% endif %}
|
||||
{% if backup_running %} · <span style="color:var(--accent)">备份进行中…</span>{% endif %}
|
||||
</p>
|
||||
<form action="{{ url_for('settings') }}" method="post" style="margin-bottom:.55rem">
|
||||
<input type="hidden" name="action" value="backup_config">
|
||||
<div class="settings-backup-config">
|
||||
<div class="field">
|
||||
<label style="display:flex;align-items:center;gap:.45rem;cursor:pointer">
|
||||
<input type="checkbox" name="backup_auto_enabled" value="1" {% if backup_auto_enabled %}checked{% endif %}>
|
||||
<span>启用每日自动备份</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>自动备份时刻(0–23 点)</label>
|
||||
<input name="backup_auto_hour" type="number" min="0" max="23" step="1" value="{{ backup_auto_hour }}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>保留最近份数</label>
|
||||
<input name="backup_keep_count" type="number" min="5" max="200" step="1" value="{{ backup_keep_count }}">
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn-primary">保存备份策略</button>
|
||||
</form>
|
||||
<div class="settings-backup-actions">
|
||||
<form action="{{ url_for('settings') }}" method="post">
|
||||
<input type="hidden" name="action" value="backup_now">
|
||||
<button type="submit" class="btn-primary" {% if backup_running %}disabled{% endif %}>立即备份</button>
|
||||
</form>
|
||||
</div>
|
||||
<p class="hint" style="margin:.5rem 0 0">备份含 <code>futures.db</code>、<code>uploads/</code>,默认恢复至 <code>{{ backup_restore_dir }}</code>。</p>
|
||||
|
||||
{% if backup_items %}
|
||||
<table class="settings-backup-table">
|
||||
<thead>
|
||||
<tr><th>文件名</th><th>大小</th><th>时间</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in backup_items %}
|
||||
<tr>
|
||||
<td><code>{{ item.name }}</code></td>
|
||||
<td>{{ item.size_mb }} MB</td>
|
||||
<td>{{ item.mtime.replace('T', ' ')[:16] }}</td>
|
||||
<td><a href="{{ url_for('api_backup_download', filename=item.name) }}" class="settings-backup-download">下载</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="hint" style="margin-top:.5rem;margin-bottom:0">暂无备份,可点「立即备份」。</p>
|
||||
{% endif %}
|
||||
|
||||
<details class="settings-backup-restore">
|
||||
<summary>备份恢复说明</summary>
|
||||
<ol style="margin:.5rem 0 0 1rem;padding:0">
|
||||
<li>下载 <code>.tar.gz</code> 到目标服务器(如 <code>/root/</code>)。</li>
|
||||
<li>解压:<code>tar -xzf qihuo_backup_*.tar.gz</code></li>
|
||||
<li>执行:<code>chmod +x restore.sh && ./restore.sh</code></li>
|
||||
<li>指定目录:<code>RESTORE_DIR=/opt/qihuo ./restore.sh</code></li>
|
||||
<li>部署代码、配置 <code>.env</code> 后重启服务。</li>
|
||||
</ol>
|
||||
</details>
|
||||
{% endcall %}
|
||||
|
||||
{% call settings_card('password', '登录账号', 'settings-compact-card') %}
|
||||
<form action="{{ url_for('settings') }}" method="post" class="settings-password-form">
|
||||
<input type="hidden" name="action" value="password">
|
||||
<div class="field field-full">
|
||||
<label>用户名</label>
|
||||
<input name="admin_username" type="text" value="{{ username }}" required maxlength="64"
|
||||
pattern="[A-Za-z0-9_.@-]+" autocomplete="username">
|
||||
</div>
|
||||
<div class="field field-full">
|
||||
<label>原密码</label>
|
||||
<input name="old_password" type="password" required autocomplete="current-password">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>新密码</label>
|
||||
<input name="new_password" type="password" minlength="6" placeholder="留空则不修改" autocomplete="new-password">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>确认新密码</label>
|
||||
<input name="new_password2" type="password" minlength="6" placeholder="修改密码时填写" autocomplete="new-password">
|
||||
</div>
|
||||
<div class="field-full">
|
||||
<button type="submit" class="btn-primary">保存账号</button>
|
||||
</div>
|
||||
<p class="hint" style="margin:.45rem 0 0;font-size:.72rem">保存后写入数据库,并同步至 <code>.env</code> 的 <code>ADMIN_USERNAME</code> / <code>ADMIN_PASSWORD</code>。</p>
|
||||
</form>
|
||||
{% endcall %}
|
||||
</div>
|
||||
|
||||
<div class="split-grid">
|
||||
{% call settings_card('tips', '使用提示') %}
|
||||
<ul class="settings-tips">
|
||||
<li>下单监控:连接 CTP 后下单、看持仓与可开仓品种</li>
|
||||
<li>策略交易:趋势回调自动补仓;顺势加仓需先开仓</li>
|
||||
<li>手续费:默认 CTP 柜台费率,连接后点同步</li>
|
||||
<li>手机端:浏览器菜单可「添加到主屏幕」安装 App</li>
|
||||
</ul>
|
||||
{% endcall %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/settings.js') }}?v={{ asset_v }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,79 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}统计分析 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
.stats-summary-card{margin-bottom:1.25rem}
|
||||
.stats-toolbar{display:flex;align-items:center;justify-content:flex-start;gap:1rem;margin-bottom:.75rem;flex-wrap:wrap}
|
||||
.stat-grid-summary{
|
||||
display:flex;flex-wrap:nowrap;align-items:stretch;gap:0;
|
||||
margin-bottom:0;overflow-x:auto;-webkit-overflow-scrolling:touch;
|
||||
}
|
||||
.stat-grid-summary .stat-item{
|
||||
flex:1 1 0;min-width:4.5rem;background:transparent;border:none;border-radius:0;
|
||||
padding:.35rem .2rem;text-align:center;position:relative;overflow:visible;
|
||||
border-right:1px solid var(--table-border);
|
||||
}
|
||||
.stat-grid-summary .stat-item:last-child{border-right:none}
|
||||
.stat-grid-summary .stat-item::before{display:none}
|
||||
.stat-grid-summary .stat-item:hover{transform:none;box-shadow:none}
|
||||
.stat-grid-summary .stat-item .label{
|
||||
font-size:.62rem;line-height:1.25;color:var(--text-muted);white-space:nowrap;
|
||||
}
|
||||
.stat-grid-summary .stat-item .value{
|
||||
font-size:.78rem;font-weight:600;color:var(--text-title);margin-top:.12rem;
|
||||
font-variant-numeric:tabular-nums;white-space:nowrap;
|
||||
}
|
||||
.stats-card-head{display:flex;align-items:flex-end;justify-content:space-between;gap:1rem;flex-wrap:wrap;margin-bottom:1rem}
|
||||
.stats-card-head h2{margin-bottom:0}
|
||||
.stats-view-field{width:auto;min-width:200px}
|
||||
.stats-view-field select{width:100%;min-width:180px}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<div class="card stats-summary-card">
|
||||
<div class="stats-toolbar">
|
||||
<span id="stats-updated" class="hint">正在加载统计…</span>
|
||||
</div>
|
||||
<div class="stat-grid stat-grid-summary" id="stats-summary">
|
||||
<div class="stat-item"><div class="label">总交易次数</div><div class="value" data-k="total_trades">-</div></div>
|
||||
<div class="stat-item"><div class="label">胜率</div><div class="value" data-k="win_rate">-</div></div>
|
||||
<div class="stat-item"><div class="label">平均盈利</div><div class="value text-profit" data-k="avg_profit">-</div></div>
|
||||
<div class="stat-item"><div class="label">平均亏损</div><div class="value text-loss" data-k="avg_loss">-</div></div>
|
||||
<div class="stat-item"><div class="label">盈亏比</div><div class="value" data-k="profit_loss_ratio">-</div></div>
|
||||
<div class="stat-item"><div class="label">连续亏损次数</div><div class="value" data-k="consecutive_losses">-</div></div>
|
||||
<div class="stat-item"><div class="label">最大回撤</div><div class="value" data-k="max_drawdown">-</div></div>
|
||||
<div class="stat-item"><div class="label">最大亏损金额</div><div class="value text-loss" data-k="max_loss_amount">-</div></div>
|
||||
<div class="stat-item"><div class="label">最大亏损占比</div><div class="value text-loss" data-k="max_loss_pct">-</div></div>
|
||||
<div class="stat-item"><div class="label">最大盈利金额</div><div class="value text-profit" data-k="max_profit_amount">-</div></div>
|
||||
<div class="stat-item"><div class="label">最大盈利占比</div><div class="value text-profit" data-k="max_profit_pct">-</div></div>
|
||||
<div class="stat-item"><div class="label">累计手续费</div><div class="value text-loss" data-k="total_fee">-</div></div>
|
||||
<div class="stat-item"><div class="label">情绪单数量</div><div class="value" data-k="emotion_count">-</div></div>
|
||||
<div class="stat-item"><div class="label">情绪单占比</div><div class="value" data-k="emotion_ratio">-</div></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="stats-card-head">
|
||||
<h2>分项统计</h2>
|
||||
<div class="field stats-view-field">
|
||||
<label for="stats-view-select">统计维度</label>
|
||||
<select id="stats-view-select"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-scroll">
|
||||
<table id="stats-breakdown-table">
|
||||
<thead><tr id="stats-breakdown-head"></tr></thead>
|
||||
<tbody id="stats-breakdown-body">
|
||||
<tr><td colspan="12" class="text-muted">加载中…</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/stats.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,215 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}策略交易 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
.strategy-page .split-grid .card{min-height:420px;display:flex;flex-direction:column}
|
||||
.strategy-page .split-grid .card-body{flex:1}
|
||||
.strategy-preview{background:var(--card-inner);border:1px solid var(--card-border);border-radius:8px;padding:.65rem .85rem;font-size:.78rem;line-height:1.5;margin-top:.75rem;max-height:360px;overflow:auto}
|
||||
.strategy-preview .trend-summary{margin-bottom:.45rem;color:var(--text-title);font-size:.8rem;line-height:1.55}
|
||||
.strategy-preview .trend-detail{margin-bottom:.55rem;color:var(--text-muted);font-size:.75rem;line-height:1.5}
|
||||
.strategy-preview-table{width:100%;border-collapse:collapse;font-size:.72rem;min-width:520px}
|
||||
.strategy-preview-table th,.strategy-preview-table td{padding:.35rem .4rem;border-bottom:1px solid var(--table-border);text-align:right;white-space:nowrap}
|
||||
.strategy-preview-table th:first-child,.strategy-preview-table td:first-child{text-align:left}
|
||||
.strategy-preview-table thead th{color:var(--text-muted);font-weight:600;background:var(--list-item-bg)}
|
||||
.strategy-page .form-line.line-trend-head{grid-template-columns:1.5fr .75fr .85fr}
|
||||
.strategy-steps{margin:.75rem 0 0;padding-left:1.1rem;font-size:.82rem;color:var(--text-muted);line-height:1.6}
|
||||
.strategy-steps a{color:var(--accent)}
|
||||
.strategy-active-roll{margin-top:.65rem;padding:.55rem .75rem;background:var(--card-inner);border-radius:8px;font-size:.8rem;border:1px solid var(--card-border)}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="strategy-page">
|
||||
<details class="module-rules">
|
||||
<summary>规则说明</summary>
|
||||
<div class="module-rules-body">
|
||||
<p><strong>趋势回调</strong></p>
|
||||
<ul>
|
||||
<li>填写品种、方向、周期、止损、补仓边界、止盈 → <strong>预览计划</strong> → 确认后<strong>市价开首仓</strong></li>
|
||||
<li>须 CTP 已连接、交易时段内、账户风控允许开仓</li>
|
||||
<li>运行中:价格触及<strong>止盈</strong> → 全部平仓结案;回落至<strong>网格档位</strong> → 自动分档补仓</li>
|
||||
<li>可手动「结束计划」;记录归档至策略交易记录</li>
|
||||
</ul>
|
||||
<p><strong>顺势加仓(滚仓)</strong></p>
|
||||
<ul>
|
||||
<li>仅<strong>固定金额(以损定仓)</strong>模式;<strong>移动保本</strong>持仓不可滚仓</li>
|
||||
<li>须「下单监控」有 active 持仓;与趋势回调互斥</li>
|
||||
<li>风险预算 = 系统设置<strong>固定金额</strong>;合并持仓打到新止损总亏损 ≤ B</li>
|
||||
<li>最多 3 腿(已成交);同一组最多 1 条 pending 监控腿</li>
|
||||
<li>止盈锁定首仓;突破由程序监控标记价穿越后市价加仓</li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
<div class="split-grid">
|
||||
<div class="card">
|
||||
<h2>趋势回调</h2>
|
||||
<div class="card-body">
|
||||
{% if active_trend %}
|
||||
<p class="hint">运行中 #{{ active_trend.id }} · {{ active_trend.symbol_name or active_trend.symbol }} · {{ '做多' if active_trend.direction == 'long' else '做空' }} · {{ active_trend.period_label or '15分' }}</p>
|
||||
<p class="hint">已开 <strong>{{ active_trend.lots_open or 0 }}</strong> / {{ active_trend.target_lots }} 手 · 止损 {{ active_trend.stop_loss }} · 止盈 {{ active_trend.take_profit }}</p>
|
||||
<form id="trend-stop-form" class="form-row" style="margin-top:.75rem">
|
||||
<input type="hidden" name="plan_id" value="{{ active_trend.id }}">
|
||||
<button type="button" class="btn-primary" id="btn-trend-stop">结束计划</button>
|
||||
</form>
|
||||
<p class="hint" style="margin-top:.75rem;font-size:.75rem">后台按档位自动补仓,触及止盈或手动结束。</p>
|
||||
{% else %}
|
||||
<p class="hint" style="margin-bottom:.65rem">设置止损/补仓边界/止盈 → 预览 → 确认执行首仓;后续自动分档加仓。</p>
|
||||
<form id="trend-form" class="form-compact">
|
||||
<div class="form-line line-trend-head">
|
||||
<div class="symbol-wrap symbol-mains">
|
||||
<input type="text" class="symbol-input" placeholder="品种,输入中文或代码" autocomplete="off" required>
|
||||
<input type="hidden" name="symbol" class="symbol-ths-code">
|
||||
<input type="hidden" name="symbol_name">
|
||||
<div class="symbol-dropdown"></div>
|
||||
<div class="symbol-selected"></div>
|
||||
</div>
|
||||
<select name="direction"><option value="long">做多</option><option value="short">做空</option></select>
|
||||
<select name="period" title="参考 K 线周期">
|
||||
{% for p in trend_periods %}
|
||||
<option value="{{ p.key }}"{% if p.key == '15m' %} selected{% endif %}>{{ p.label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-line line-3">
|
||||
<input name="stop_loss" type="number" step="any" placeholder="止损" required>
|
||||
<input name="add_upper" type="number" step="any" placeholder="补仓边界" required>
|
||||
<input name="take_profit" type="number" step="any" placeholder="止盈" required>
|
||||
</div>
|
||||
<div class="form-line line-2">
|
||||
<input name="risk_percent" type="number" step="0.1" value="{{ risk_percent }}" placeholder="单笔风险 %" title="单笔风险%">
|
||||
<button type="button" class="btn-primary" id="btn-trend-preview">预览计划</button>
|
||||
</div>
|
||||
</form>
|
||||
<div id="trend-preview" class="strategy-preview" hidden></div>
|
||||
<button type="button" class="btn-primary" id="btn-trend-exec" hidden style="margin-top:.65rem;width:100%">确认执行首仓</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2>顺势加仓(滚仓)</h2>
|
||||
<div class="card-body">
|
||||
<details class="module-rules" style="margin-bottom:.65rem">
|
||||
<summary>顺势加仓规则说明</summary>
|
||||
<div class="module-rules-body" style="font-size:.78rem;line-height:1.55">
|
||||
<ul>
|
||||
<li>手动提交;须实盘已有同向持仓与 active 监控单</li>
|
||||
<li>计仓模式须为<strong>固定金额</strong>;移动保本不可滚仓</li>
|
||||
<li>做多/做空各最多 3 次滚仓(仅计已成交);止盈为首仓 TP 不变</li>
|
||||
<li>风险预算 B = 系统设置中的<strong>固定金额</strong>;打到新止损 S 时合并持仓总亏损 ≤ B</li>
|
||||
<li>突破:标记价穿越触发价后按当时持仓重算手数再市价加仓</li>
|
||||
<li>pending 腿不可改,只能删除;手动平仓后滚仓组关闭</li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
{% if not roll_allowed %}
|
||||
<p class="hint text-muted">当前为「{{ sizing_mode_label }}」模式,滚仓不可用。请在系统设置切换为<strong>固定金额</strong>。</p>
|
||||
{% endif %}
|
||||
{% if monitors %}
|
||||
<p class="hint" id="roll-risk-hint">风险预算(固定金额):<strong id="roll-risk-budget">{{ '%.0f'|format(fixed_amount) }} 元</strong></p>
|
||||
<form id="roll-form" class="form-compact">
|
||||
<div class="form-line line-2">
|
||||
<select name="monitor_id" id="roll-monitor-select" required {% if not roll_allowed %}disabled{% endif %}>
|
||||
{% for m in monitors %}
|
||||
<option value="{{ m.id }}"
|
||||
data-direction="{{ m.direction }}"
|
||||
data-eligible="{{ '1' if m.roll_eligible else '0' }}"
|
||||
data-block="{{ m.roll_block_reason or '' }}"
|
||||
{% if not m.roll_eligible %}disabled{% endif %}>
|
||||
{{ m.symbol_name or m.symbol }} {{ m.symbol }} · {{ '多' if m.direction == 'long' else '空' }} #{{ m.id }}
|
||||
· {{ m.lots }}手 · SL {{ m.stop_loss or '—' }}
|
||||
{% if not m.roll_eligible %} · {{ m.roll_block_reason }}{% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<select name="add_mode" id="roll-add-mode" {% if not roll_allowed %}disabled{% endif %}>
|
||||
<option value="market">市价加仓</option>
|
||||
<option value="breakout">突破加仓</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-line line-2">
|
||||
<input name="new_stop_loss" id="roll-new-sl" type="number" step="any" placeholder="新统一止损" required {% if not roll_allowed %}disabled{% endif %}>
|
||||
<input name="breakthrough_price" id="roll-break-price" type="number" step="any" placeholder="突破价" hidden>
|
||||
</div>
|
||||
<div class="form-line line-2">
|
||||
<button type="button" class="btn-primary" id="btn-roll-preview" {% if not roll_allowed %}disabled{% endif %}>预览</button>
|
||||
<button type="button" class="btn-primary" id="btn-roll-exec" hidden {% if not roll_allowed %}disabled{% endif %}>执行滚仓</button>
|
||||
</div>
|
||||
<div id="roll-preview" class="strategy-preview" hidden></div>
|
||||
<p class="hint" id="roll-exec-hint" hidden style="font-size:.75rem;margin-top:.45rem">市价加仓:须交易时段内确认,10 秒倒计时执行;突破加仓:休盘也可提交,开盘后再监控触价</p>
|
||||
{% if not trading_session %}
|
||||
<p class="hint text-muted" id="roll-off-session-hint" style="font-size:.75rem;margin-top:.35rem">当前{{ session_clock.status_label or '休盘' }}:请选「突破加仓」填写突破价后预览并提交监控。</p>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="empty-hint">暂无可用持仓监控</p>
|
||||
<ol class="strategy-steps">
|
||||
<li>打开 <a href="{{ url_for('positions') }}">持仓监控</a>,连接 CTP</li>
|
||||
<li>系统设置为<strong>固定金额</strong>,在「期货下单」开仓(勿开移动保本)</li>
|
||||
<li>开仓成功后生成本页可选监控,即可滚仓</li>
|
||||
</ol>
|
||||
{% endif %}
|
||||
<h3 style="font-size:.85rem;margin:1rem 0 .45rem">活跃滚仓组</h3>
|
||||
{% if roll_groups %}
|
||||
<div class="table-responsive">
|
||||
<table class="strategy-preview-table">
|
||||
<thead><tr>
|
||||
<th>ID</th><th>品种</th><th>方向</th><th>腿数</th><th>首仓手数</th><th>当前总手数</th><th>首仓TP</th><th>当前SL</th><th>当前均价</th><th>止盈盈利(元)</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
{% for g in roll_groups %}
|
||||
<tr>
|
||||
<td>#{{ g.id }}</td>
|
||||
<td>{{ g.symbol_name or g.symbol }}</td>
|
||||
<td>{{ '多' if g.direction == 'long' else '空' }}</td>
|
||||
<td>{{ g.leg_count or 0 }}/3</td>
|
||||
<td>{{ g.first_lots if g.first_lots is not none else '—' }}</td>
|
||||
<td>{{ g.total_lots if g.total_lots is not none else '—' }}</td>
|
||||
<td>{{ g.initial_take_profit or '—' }}</td>
|
||||
<td>{{ g.current_stop_loss or '—' }}</td>
|
||||
<td>{{ g.avg_entry or '—' }}</td>
|
||||
<td>{{ g.reward_at_tp if g.reward_at_tp is not none else '—' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="hint text-muted">暂无</p>
|
||||
{% endif %}
|
||||
<h3 style="font-size:.85rem;margin:1rem 0 .45rem">正在滚仓</h3>
|
||||
{% if roll_legs %}
|
||||
<div class="table-responsive">
|
||||
<table class="strategy-preview-table">
|
||||
<thead><tr>
|
||||
<th>#</th><th>组</th><th>方式</th><th>手数</th><th>触发/限价</th><th>新SL</th><th>当前价</th><th>状态</th><th>操作</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
{% for l in roll_legs %}
|
||||
<tr>
|
||||
<td>{{ l.id }}</td>
|
||||
<td>#{{ l.roll_group_id }}</td>
|
||||
<td>{{ add_mode_labels.get(l.add_mode, l.add_mode) }}</td>
|
||||
<td>{{ l.lots or '—' }}</td>
|
||||
<td>{{ l.breakthrough_price or l.limit_price or l.fill_price or '—' }}</td>
|
||||
<td>{{ l.new_stop_loss or '—' }}</td>
|
||||
<td>{{ l.current_price if l.current_price is not none else '—' }}</td>
|
||||
<td title="{{ l.invalidated_reason or '' }}">{{ roll_leg_status_labels.get(l.status, l.status) }}{% if l.status == 'invalidated' and l.invalidated_reason %} · {{ l.invalidated_reason[:24] }}{% endif %}</td>
|
||||
<td>{% if l.status == 'pending' %}<button type="button" class="btn-link roll-cancel-leg" data-leg-id="{{ l.id }}">删除</button>{% else %}—{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="hint text-muted">暂无</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint" style="margin-top:1rem"><a href="{{ url_for('strategy_records_page') }}">策略交易记录 →</a></p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script src="{{ url_for('static', filename='js/strategy.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,58 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}策略记录 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
.strategy-preview{background:var(--card-inner);border:1px solid var(--card-border);border-radius:8px;padding:.65rem .85rem;font-size:.78rem;line-height:1.5}
|
||||
.strategy-preview-table{width:100%;border-collapse:collapse;font-size:.72rem;min-width:520px}
|
||||
.strategy-preview-table th,.strategy-preview-table td{padding:.35rem .4rem;border-bottom:1px solid var(--table-border);text-align:right;white-space:nowrap}
|
||||
.strategy-preview-table th:first-child,.strategy-preview-table td:first-child{text-align:left}
|
||||
.strategy-preview-table thead th{color:var(--text-muted);font-weight:600;background:var(--list-item-bg)}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="split-grid">
|
||||
<div class="card card-scroll">
|
||||
<h2>趋势回调</h2>
|
||||
{% if trend_rows %}
|
||||
<ul class="list">{% for r in trend_rows %}
|
||||
<li class="list-item"><span>{{ r.symbol }} {{ r.result_label }} · {{ r.closed_at or r.created_at }}</span></li>
|
||||
{% endfor %}</ul>
|
||||
{% else %}<p class="empty-hint">暂无记录</p>{% endif %}
|
||||
</div>
|
||||
<div class="card card-scroll">
|
||||
<h2>顺势加仓</h2>
|
||||
{% if roll_rows %}
|
||||
<ul class="list">{% for r in roll_rows %}
|
||||
<li class="list-item">
|
||||
<details style="width:100%">
|
||||
<summary>{{ r.symbol }} {{ r.result_label }} · {{ r.closed_at or r.created_at }}</summary>
|
||||
<div class="strategy-preview" style="margin-top:.55rem">
|
||||
<p>方向:{{ '多' if r.direction == 'long' else '空' }}</p>
|
||||
<p>首仓手数:{{ r.detail.first_lots or '—' }} · 加仓次数:{{ r.detail.add_count or 0 }} · 加仓手数:{{ r.detail.add_lots or 0 }} · 当前总手数:{{ r.detail.total_lots or '—' }}</p>
|
||||
<p>最新止损:{{ r.detail.latest_stop_loss or '—' }} · 平仓价格:{{ r.detail.close_price or '—' }} · 盈利情况:{{ r.detail.pnl if r.detail.pnl is not none else '—' }}</p>
|
||||
{% if r.detail.legs %}
|
||||
<table class="strategy-preview-table">
|
||||
<thead><tr><th>腿</th><th>方式</th><th>手数</th><th>成交/触发价</th><th>新SL</th><th>时间</th></tr></thead>
|
||||
<tbody>
|
||||
{% for l in r.detail.legs %}
|
||||
<tr>
|
||||
<td>{{ l.leg_index or loop.index }}</td>
|
||||
<td>{{ l.add_mode }}</td>
|
||||
<td>{{ l.lots or '—' }}</td>
|
||||
<td>{{ l.fill_price or l.breakthrough_price or l.limit_price or '—' }}</td>
|
||||
<td>{{ l.new_stop_loss or '—' }}</td>
|
||||
<td>{{ l.created_at or '—' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
{% endfor %}</ul>
|
||||
{% else %}<p class="empty-hint">暂无记录</p>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,312 @@
|
||||
{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
|
||||
{% extends "base.html" %}
|
||||
{% block title %}下单监控 - 国内期货 · 交易复盘系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/trade.css') }}?v={{ asset_v }}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="trade-page">
|
||||
<div class="trade-top-bar">
|
||||
<div class="trade-top-bar-main">
|
||||
<span class="badge dir">{{ trading_mode_label }}</span>
|
||||
<span class="badge {% if ctp_status.connected %}profit{% else %}planned{% endif %}" id="ctp-badge">
|
||||
{% if ctp_status.connected %}CTP 已连接{% else %}CTP 未连接{% endif %}
|
||||
</span>
|
||||
<span class="badge {% if risk_status.can_trade %}profit{% else %}loss{% endif %}" id="risk-badge">{{ risk_status.status_label }}</span>
|
||||
<span class="text-muted">权益 <strong id="cap-display">{{ '%.2f'|format(capital) }}</strong> 元</span>
|
||||
{% if ctp_account.available is defined and ctp_status.connected %}
|
||||
<span class="text-muted">可用 <strong id="avail-display">{{ '%.2f'|format(ctp_account.available) }}</strong> 元</span>
|
||||
{% endif %}
|
||||
<span class="text-muted trade-session-clock" id="session-clock-wrap">
|
||||
· <span id="clock-now">{{ session_clock.now_time }}</span>
|
||||
· <span id="clock-status" class="{% if session_clock.in_session %}text-profit{% else %}text-muted{% endif %}">{{ session_clock.status_label }}</span>
|
||||
<span id="clock-detail" class="session-clock-detail">
|
||||
{% if not session_clock.in_session and session_clock.next_open_at %}
|
||||
· 下次{{ session_clock.next_open_label }} {{ session_clock.next_open_at }}
|
||||
· 距开盘 <strong id="clock-countdown-open">{{ session_clock.countdown_open }}</strong>
|
||||
{% elif session_clock.in_session %}
|
||||
{% if session_clock.countdown_break %}
|
||||
· 距{{ session_clock.break_label }} <strong id="clock-countdown-break">{{ session_clock.countdown_break }}</strong>
|
||||
{% endif %}
|
||||
{% if session_clock.countdown_close %}
|
||||
· 距{{ session_clock.close_label }} <strong id="clock-countdown-close">{{ session_clock.countdown_close }}</strong>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="trade-top-bar-actions">
|
||||
<button type="button" class="btn-primary btn-ctp-sm" id="btn-ctp-connect"
|
||||
{% if not ctp_auto_connect %}disabled title="请先在系统设置 → CTP 连接 中开启自动连接"{% endif %}>
|
||||
{% if ctp_status.connected %}重连 CTP{% else %}连接 CTP{% endif %}
|
||||
</button>
|
||||
<span class="text-muted trade-top-hint" id="ctp-auto-hint">{% if ctp_auto_connect %}交易时段断线自动重连 · 开盘前 30 分钟检查连接 · 不自动强制断开{% else %}自动连接已关闭 · 盘前 30 分钟及交易时段仍会按计划连接 · 断开请手动操作{% endif %}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="split-grid trade-split">
|
||||
<div class="card trade-card" id="order">
|
||||
<h2>期货下单</h2>
|
||||
<div class="card-body">
|
||||
<div class="trade-order-status trade-order-status-compact">
|
||||
<div class="status-row">
|
||||
<span class="text-muted">计仓</span>
|
||||
<strong id="sizing-label">{{ sizing_mode_label }}</strong>
|
||||
{% if sizing_mode == 'fixed' %}
|
||||
<span class="text-muted">· {{ fixed_lots }} 手</span>
|
||||
{% elif sizing_mode in ('amount', 'risk') %}
|
||||
<span class="text-muted">· {{ '%.0f'|format(fixed_amount) }} 元</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<details class="module-rules">
|
||||
<summary>规则说明</summary>
|
||||
<div class="module-rules-body">
|
||||
<p><strong>开仓</strong></p>
|
||||
<ul>
|
||||
<li>须 <strong>CTP 已连接</strong> 且处于<strong>交易时段</strong>;账户风控允许(顶栏状态)</li>
|
||||
<li>固定金额计仓、开启<strong>移动保本</strong>时须填写<strong>止损</strong></li>
|
||||
<li>手数:固定手数,或按止损距离与单笔风险金额自动计算;保证金占用不超过系统设置上限</li>
|
||||
<li>限价未成交 → 挂单中,超时自动撤单(系统设置可改分钟数)</li>
|
||||
</ul>
|
||||
<p><strong>止盈 / 止损 / 移动保本</strong></p>
|
||||
<ul>
|
||||
<li>成交后由程序<strong>本地监控</strong>;触及止盈或止损 → 市价平仓</li>
|
||||
<li><strong>移动保本</strong>:须填止损、不设固定止盈;达 1R 止损移至开仓±缓冲跳,2R 移 1R,依次类推</li>
|
||||
<li>手动平仓写入交易记录;当日手动平仓次数超限 → 当日禁止新开仓</li>
|
||||
</ul>
|
||||
<p><strong>可开仓品种表</strong></p>
|
||||
<ul>
|
||||
<li>按权益与保证金上限筛选;权益 ≤20 万或 CTP 未连接时仅四品种(玉米、豆粕、甲醇、螺纹钢)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<div class="trade-form-rows">
|
||||
<div class="trade-form-line line-3">
|
||||
<div class="symbol-wrap trade-field symbol-mains">
|
||||
<label class="text-label">品种</label>
|
||||
<input type="text" id="trade-symbol" class="symbol-input" placeholder="输入中文或代码,选择主力合约" autocomplete="off">
|
||||
<input type="hidden" id="trade-symbol-code" class="symbol-ths-code">
|
||||
<div class="symbol-dropdown"></div>
|
||||
<div class="symbol-selected" id="sym-selected"></div>
|
||||
</div>
|
||||
<div class="trade-field">
|
||||
<label class="text-label">方向</label>
|
||||
<select id="trade-direction">
|
||||
<option value="long">做多</option>
|
||||
<option value="short">做空</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="trade-field" id="field-lots">
|
||||
<label class="text-label">手数</label>
|
||||
<input type="text" id="trade-lots-calc" class="lots-auto" readonly placeholder="—">
|
||||
<input type="hidden" id="trade-lots" value="{{ fixed_lots if sizing_mode == 'fixed' else '1' }}">
|
||||
<p class="hint lots-warn text-loss" id="lots-warn" hidden></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="trade-form-line line-3">
|
||||
<div class="trade-field">
|
||||
<label class="text-label">入场价</label>
|
||||
<div class="price-type-tabs">
|
||||
<button type="button" class="price-tab active" data-type="limit">限价</button>
|
||||
<button type="button" class="price-tab" data-type="market">市价</button>
|
||||
</div>
|
||||
<input type="number" id="trade-price" step="any" placeholder="限价">
|
||||
<p class="hint market-hint" id="market-hint" hidden>市价以 FAK 即时成交报单(非限价挂单)</p>
|
||||
</div>
|
||||
<div class="trade-field" id="field-tp">
|
||||
<label class="text-label">止盈</label>
|
||||
<input type="number" id="trade-tp" step="any">
|
||||
</div>
|
||||
<div class="trade-field">
|
||||
<label class="text-label">止损</label>
|
||||
<input type="number" id="trade-sl" step="any">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="trade-action-row">
|
||||
<label class="trailing-be-toggle">
|
||||
<input type="checkbox" id="trailing-be">
|
||||
<span>移动保本</span>
|
||||
</label>
|
||||
<p class="hint trailing-be-hint" id="trailing-be-hint" hidden>已开启:仅监控止损,达 1R 后移动保本平仓</p>
|
||||
<span class="hint trade-rr-hint" id="trade-rr-hint" hidden></span>
|
||||
<button type="button" class="btn-primary btn-open" id="btn-open">开仓</button>
|
||||
<p class="hint session-hint text-muted" id="session-hint" hidden>不在交易时间段</p>
|
||||
<p class="trade-order-msg" id="order-msg" hidden></p>
|
||||
</div>
|
||||
|
||||
<div class="trade-footer" id="trade-footer">
|
||||
<p class="hint" id="trade-metrics-hint">填写品种后显示精度与每跳价值;策略自动化请用 <a href="{{ url_for('strategy_page') }}">策略交易</a>。</p>
|
||||
{% if ctp_status.last_error %}
|
||||
<p class="text-loss ctp-install-hint" style="font-size:.78rem;margin-top:.35rem">{{ ctp_status.last_error }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card trade-card" id="trading-live">
|
||||
<h2>委托与持仓 <span class="sync-badge text-muted" id="sync-badge" hidden></span></h2>
|
||||
<p class="hint pos-hint">委托、持仓均以 CTP 柜台为准;止盈止损为程序本地监控,触发后市价平仓。</p>
|
||||
<div class="card-body card-scroll trading-live-body">
|
||||
<section class="trading-live-section" id="active-orders">
|
||||
<h3 class="trading-live-subtitle">当前委托</h3>
|
||||
<div id="order-live-list">
|
||||
<div class="empty-hint" id="order-placeholder">加载委托…</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="trading-live-section trading-live-positions" id="positions">
|
||||
<h3 class="trading-live-subtitle">当前持仓</h3>
|
||||
<div id="position-live-list">
|
||||
<div class="empty-hint" id="position-placeholder">加载持仓…</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card trade-card trade-card-full" id="recommend">
|
||||
<h2>可开仓品种</h2>
|
||||
<div class="card-body">
|
||||
<p class="hint">最大手数 = floor((权益 × 保证金上限 <strong>{{ max_margin_pct }}%</strong> − 已占用保证金) ÷ 1手保证金);当前权益 <strong class="text-accent" id="rec-capital">{{ '%.2f'|format(recommend_capital) }}</strong> 元<span id="rec-margin-hint" class="text-muted"></span>。
|
||||
{% if sizing_mode == 'fixed' %}仅显示最大手数 ≥ <strong>{{ fixed_lots }}</strong> 手的品种。{% endif %}
|
||||
{% if small_account_scope %}<span class="text-muted">{{ small_account_scope_hint }}。</span>{% endif %}
|
||||
{% if small_account_margin_rec %}<span class="text-muted">{{ small_account_margin_rec.label }}。</span>{% endif %}
|
||||
{% if night_session %}<span class="text-muted">当前为夜盘时段,品种下拉与下表仅显示有夜盘品种;带「夜盘」标记。</span>{% elif not small_account_scope %}<span class="text-muted">有夜盘交易的品种带「夜盘」标记。</span>{% endif %}
|
||||
保证金优先读取 CTP 柜台合约信息。
|
||||
{% if recommend_updated_at %}<span class="text-muted">每日后台更新 · 最近 {{ recommend_updated_at }}</span>{% else %}<span class="text-muted" id="rec-updated">等待今日后台刷新…</span>{% endif %}
|
||||
</p>
|
||||
<p class="trend-hint">走势:近一周日线,近3日重叠≥70%为震荡;跳空=今日开盘 vs 昨日收盘。成交量为昨日成交手数,成交额=成交量×昨收×合约乘数。支持按走势/跳空/成交量/振幅排序,可按行业筛选。</p>
|
||||
<div class="rec-stats" id="rec-stats"></div>
|
||||
<div class="rec-sort-bar">
|
||||
<label for="rec-industry-filter">行业</label>
|
||||
<select id="rec-industry-filter">
|
||||
<option value="" selected>全部</option>
|
||||
{% for cat in product_categories %}
|
||||
<option value="{{ cat }}">{{ cat }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="rec-sort-key">排序</label>
|
||||
<select id="rec-sort-key">
|
||||
<option value="trend" selected>走势</option>
|
||||
<option value="gap">跳空</option>
|
||||
<option value="volume">成交量</option>
|
||||
<option value="amplitude">振幅</option>
|
||||
</select>
|
||||
<button type="button" class="rec-sort-dir-btn" id="rec-sort-dir" title="切换升序/降序">↓</button>
|
||||
</div>
|
||||
<div class="trade-table-wrap">
|
||||
<table class="trade-table" id="recommend-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>品种</th><th>交易所</th><th>行业</th><th>走势</th><th>是否跳空</th>
|
||||
<th>参考价</th><th>昨日收盘</th><th>今日开盘</th>
|
||||
<th>昨日涨跌</th><th>昨日振幅</th> <th>成交量(手)</th><th>成交额</th>
|
||||
<th>乘数</th><th>最小变动</th>
|
||||
<th>1手保证金</th><th>1手手续费</th><th>最大手数</th><th>状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="recommend-list">
|
||||
{% if recommend_rows %}
|
||||
{% for r in recommend_rows %}
|
||||
<tr class="rec-{{ r.status }}{% if r.trend_transition %} rec-trend-break{% endif %}">
|
||||
<td>
|
||||
{% if r.main_code and nav_items.market %}
|
||||
<a href="{{ url_for('market_page', symbol=r.main_code, period='d') }}" class="rec-market-link" title="查看日线 K 线">
|
||||
<strong class="{% if r.trend_transition %}trend-name{% endif %}">{{ r.name }}</strong>{% if r.has_night_session %} <span class="night-session-tag">夜盘</span>{% endif %}
|
||||
<span class="text-accent">{{ r.main_code }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<strong class="{% if r.trend_transition %}trend-name{% endif %}">{{ r.name }}</strong>{% if r.has_night_session %} <span class="night-session-tag">夜盘</span>{% endif %}
|
||||
<span class="text-accent">{{ r.main_code or r.ths }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ r.exchange }}</td>
|
||||
<td>{{ r.category or '—' }}</td>
|
||||
<td>
|
||||
{% if r.trend_label and r.trend_label != '—' %}
|
||||
<span class="badge trend-badge {% if r.trend in ('break_long', 'break_short') %}break{% elif r.trend == 'long' %}profit{% elif r.trend == 'short' %}loss{% else %}planned{% endif %}" title="{% if r.trend_overlap_pct is not none %}近3日重叠 {{ r.trend_overlap_pct }}%{% endif %}">
|
||||
{% if r.trend_transition %}★ {% endif %}{{ r.trend_label }}
|
||||
</span>
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if r.gap_label and r.gap_label != '—' %}
|
||||
<span class="badge gap-badge {% if r.gap == 'up' %}profit{% elif r.gap == 'down' %}loss{% else %}planned{% endif %}"{% if r.gap_pct %} title="跳空 {{ '%+.2f'|format(r.gap_pct) }}%"{% endif %}>{{ r.gap_label }}</span>
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
<td>{% if r.price %}{{ r.price }}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.prev_close is not none %}{{ r.prev_close }}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.today_open is not none %}{{ r.today_open }}{% else %}—{% endif %}</td>
|
||||
<td>
|
||||
{% if r.yesterday_change is not none %}
|
||||
<span class="{% if r.yesterday_change > 0 %}rec-change-up{% elif r.yesterday_change < 0 %}rec-change-down{% endif %}">
|
||||
{{ '%+.4f'|format(r.yesterday_change) }}{% if r.yesterday_change_pct is not none %} ({{ '%+.2f'|format(r.yesterday_change_pct) }}%){% endif %}
|
||||
</span>
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
<td>{% if r.yesterday_amplitude_pct is not none %}{{ '%.2f'|format(r.yesterday_amplitude_pct) }}%{% else %}—{% endif %}</td>
|
||||
<td>{% if r.volume is not none %}{{ r.volume }}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.turnover is not none %}{{ '%.0f'|format(r.turnover) }}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.mult is not none %}{{ '%g'|format(r.mult) }}{% if r.spec_source == 'ctp' %} <span class="text-muted">(柜台)</span>{% endif %}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.tick_size is not none %}{{ '%g'|format(r.tick_size) }}{% if r.spec_source == 'ctp' %} <span class="text-muted">(柜台)</span>{% endif %}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.margin_one_lot %}{{ r.margin_one_lot }}{% if r.margin_source == 'ctp' %} <span class="text-muted">(柜台)</span>{% endif %}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.open_fee_one_lot is defined and r.open_fee_one_lot is not none %}{{ r.open_fee_one_lot }}{% else %}—{% endif %}</td>
|
||||
<td>{% if r.max_lots is not none and r.max_lots > 0 %}{{ r.max_lots }}{% else %}—{% endif %}</td>
|
||||
<td><span class="badge {% if r.status=='ok' %}profit{% else %}planned{% endif %}">{{ r.status_label }}</span></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr><td colspan="18" class="empty-hint">等待今日后台刷新推荐…</td></tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="sl-tp-modal" class="modal-mask" role="dialog" aria-labelledby="sl-tp-modal-title">
|
||||
<div class="modal-box sl-tp-modal">
|
||||
<h3 id="sl-tp-modal-title">设置止盈止损</h3>
|
||||
<div class="sl-tp-modal-fields">
|
||||
<div class="trade-field">
|
||||
<label class="text-label" for="sl-tp-modal-sl">止损</label>
|
||||
<input type="number" id="sl-tp-modal-sl" step="any" placeholder="必填(移动保本须填止损)">
|
||||
</div>
|
||||
<div class="trade-field" id="sl-tp-modal-tp-wrap">
|
||||
<label class="text-label" for="sl-tp-modal-tp">止盈</label>
|
||||
<input type="number" id="sl-tp-modal-tp" step="any" placeholder="可留空">
|
||||
</div>
|
||||
<label class="trailing-be-toggle sl-tp-modal-trailing">
|
||||
<input type="checkbox" id="sl-tp-modal-trailing">
|
||||
<span>移动保本</span>
|
||||
</label>
|
||||
<p class="hint" id="sl-tp-modal-trailing-hint" hidden>开启后不设固定止盈;达 1R 后止损移至开仓价 ± 缓冲跳</p>
|
||||
</div>
|
||||
<div class="sl-tp-modal-actions">
|
||||
<button type="button" class="btn-secondary" id="sl-tp-modal-cancel">取消</button>
|
||||
<button type="button" class="btn-primary" id="sl-tp-modal-save">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script type="application/json" id="trade-page-data">{{ {
|
||||
'sizing_mode': sizing_mode,
|
||||
'market_nav_enabled': nav_items.market,
|
||||
'fixed_lots': fixed_lots,
|
||||
'fixed_amount': fixed_amount,
|
||||
'product_categories': product_categories | default([]),
|
||||
'recommend_rows': recommend_rows | default([]),
|
||||
'ctp_auto_connect': ctp_auto_connect,
|
||||
'session_clock': session_clock,
|
||||
'capital': capital,
|
||||
'bootstrap_live': bootstrap_live | default({})
|
||||
} | tojson }}</script>
|
||||
<script src="{{ url_for('static', filename='js/trade.js') }}?v={{ asset_v }}"></script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user