58020b6e9c
Co-authored-by: Cursor <cursoragent@cursor.com>
182 lines
11 KiB
HTML
182 lines
11 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}交易记录与复盘 - 国内期货监控系统{% endblock %}
|
|
{% block content %}
|
|
<div class="split-grid records-split">
|
|
<div class="card">
|
|
<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="card-scroll">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<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>{% 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,
|
|
"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="7" 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>
|
|
|
|
{% 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 %}
|
|
{% endblock %}
|
|
{% block extra_js %}
|
|
<script src="{{ url_for('static', filename='js/review.js') }}"></script>
|
|
{% endblock %}
|