本地监控止盈止损、盘前自动连CTP,并完善保证金与推荐手数。

- 止盈止损改为程序本地监控,触发后市价平仓(含跳空)
- 交易前30分钟后台自动连接 CTP
- 保证金占用上限默认30%,可在系统设置修改
- K线标准蜡烛图红跌绿涨,费率表全宽固定表头
- 品种推荐按保证金比例×总资金计算推荐手数

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-25 12:18:18 +08:00
parent fe1b651900
commit 9875ee6d44
15 changed files with 467 additions and 256 deletions
+2
View File
@@ -430,6 +430,8 @@
name: 'K线',
type: 'candlestick',
data: candle,
barMaxWidth: 14,
barMinWidth: 3,
itemStyle: {
color: c.up,
color0: c.down,
+7 -11
View File
@@ -330,7 +330,7 @@
'</div>'
);
}).join('');
return '<div class="pos-pending-orders"><div class="pending-title">止盈止损挂单</div>' + rows + '</div>';
return '<div class="pos-pending-orders"><div class="pending-title">止盈止损监控</div>' + rows + '</div>';
}
function dismissMonitor(monitorId, btn) {
@@ -381,12 +381,8 @@
lots: row.lots, entry_price: row.entry_price
})) + '">设置止盈止损</button>' : '';
var orderBtn = '';
if (row.monitor_id && (row.stop_loss != null || row.take_profit != null)) {
if (row.can_place_orders) {
orderBtn = '<button type="button" class="pos-order-btn" data-place-orders="' + row.monitor_id + '">委托</button>';
} else {
orderBtn = '<button type="button" class="pos-order-btn pos-order-done" disabled title="止盈止损委托已在柜台">委托</button>';
}
if (row.monitor_id && (row.stop_loss != null || row.take_profit != null) && row.can_place_orders) {
orderBtn = '<button type="button" class="pos-order-btn" data-place-orders="' + row.monitor_id + '">清理旧挂单</button>';
}
var closePayload = encodeURIComponent(JSON.stringify({
source: row.source, symbol_code: row.symbol_code, direction: row.direction,
@@ -403,8 +399,8 @@
actionBtns + '</div>' +
'<div class="pos-card-meta">来源 <strong>' + (row.source_label || 'CTP') + '</strong> · 柜台浮盈' +
(slTpBtn ? ' · ' + slTpBtn : '') +
(row.sl_order_active ? ' · <span class="text-profit">止损已挂</span>' : '') +
(row.tp_order_active ? ' · <span class="text-profit">止盈已挂</span>' : '') + '</div>' +
(row.sl_order_active ? ' · <span class="text-profit">止损监控中</span>' : '') +
(row.tp_order_active ? ' · <span class="text-profit">止盈监控中</span>' : '') + '</div>' +
'<div class="pos-metrics">' +
'<div class="cell"><label>持仓均价</label><div>' + fmtNum(row.entry_price) + '</div></div>' +
'<div class="cell"><label>当前价格</label><div>' + (row.current_price != null ? fmtNum(row.current_price) : '--') + '</div></div>' +
@@ -429,7 +425,7 @@
function placeMonitorOrders(monitorId, btn) {
if (!monitorId) return;
if (!confirm('按开仓快照向柜台挂止盈/止损平仓委托')) return;
if (!confirm('清理该持仓在柜台残留的旧版止盈/止损挂单')) return;
if (btn) {
btn.disabled = true;
btn.textContent = '委托中…';
@@ -643,7 +639,7 @@
'<td>' + (r.ref_take_profit != null ? r.ref_take_profit : '—') + '</td>' +
'<td>' + (r.margin_one_lot != null ? r.margin_one_lot : '—') + '</td>' +
'<td>' + (r.open_fee_one_lot != null ? r.open_fee_one_lot : '—') + '</td>' +
'<td>' + (r.min_capital_one_lot != null ? r.min_capital_one_lot : '—') + '</td>' +
'<td>' + (r.recommended_lots != null && r.recommended_lots > 0 ? r.recommended_lots : '—') + '</td>' +
'<td><span class="badge ' + (r.status === 'ok' ? 'profit' : 'planned') + '">' + (r.status_label || '') + '</span></td>' +
'</tr>'
);