Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
412 lines (378 loc) · 20.2 KB
/
Copy pathindex.html
File metadata and controls
412 lines (378 loc) · 20.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>交易监控面板</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
/* 基础样式 */
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.main-container {
display: flex;
flex-direction: column;
height: calc(100vh - 40px);
min-height: 768px;
}
.content-area {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
@keyframes fadeOut {
from { opacity: 1; }
to { opacity: 0; }
}
.fade-out {
animation: fadeOut 0.3s ease-out forwards;
}
/* 优化刷新状态指示器 */
#refreshStatus {
animation: fadeOut 0.5s ease-in-out;
z-index: 1000;
}
/* 优化数据更新指示器 */
.highlight-update {
animation: highlight 1s ease-out;
}
@keyframes highlight {
0% { background-color: rgba(16, 185, 129, 0.2); }
100% { background-color: transparent; }
}
#orderLog {
height: 400px;
min-height: 400px;
max-height: 400px;
overflow-y: scroll;
overflow-y: overlay;
white-space: pre-wrap;
overflow-wrap: break-word;
}
#orderLog::-webkit-scrollbar {
width: 8px;
}
/* 状态消息样式 */
.status-message {
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
font-weight: bold;
}
.loading { background-color: #e0f2fe; color: #0c4a6e; border: 1px solid #7dd3fc;}
.error { background-color: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.success { background-color: #dcfce7; color: #166534; border: 1px solid #86efac; }
.warning { background-color: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
/* API连接状态指示器 */
.connection-status {
position: fixed;
top: 10px;
right: 10px;
padding: 5px 10px;
border-radius: 5px;
font-size: 12px;
font-weight: bold;
z-index: 1000;
}
.connected { background-color: #dcfce7; color: #166534; }
.disconnected { background-color: #fee2e2; color: #991b1b; }
/* 刷新状态动画 */
@keyframes fadeOut {
from { opacity: 1; }
to { opacity: 0; }
}
@keyframes pulse {
0% { opacity: 0.6; }
50% { opacity: 0.3; }
100% { opacity: 0.6; }
}
/* 加载图标淡入淡出 */
#holdingsLoading, #logLoading {
transition: opacity 0.3s ease;
}
#holdingsLoading.shown, #logLoading.shown {
opacity: 1;
}
#holdingsLoading:not(.shown), #logLoading:not(.shown) {
opacity: 0;
transition-delay: 0.3s;
}
.api-refreshing .text-blue-700 {
position: relative;
}
.api-refreshing .text-blue-700::after {
content: '';
position: absolute;
bottom: -3px;
left: 0;
width: 100%;
height: 2px;
background: linear-gradient(90deg, rgba(59, 130, 246, 0.5), rgba(96, 165, 250, 0.1));
animation: pulse 2s infinite;
}
.refreshing {
position: relative;
}
.refreshing::after {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(255, 255, 255, 0.1);
pointer-events: none;
animation: pulse 1s infinite;
z-index: 5;
}
/* 低性能模式 */
.low-performance-mode .refreshing::after {
animation: none;
opacity: 0.1;
}
/* 参数验证错误提示 */
.param-error {
color: #ef4444;
font-size: 0.75rem;
margin-top: 0.25rem;
}
/* 模拟交易模式警告 */
.simulation-mode-warning {
background-color: #fef3c7;
border: 1px solid #f59e0b;
color: #92400e;
padding: 0.5rem;
border-radius: 0.25rem;
margin-bottom: 0.5rem;
font-weight: bold;
display: flex;
align-items: center;
}
.simulation-mode-warning svg {
margin-right: 0.5rem;
}
</style>
</head>
<body class="bg-gray-100 p-4">
<div id="connectionStatus" class="connection-status disconnected">API未连接</div>
<div class="container mx-auto bg-white shadow-md rounded-lg p-5">
<div id="messageArea"></div>
<!-- 模拟交易模式警告 -->
<div id="simulationModeWarning" class="simulation-mode-warning hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg>
<span>当前为模拟交易模式,所有买卖操作不会真实执行</span>
</div>
<section class="mb-6 border rounded p-4 bg-gray-50">
<h2 class="text-xl font-semibold mb-3 text-blue-700">1. 参数设置</h2>
<div class="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4 items-center">
<div class="flex flex-col">
<div class="flex items-center space-x-2">
<label for="singleBuyAmount" class="text-sm whitespace-nowrap">单只单次买入金额:</label>
<input type="number" id="singleBuyAmount" class="border rounded px-2 py-1 w-full" value="35000">
</div>
<div id="singleBuyAmountError" class="param-error hidden"></div>
</div>
<div class="flex flex-col">
<div class="flex items-center space-x-2">
<label for="firstProfitSell" class="text-sm whitespace-nowrap">平仓盈利超过:</label>
<input type="number" id="firstProfitSell" class="border rounded px-2 py-1 w-20" value="5.00" step="0.1" min="0">
<input type="checkbox" id="firstProfitSellEnabled" class="form-checkbox h-5 w-5 text-blue-600" checked>
<label for="firstProfitSellEnabled" class="text-sm">%</label>
</div>
<div id="firstProfitSellError" class="param-error hidden"></div>
</div>
<div class="flex flex-col">
<div class="flex items-center space-x-2">
<label for="stockGainSellPencent" class="text-sm whitespace-nowrap">首次盈利平仓卖出:</label>
<input type="number" id="stockGainSellPencent" class="border rounded px-2 py-1 w-20" value="60.00">
<input type="checkbox" id="firstProfitSellPencent" class="form-checkbox h-5 w-5 accent-gray-600" checked>
<label for="firstProfitSellPencent" class="text-sm">%</label>
</div>
<div id="stockGainSellPencentError" class="param-error hidden"></div>
</div>
<div class="flex items-center space-x-2">
<input type="checkbox" id="allowBuy" class="form-checkbox h-5 w-5 text-blue-600" checked>
<label for="allowBuy" class="text-sm">允许买</label>
<input type="checkbox" id="allowSell" class="form-checkbox h-5 w-5 text-blue-600" checked>
<label for="allowSell" class="text-sm">允许卖</label>
</div>
<div class="flex flex-col">
<div class="flex items-center space-x-2">
<label for="stopLossBuy" class="text-sm whitespace-nowrap">补仓跌幅超过:</label>
<input type="number" id="stopLossBuy" class="border rounded px-2 py-1 w-20" value="5.00" step="0.1" min="0">
<input type="checkbox" id="stopLossBuyEnabled" class="form-checkbox h-5 w-5 accent-gray-600" checked>
<label for="stopLossBuyEnabled" class="text-sm">%</label>
</div>
<div id="stopLossBuyError" class="param-error hidden"></div>
</div>
<div class="flex flex-col">
<div class="flex items-center space-x-2">
<label for="stockStopLoss" class="text-sm whitespace-nowrap">平仓止损超过:</label>
<input type="number" id="stockStopLoss" class="border rounded px-2 py-1 w-20" value="7.00" step="0.1" min="0">
<input type="checkbox" id="StopLossEnabled" class="form-checkbox h-5 w-5 accent-gray-600" checked>
<label for="StopLossEnabled" class="text-sm">%</label>
</div>
<div id="stockStopLossError" class="param-error hidden"></div>
</div>
<div class="flex flex-col">
<div class="flex items-center space-x-2">
<label for="singleStockMaxPosition" class="text-sm whitespace-nowrap">单只股票最大持仓:</label>
<input type="number" id="singleStockMaxPosition" class="border rounded px-2 py-1 w-full" value="70000">
</div>
<div id="singleStockMaxPositionError" class="param-error hidden"></div>
</div>
<div class="flex flex-col">
<div class="flex items-center space-x-2">
<label for="totalMaxPosition" class="text-sm whitespace-nowrap">最大总持仓:</label>
<input type="number" id="totalMaxPosition" class="border rounded px-2 py-1 w-full" value="400000">
</div>
<div id="totalMaxPositionError" class="param-error hidden"></div>
</div>
<div class="flex flex-col">
<div class="flex items-center space-x-2">
<label for="totalAccounts" class="text-sm whitespace-nowrap">连接IP:</label>
<input type="text" id="totalAccounts" class="border rounded px-2 py-1 w-full" value="127.0.0.1">
</div>
</div>
<div class="flex flex-col">
<div class="flex items-center space-x-2">
<label for="connectPort" class="text-sm whitespace-nowrap">端口号:</label>
<input type="number" id="connectPort" class="border rounded px-2 py-1 w-full" value="5000">
</div>
<div id="connectPortError" class="param-error hidden"></div>
</div>
<div class="flex items-center space-x-2">
<input type="checkbox" id="simulationMode" class="form-checkbox h-8 w-8 text-orange-600">
<label for="simulationMode" class="text-sm font-bold text-orange-600">模拟交易模式</label>
</div>
<div class="flex items-center space-x-2">
<input type="checkbox" id="globalAllowBuySell" class="form-checkbox h-8 w-8 text-blue-600" checked>
<label for="globalAllowBuySell" class="text-sm">全局监控总开关</label>
</div>
</div>
<div class="mt-4 flex justify-between items-center">
<div id="accountInfo" class="text-sm text-gray-700">
账号 <span id="accountId" class="font-bold">--</span>:
可用金额: <span id="availableBalance" class="font-bold text-green-600">--</span>
最高持股: <span id="maxHoldingValue" class="font-bold">--</span>
总资产: <span id="totalAssets" class="font-bold">--</span>
数据更新时间: <span id="last-update-timestamp">--</span>
</div>
<div id="statusIndicator" class="text-lg font-bold text-red-600">
未运行
</div>
</div>
<div class="mt-4 grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-2">
<button id="toggleMonitorBtn" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded transition duration-150 ease-in-out">
开始执行监控
</button>
<button id="saveConfigBtn" class="bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded transition duration-150 ease-in-out">
保存当前数据
</button>
<button id="clearLogBtn" class="bg-yellow-500 hover:bg-yellow-600 text-white font-bold py-2 px-4 rounded transition duration-150 ease-in-out">
清空日志
</button>
<button id="clearCurrentDataBtn" class="bg-yellow-500 hover:bg-yellow-600 text-white font-bold py-2 px-4 rounded transition duration-150 ease-in-out">
清空当前数据
</button>
<button id="clearBuySellDataBtn" class="bg-yellow-500 hover:bg-yellow-600 text-white font-bold py-2 px-4 rounded transition duration-150 ease-in-out">
清空买入/卖出数据
</button>
<button id="importDataBtn" class="bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 px-4 rounded transition duration-150 ease-in-out">
导入保存数据
</button>
<button id="initHoldingsBtn" class="bg-red-600 hover:bg-red-700 text-white font-bold py-2 px-4 rounded transition duration-150 ease-in-out">
初始化持仓数据
</button>
</div>
</section>
<section class="grid grid-cols-1 lg:grid-cols-3 gap-4">
<div class="lg:col-span-2 flex flex-col space-y-4">
<div class="flex items-center space-x-2 border rounded p-3 bg-gray-50">
<label for="buyStrategy" class="text-sm font-medium whitespace-nowrap">1. 选股买入设置:</label>
<select id="buyStrategy" class="border rounded px-2 py-1 text-sm">
<option value="random_pool">从备选池随机买入</option>
<option value="custom_stock">自定义股票买入</option>
</select>
<input type="number" id="buyQuantity" class="border rounded px-2 py-1 w-20 text-sm" placeholder="数量" value="1">
<label for="buyQuantity" class="text-sm">只</label>
<button id="executeBuyBtn" class="bg-cyan-600 hover:bg-cyan-700 text-white text-sm font-bold py-1 px-3 rounded transition duration-150 ease-in-out whitespace-nowrap">
一键买入
</button>
</div>
<div class="flex-grow border rounded p-3 bg-white overflow-x-auto">
<h3 class="text-lg font-semibold mb-2 text-blue-700 flex items-center">
2. 当前持仓列表
<span id="holdingsLoading" class="ml-2 text-xs text-gray-500 hidden">
<svg class="animate-spin -ml-1 mr-2 h-4 w-4 text-blue-500 inline" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
更新中
</span>
<span id="holdingsError" class="ml-2 text-xs text-red-500 hidden">加载失败</span>
</h3>
<div class="overflow-y-auto max-h-96">
<table class="w-full text-sm text-left border-collapse">
<thead class="bg-gray-200 sticky top-0"> <tr>
<th class="border p-2"><input type="checkbox" id="selectAllHoldings"></th>
<th class="border p-2">代码</th>
<th class="border p-2">名称</th>
<th class="border p-2">涨跌幅</th>
<th class="border p-2">价格</th>
<th class="border p-2">成本价</th>
<th class="border p-2">盈亏率</th>
<th class="border p-2">市值</th>
<th class="border p-2">可用数</th>
<th class="border p-2">总数</th>
<th class="border p-2">已止盈</th>
<th class="border p-2">买后最高</th>
<th class="border p-2">动态止损</th>
<th class="border p-2">建仓时间</th>
<th class="border p-2">基准成本</th>
</tr>
</thead>
<tbody id="holdingsTableBody">
<!-- 持仓数据将在这里插入 -->
</tbody>
</table>
</div>
</div>
</div>
<div class="border rounded p-3 bg-gray-50 flex flex-col relative" style="height: 460px;">
<h3 class="text-lg font-semibold mb-2 text-blue-700 flex items-center">
3. 下单日志
<span id="logLoading" class="ml-2 text-xs text-gray-500 hidden">
<svg class="animate-spin -ml-1 mr-2 h-4 w-4 text-blue-500 inline" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
更新中
</span>
<span id="logError" class="ml-2 text-xs text-red-500 hidden">加载失败</span>
</h3>
<div class="flex-grow relative">
<textarea id="orderLog" class="w-full h-full border rounded p-2 text-xs bg-white resize-none" readonly></textarea>
</div>
</div>
</section>
</div>
<div id="stockSelectDialog" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-white rounded-lg p-6 w-96 max-w-lg">
<h3 id="dialogTitle" class="text-lg font-semibold mb-4">选择股票</h3>
<div id="dialogContent">
<!-- 动态内容会在JavaScript中插入 -->
</div>
<div class="flex justify-end mt-6 space-x-2">
<button id="dialogCancelBtn" class="px-4 py-2 bg-gray-300 rounded hover:bg-gray-400">取消</button>
<button id="dialogConfirmBtn" class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">确定</button>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>