-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1406 lines (1292 loc) · 82.2 KB
/
index.html
File metadata and controls
1406 lines (1292 loc) · 82.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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>仓位计算器 | 风险/盈亏比仓位管理工具</title>
<link rel="manifest" href="./manifest.json">
<meta name="theme-color" content="#0f172a">
<link rel="apple-touch-icon" href="./icons/icon-192x192.png">
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', 'Noto Sans SC', sans-serif;
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
min-height: 100vh;
}
.glass-panel {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.input-group {
transition: all 0.3s ease;
}
.input-group:focus-within {
transform: translateY(-2px);
}
.type-btn, .mode-btn, .tab-btn, .rr-btn, .personality-btn {
transition: all 0.2s ease;
}
.type-btn.active {
background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
color: white;
box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}
.mode-btn {
background-color: #f1f5f9;
border: 1px solid #cbd5e1;
color: #334155;
}
.mode-btn.active {
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
color: white;
border-color: transparent;
box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}
.tab-btn.active {
background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
color: white;
box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
transform: translateY(-2px);
}
.personality-btn.active {
background: linear-gradient(135deg, #475569 0%, #334155 100%);
color: white;
border-color: #94a3b8;
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba(100, 116, 139, 0.4);
}
.rr-btn.active {
background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
color: white;
border-color: transparent;
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}
.result-card {
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
border-left: 4px solid #3b82f6;
}
.target-card-red {
background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
border-left: 4px solid #ef4444;
}
.breakeven-card {
background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
border-left: 4px solid #f97316;
}
.highlight-number {
background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 700;
}
.target-number-red {
background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 700;
}
.rr-badge {
background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
color: white;
font-weight: bold;
}
.entry-input {
background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
border: 2px solid #fecaca;
}
.entry-input:focus {
border-color: #ef4444;
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.stop-input {
background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
border: 2px solid #bbf7d0;
}
.stop-input:focus {
border-color: #22c55e;
box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}
.pit-top-input {
background: linear-gradient(135deg, #fef9c3 0%, #fde047 100%);
border: 2px solid #facc15;
}
.pit-top-input:focus {
border-color: #eab308;
box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.1);
}
.pit-bottom-input {
background: linear-gradient(135deg, #dcfce7 0%, #86efac 100%);
border: 2px solid #4ade80;
}
.pit-bottom-input:focus {
border-color: #22c55e;
box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}
.pit-current-input {
background: #f3f4f6;
border: 2px solid #d1d5db;
}
.pit-current-input:focus {
border-color: #9ca3af;
box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.2);
}
.pit-target-card {
background: linear-gradient(135deg, #fef9c3 0%, #fde047 100%);
border-left: 4px solid #eab308;
}
.pit-profit-card {
background: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%);
border-left: 4px solid #ef4444;
}
.pit-number-target {
background: linear-gradient(135deg, #ca8a04 0%, #a16207 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 700;
}
.pit-number-profit {
background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 700;
}
.protect-entry-input {
background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
border: 2px solid #fecaca;
}
.protect-entry-input:focus {
border-color: #ef4444;
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.protect-stop-input {
background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
border: 2px solid #bbf7d0;
}
.protect-stop-input:focus {
border-color: #22c55e;
box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}
.protect-high-input {
background: linear-gradient(135deg, #fef9c3 0%, #fde047 100%);
border: 2px solid #facc15;
}
.protect-high-input:focus {
border-color: #eab308;
box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.1);
}
.creator-info {
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
color: #fbbf24;
border: 1px solid #fbbf24;
}
.page-container {
display: none;
}
.page-container.active {
display: block;
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.warning-box {
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
border: 1px solid #f59e0b;
color: #92400e;
}
.disclaimer {
background: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.status-success {
background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
border: 1px solid #10b981;
color: #065f46;
}
.status-warning {
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
border: 1px solid #f59e0b;
color: #92400e;
}
.compact-section {
margin-bottom: 0.75rem;
}
.compact-input {
padding: 0.5rem 0.75rem;
font-size: 0.95rem;
}
.compact-label {
font-size: 0.8rem;
margin-bottom: 0.25rem;
}
.compact-btn {
padding: 0.4rem 0.75rem;
font-size: 0.85rem;
}
.compact-card {
padding: 0.75rem;
}
.compact-text {
font-size: 0.85rem;
}
.risk-level-tag {
display: inline-flex;
align-items: center;
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 600;
margin-left: 0.5rem;
transition: all 0.3s;
}
.risk-conservative { background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%); color: #065f46; }
.risk-moderate { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); color: #1e40af; }
.risk-aggressive { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); color: #92400e; }
.risk-heavy { background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%); color: #991b1b; }
.risk-extreme { background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%); color: #6b21a8; }
/* 定制滑块样式 */
input[type="range"] {
-webkit-appearance: none;
width: 100%;
height: 6px;
background: #e2e8f0;
border-radius: 5px;
outline: none;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: #3b82f6;
cursor: pointer;
box-shadow: 0 2px 4px rgba(59, 130, 246, 0.4);
transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover {
transform: scale(1.15);
}
</style>
</head>
<body class="text-slate-800 p-3 md:p-6">
<div class="max-w-6xl mx-auto">
<div class="text-center mb-4 text-white">
<h1 class="text-3xl md:text-4xl font-bold mb-1 tracking-tight">仓位计算器</h1>
<p class="text-slate-300 text-sm">风险/盈亏比仓位管理工具</p>
</div>
<div class="flex justify-center mb-4">
<div class="glass-panel rounded-xl p-1.5 flex gap-1.5 shadow-xl">
<button onclick="switchTab('position')" id="tab-position" class="tab-btn active px-4 py-2 rounded-lg font-medium text-sm flex items-center gap-1.5 transition-all">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 7h6m0 10v-3m-3 3h.01M9 17h.01M9 14h.01M12 14h.01M15 11h.01M12 11h.01M9 11h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path>
</svg>
<span class="text-xs">开仓计算</span>
</button>
<button onclick="switchTab('pit')" id="tab-pit" class="tab-btn px-4 py-2 rounded-lg font-medium text-sm flex items-center gap-1.5 transition-all text-slate-600 hover:text-slate-800">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path>
</svg>
<span class="text-xs">出坑计算</span>
</button>
<button onclick="switchTab('protect')" id="tab-protect" class="tab-btn px-4 py-2 rounded-lg font-medium text-sm flex items-center gap-1.5 transition-all text-slate-600 hover:text-slate-800">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"></path>
</svg>
<span class="text-xs">回撤保护</span>
</button>
</div>
</div>
<div id="page-position" class="page-container active">
<div class="grid lg:grid-cols-2 gap-4">
<div class="glass-panel rounded-xl p-5 shadow-2xl flex flex-col justify-between">
<div>
<div class="flex items-center justify-between mb-4">
<h2 class="text-lg font-bold text-slate-800 flex items-center gap-2">
<svg class="w-5 h-5 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"></path>
</svg>
交易参数
</h2>
<div class="flex gap-2 bg-slate-100 p-1 rounded-lg">
<button onclick="setPersonalityMode('courage')" id="mode-courage" class="personality-btn active px-3 py-1.5 rounded-md text-xs font-medium flex items-center gap-1">
<span>💪</span> 勇气
</button>
<button onclick="setPersonalityMode('sensitive')" id="mode-sensitive" class="personality-btn px-3 py-1.5 rounded-md text-xs font-medium flex items-center gap-1 text-slate-600">
<span>🧠</span> 敏感
</button>
</div>
</div>
<div class="grid grid-cols-2 gap-3 mb-3">
<div>
<label class="block compact-label font-semibold text-slate-600 mb-1">账户总资金 (元)</label>
<div class="relative">
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 text-sm">¥</span>
<input type="number" id="accountBalance" placeholder="100000"
class="w-full pl-7 pr-3 py-2 rounded-lg border border-slate-200 focus:border-blue-500 focus:ring-2 focus:ring-blue-200 outline-none transition-all text-base font-medium"
oninput="calculatePosition()">
</div>
</div>
<div>
<label class="block compact-label font-semibold text-slate-600 mb-1">单笔风险金额</label>
<div class="bg-gray-100 border border-slate-200 rounded-lg px-3 py-2 flex items-center h-[42px]">
<div class="text-lg font-bold text-slate-800">¥<span id="plannedRiskAmount">0</span></div>
</div>
</div>
</div>
<div class="compact-section bg-slate-50 border border-slate-100 px-3 py-2 rounded-lg">
<div class="flex items-center justify-between mb-2">
<div class="flex items-center gap-2">
<label class="block text-xs font-semibold text-slate-600 mb-0 flex items-center">
单笔风险: <span id="riskSliderVal" class="text-blue-600 font-bold ml-1 inline-block w-[45px]">2.00%</span>
</label>
<span id="kellySuggestionBox" class="hidden text-[10px] px-1.5 py-0.5 rounded bg-indigo-50 border border-indigo-100 text-indigo-600 font-medium whitespace-nowrap">
凯利建议: <span id="kellyRange" class="font-bold">--</span>
</span>
<a id="kellyGoToSim" href="https://zxchart.github.io/trading-simu/" target="_blank" class="text-[10px] px-1.5 py-0.5 rounded bg-slate-200 border border-slate-300 text-slate-500 hover:text-blue-600 hover:bg-blue-50 transition-colors whitespace-nowrap">
前往模拟器获取建议 ➔
</a>
</div>
<span id="riskLevelTag" class="risk-level-tag risk-moderate mt-0 flex-shrink-0">稳健</span>
</div>
<div class="relative mt-2 mb-3">
<input type="range" id="riskSlider" min="0.1" max="5.0" step="0.05" value="2.0" oninput="updateRiskFromSlider()" class="m-0 block w-full">
<div id="sliderTicks" class="relative mx-[9px] h-3 mt-1.5 text-[10px] text-slate-400 font-medium pointer-events-none"></div>
</div>
<input type="hidden" id="riskPercent" value="2">
</div>
<div class="compact-section mt-3">
<div class="flex items-center justify-between mb-1.5">
<div class="flex items-center gap-2">
<label class="block compact-label font-semibold text-slate-600 mb-0">开仓</label>
<span id="typeRRHint" class="text-[10px] text-purple-600 font-medium">对应理想盈亏比10:1</span>
</div>
<select id="tradeHistorySelect" onchange="loadTradeHistory()" class="text-[10px] font-medium border border-slate-200 rounded p-1 text-slate-600 outline-none bg-white max-w-[120px] shadow-sm cursor-pointer">
<option value="">最近开仓记录 ▼</option>
</select>
</div>
<div class="grid grid-cols-4 md:grid-cols-3 gap-2 h-10">
<button onclick="setTradeType('B1')" id="type-B1" class="type-btn active h-full rounded-lg border border-slate-200 font-medium flex items-center justify-center gap-1">
<span class="font-bold text-sm">B1</span>
<span class="text-[10px] opacity-80">类B1</span>
</button>
<button onclick="setTradeType('B2')" id="type-B2" class="type-btn h-full rounded-lg border border-slate-200 font-medium flex items-center justify-center gap-1">
<span class="font-bold text-sm">B2</span>
<span class="text-[10px] opacity-80">突破</span>
</button>
<div class="col-span-2 md:col-span-1 relative h-full input-group">
<span class="absolute left-2.5 top-1/2 -translate-y-1/2 text-red-500 font-bold text-sm z-10">¥</span>
<input type="number" id="entryPrice" placeholder="开仓价格" step="0.01"
class="w-full h-full pl-6 pr-1 py-1 rounded-lg entry-input outline-none transition-all text-sm font-medium"
oninput="calculatePosition()" onchange="checkAndSaveHistory()">
</div>
</div>
<input type="hidden" id="tradeType" value="B1">
</div>
<div class="compact-section mt-3">
<div class="flex items-center justify-between mb-1.5">
<label class="block compact-label font-semibold text-slate-600 mb-0">止损</label>
<div class="text-right text-[10px] text-slate-500">
<span id="priceModeInfo">对应幅度: <span class="font-medium text-green-600">--%</span></span>
<span id="percentModeInfo" class="hidden">对应价格: <span class="font-medium text-green-600">¥--</span></span>
</div>
</div>
<div class="grid grid-cols-4 md:grid-cols-3 gap-2 h-10">
<button onclick="setStopMode('price')" id="mode-price" class="mode-btn active h-full rounded-md text-xs font-medium transition-all">固定价格</button>
<button onclick="setStopMode('percent')" id="mode-percent" class="mode-btn h-full rounded-md text-xs font-medium transition-all">固定幅度</button>
<div class="col-span-2 md:col-span-1 relative h-full input-group">
<div id="stopPriceWrapper" class="relative h-full w-full">
<span class="absolute left-2.5 top-1/2 -translate-y-1/2 text-green-500 font-bold text-sm z-10">¥</span>
<input type="number" id="stopPrice" placeholder="止损价格" step="0.01"
class="w-full h-full pl-6 pr-1 py-1 rounded-lg stop-input outline-none transition-all text-sm font-medium"
oninput="calculateFromStopPrice()" onchange="checkAndSaveHistory()">
</div>
<div id="stopPercentWrapper" class="relative h-full w-full hidden">
<span class="absolute left-2 top-1/2 -translate-y-1/2 text-green-500 font-bold text-sm z-10">-</span>
<input type="number" id="stopPercent" placeholder="5" step="0.1" min="0.1" max="50"
class="w-full h-full pl-5 pr-5 py-1 rounded-lg stop-input outline-none transition-all text-sm font-medium"
oninput="calculateFromStopPercent()" onchange="checkAndSaveHistory()">
<span class="absolute right-2 top-1/2 -translate-y-1/2 text-green-400 text-[10px] z-10">%</span>
</div>
</div>
</div>
</div>
</div>
<div class="mt-4 border-t border-slate-100 pt-4">
<a href="https://zxchart.github.io/trading-simu/" target="_blank" class="w-full py-3 px-4 rounded-lg font-bold text-center transition-all text-sm flex justify-center items-center gap-2 border border-blue-300 bg-blue-50 text-blue-600 hover:bg-blue-100 hover:border-blue-400 hover:shadow-md">
🎲 切换至配套工具:策略模拟器 ➔
</a>
</div>
</div>
<div class="space-y-4">
<div class="glass-panel rounded-xl p-5 shadow-2xl">
<h2 class="text-lg font-bold mb-4 text-slate-800 flex items-center gap-2">
<svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 7h6m0 10v-3m-3 3h.01M9 17h.01M9 14h.01M12 14h.01M15 11h.01M12 11h.01M9 11h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path>
</svg>
计算结果
</h2>
<div id="resultsContainer" class="space-y-3 opacity-50 pointer-events-none">
<div class="grid grid-cols-3 gap-3">
<div class="result-card compact-card rounded-lg border-l-purple-500">
<div class="text-xs text-slate-500 mb-0.5">开仓总金额</div>
<div class="text-lg font-bold text-slate-800">¥<span id="positionValue">0</span></div>
<div class="text-xs text-slate-400 mt-0.5">利用率 <span id="capitalUsage" class="font-semibold text-slate-500">0</span>%</div>
</div>
<div class="result-card compact-card rounded-lg border-l-green-500">
<div class="text-xs text-slate-500 mb-0.5">开仓股数</div>
<div class="text-lg font-bold text-slate-800"><span id="positionShares">0</span> <span class="text-xs font-normal text-slate-500">股</span></div>
<div id="sharesAdjustHint" class="text-[10px] text-slate-400 mt-0.5 hidden">自动调整为100股整数倍</div>
</div>
<div class="result-card compact-card rounded-lg border-l-blue-500">
<div class="text-xs text-slate-500 mb-0.5">实际风险金额</div>
<div class="text-lg font-bold highlight-number">¥<span id="actualRiskAmount">0</span></div>
<div class="text-xs text-slate-400 mt-0.5">占账户 <span id="actualRiskPercentDisplay">0%</span></div>
</div>
</div>
<div id="breakevenCard" class="breakeven-card compact-card rounded-lg hidden">
<div class="flex items-center justify-between mb-2">
<div class="text-xs font-semibold text-orange-800 flex items-center gap-1">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path>
</svg>
脱离成本区
</div>
<span class="rr-badge px-1.5 py-0.5 rounded text-xs" id="breakevenRRBadge">4:1</span>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<div class="text-xs text-orange-600 mb-0.5">目标价格</div>
<div class="text-lg font-bold text-orange-700">¥<span id="breakevenPrice">0</span></div>
</div>
<div>
<div class="text-xs text-orange-600 mb-0.5">目标涨幅</div>
<div class="text-lg font-bold text-orange-700">+<span id="breakevenPercent">0</span>%</div>
</div>
</div>
<div class="mt-2 pt-2 border-t border-orange-200 text-xs text-orange-800">
⚡ 脱离成本区后重新回成本平出,继续上涨可考虑放飞,未脱离成本前保持持仓
</div>
</div>
<div class="target-card-red compact-card rounded-lg">
<div class="flex items-center justify-between mb-2">
<div class="text-xs font-semibold text-red-800 flex items-center gap-1">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path>
</svg>
目标收益点位
</div>
<span class="rr-badge px-1.5 py-0.5 rounded text-xs" id="targetRRBadge">10:1</span>
</div>
<div class="grid grid-cols-2 gap-3">
<div>
<div class="text-xs text-red-600 mb-0.5">目标价格</div>
<div class="text-lg font-bold target-number-red">¥<span id="targetPrice">0</span></div>
</div>
<div>
<div class="text-xs text-red-600 mb-0.5">预期收益</div>
<div class="text-base font-bold text-red-700">¥<span id="targetProfit">0</span></div>
</div>
</div>
<div class="mt-2 pt-2 border-t border-red-200 flex justify-between text-xs">
<span class="text-red-600">上涨空间</span>
<span class="font-bold text-red-700">+<span id="targetUpPercent">0</span>%</span>
</div>
</div>
<div id="warningBox" class="hidden bg-amber-50 border border-amber-200 rounded-lg p-3 flex items-start gap-2 text-xs">
<svg class="w-4 h-4 text-amber-500 mt-0.5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
</svg>
<div class="text-amber-800" id="warningText"></div>
</div>
</div>
<div id="emptyState" class="text-center py-8 text-slate-400">
<svg class="w-12 h-12 mx-auto mb-3 opacity-30" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 7h6m0 10v-3m-3 3h.01M9 17h.01M9 14h.01M12 14h.01M15 11h.01M12 11h.01M9 11h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z"></path>
</svg>
<p class="text-sm">请输入交易参数查看计算结果</p>
</div>
</div>
<div class="glass-panel rounded-xl p-4 shadow-xl">
<h3 class="font-bold text-slate-800 mb-2 flex items-center gap-2 text-sm">
<svg class="w-4 h-4 text-amber-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
交易提示
</h3>
<ul class="space-y-1 text-xs text-slate-600">
<li class="flex items-start gap-1.5"><span class="text-emerald-500 mt-0.5">•</span><span><strong>B1类型</strong>:小止损,追求极致盈亏比</span></li>
<li class="flex items-start gap-1.5"><span class="text-emerald-500 mt-0.5">•</span><span><strong>B2类型</strong>:买启动,平衡胜率与盈亏比</span></li>
<li class="flex items-start gap-1.5"><span class="text-emerald-500 mt-0.5">•</span><span>理想盈亏比和脱离成本区盈亏比根据性格模式变化</span></li>
<li class="flex items-start gap-1.5"><span class="text-emerald-500 mt-0.5">•</span><span>A股最小交易单位100股,已自动调整</span></li>
</ul>
</div>
</div>
</div>
</div>
<div id="page-pit" class="page-container">
<div class="grid lg:grid-cols-2 gap-4">
<div class="glass-panel rounded-xl p-5 shadow-2xl">
<h2 class="text-lg font-bold mb-4 text-slate-800 flex items-center gap-2">
<svg class="w-5 h-5 text-amber-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path>
</svg>
出坑计算参数
</h2>
<div class="grid grid-cols-3 gap-3 mb-3">
<div class="input-group">
<label class="block compact-label font-semibold text-slate-600 mb-1">坑口价格</label>
<div class="relative">
<span class="absolute left-2 top-1/2 -translate-y-1/2 text-yellow-600 font-bold text-xs">¥</span>
<input type="number" id="pitTopPrice" placeholder="50" step="0.01"
class="w-full pl-5 pr-2 py-2 rounded-lg pit-top-input outline-none transition-all text-sm font-medium"
oninput="calculatePit()">
</div>
</div>
<div class="input-group">
<label class="block compact-label font-semibold text-slate-600 mb-1">坑底价格</label>
<div class="relative">
<span class="absolute left-2 top-1/2 -translate-y-1/2 text-green-600 font-bold text-xs">¥</span>
<input type="number" id="pitBottomPrice" placeholder="30" step="0.01"
class="w-full pl-5 pr-2 py-2 rounded-lg pit-bottom-input outline-none transition-all text-sm font-medium"
oninput="calculatePit()">
</div>
</div>
<div class="input-group">
<label class="block compact-label font-semibold text-slate-600 mb-1">当前价格</label>
<div class="relative">
<span class="absolute left-2 top-1/2 -translate-y-1/2 text-gray-600 font-bold text-xs">¥</span>
<input type="number" id="pitCurrentPrice" placeholder="45" step="0.01"
class="w-full pl-5 pr-2 py-2 rounded-lg pit-current-input outline-none transition-all text-sm font-medium"
oninput="calculatePit()">
</div>
</div>
</div>
<div class="p-3 bg-amber-50 rounded-lg border border-amber-200">
<h4 class="font-semibold text-amber-900 mb-1.5 flex items-center gap-1.5 text-xs">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
计算公式
</h4>
<div class="text-xs text-amber-800 space-y-0.5">
<div>• 出坑目标价 = 坑口 × 2 - 坑底</div>
<div>• 潜在利润 = (目标价 - 当前价) / 当前价 × 100%</div>
</div>
<p class="text-xs text-amber-600 mt-1.5 font-medium">注:该价位为经验价格,仅供参考</p>
</div>
</div>
<div class="space-y-4">
<div class="glass-panel rounded-xl p-5 shadow-2xl">
<h2 class="text-lg font-bold mb-4 text-slate-800 flex items-center gap-2">
<svg class="w-5 h-5 text-amber-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path>
</svg>
出坑计算结果
</h2>
<div id="pitResultsContainer" class="space-y-3 opacity-50 pointer-events-none">
<div class="grid grid-cols-2 gap-3">
<div class="pit-target-card compact-card rounded-lg">
<div class="text-xs text-yellow-800 mb-0.5">出坑目标价</div>
<div class="text-xl font-bold pit-number-target">¥<span id="pitTargetPrice">0</span></div>
<div class="text-xs text-yellow-700 mt-0.5">经验目标价位</div>
</div>
<div class="pit-profit-card compact-card rounded-lg">
<div class="text-xs text-red-800 mb-0.5">潜在利润空间</div>
<div class="text-xl font-bold pit-number-profit">+<span id="pitProfitPercent">0</span>%</div>
<div class="text-xs text-red-700 mt-0.5">基于当前价格</div>
</div>
</div>
<div class="bg-slate-50 rounded-lg p-3 space-y-1 text-xs">
<div class="flex justify-between py-0.5 border-b border-slate-200">
<span class="text-slate-600">坑口价格</span>
<span class="font-medium text-yellow-600">¥<span id="displayPitTop">0</span></span>
</div>
<div class="flex justify-between py-0.5 border-b border-slate-200">
<span class="text-slate-600">坑底价格</span>
<span class="font-medium text-green-600">¥<span id="displayPitBottom">0</span></span>
</div>
<div class="flex justify-between py-0.5 border-b border-slate-200">
<span class="text-slate-600">当前价格</span>
<span class="font-medium text-gray-600">¥<span id="displayPitCurrent">0</span></span>
</div>
<div class="flex justify-between py-0.5">
<span class="text-slate-600">坑深度</span>
<span class="font-medium text-amber-600">-<span id="pitDepth">0</span>%</span>
</div>
</div>
<div id="pitWarningBox" class="hidden warning-box rounded-lg p-3 flex items-start gap-2 text-xs">
<svg class="w-4 h-4 text-amber-700 mt-0.5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
</svg>
<div class="text-amber-900" id="pitWarningText"></div>
</div>
</div>
<div id="pitEmptyState" class="text-center py-8 text-slate-400">
<svg class="w-12 h-12 mx-auto mb-3 opacity-30" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path>
</svg>
<p class="text-sm">请输入坑口、坑底和当前价格</p>
</div>
</div>
<div class="glass-panel rounded-xl p-4 shadow-xl">
<h3 class="font-bold text-slate-800 mb-2 flex items-center gap-2 text-sm">
<svg class="w-4 h-4 text-amber-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
出坑交易提示
</h3>
<ul class="space-y-1 text-xs text-slate-600">
<li class="flex items-start gap-1.5"><span class="text-yellow-500 mt-0.5">•</span><span>出坑目标价基于经验公式,建议回测标的历史吻合率</span></li>
<li class="flex items-start gap-1.5"><span class="text-green-500 mt-0.5">•</span><span>实际交易需结合量价关系、市场情绪等因素综合判断</span></li>
<li class="flex items-start gap-1.5"><span class="text-blue-500 mt-0.5">•</span><span>价格有效突破坑口后,出坑价格才有意义</span></li>
</ul>
</div>
</div>
</div>
</div>
<div id="page-protect" class="page-container">
<div class="grid lg:grid-cols-2 gap-4">
<div class="glass-panel rounded-xl p-5 shadow-2xl">
<h2 class="text-lg font-bold mb-4 text-slate-800 flex items-center gap-2">
<svg class="w-5 h-5 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"></path>
</svg>
利润回撤保护参数
</h2>
<div class="grid grid-cols-3 gap-3 mb-3">
<div class="input-group">
<label class="block compact-label font-semibold text-slate-600 mb-1">买入价格</label>
<div class="relative">
<span class="absolute left-2 top-1/2 -translate-y-1/2 text-red-500 font-bold text-xs">¥</span>
<input type="number" id="protectEntryPrice" placeholder="50" step="0.01"
class="w-full pl-5 pr-2 py-2 rounded-lg protect-entry-input outline-none transition-all text-sm font-medium"
oninput="calculateProtection()">
</div>
</div>
<div class="input-group">
<label class="block compact-label font-semibold text-slate-600 mb-1">止损价格</label>
<div class="relative">
<span class="absolute left-2 top-1/2 -translate-y-1/2 text-green-500 font-bold text-xs">¥</span>
<input type="number" id="protectStopPrice" placeholder="45" step="0.01"
class="w-full pl-5 pr-2 py-2 rounded-lg protect-stop-input outline-none transition-all text-sm font-medium"
oninput="calculateProtection()">
</div>
</div>
<div class="input-group">
<label class="block compact-label font-semibold text-slate-600 mb-1">最高价格</label>
<div class="relative">
<span class="absolute left-2 top-1/2 -translate-y-1/2 text-yellow-600 font-bold text-xs">¥</span>
<input type="number" id="protectHighPrice" placeholder="65" step="0.01"
class="w-full pl-5 pr-2 py-2 rounded-lg protect-high-input outline-none transition-all text-sm font-medium"
oninput="calculateProtection()">
</div>
</div>
</div>
<div class="compact-section">
<label class="block compact-label font-semibold text-slate-600 mb-1.5">预期盈亏比</label>
<div class="grid grid-cols-3 gap-2 mb-3">
<button onclick="setProtectRR(10)" id="protect-rr-10" class="rr-btn active compact-btn py-1.5 rounded-lg border border-slate-200 font-medium text-xs">10:1</button>
<button onclick="setProtectRR(5)" id="protect-rr-5" class="rr-btn compact-btn py-1.5 rounded-lg border border-slate-200 font-medium text-xs">5:1</button>
<button onclick="setProtectRR(3)" id="protect-rr-3" class="rr-btn compact-btn py-1.5 rounded-lg border border-slate-200 font-medium text-xs">3:1</button>
</div>
<div class="flex items-center gap-3 bg-slate-50 p-2 px-3 rounded-lg border border-slate-100">
<span class="text-xs font-semibold text-slate-500 whitespace-nowrap">自定义</span>
<div class="w-full relative"> <input type="range" id="customRRSlider" min="2" max="20" step="0.5" value="10"
class="m-0 block w-full" oninput="updateProtectRRFromSlider()">
</div>
<span id="customRRValue" class="text-xs font-bold text-indigo-600 w-10 text-right">10:1</span>
</div>
<input type="hidden" id="protectRR" value="10">
</div>
<div class="p-3 bg-indigo-50 rounded-lg border border-indigo-200">
<div class="flex items-center gap-3">
<span class="text-xs text-indigo-700 font-medium">利润回撤</span>
<input type="number" id="retracePercent" value="35" min="10" max="80" step="5"
class="w-16 px-2 py-1.5 rounded-lg border border-indigo-300 text-center font-medium text-indigo-900 text-sm"
oninput="calculateProtection()">
<span class="text-xs text-indigo-700">%时止盈</span>
</div>
</div>
</div>
<div class="space-y-4">
<div class="glass-panel rounded-xl p-5 shadow-2xl">
<h2 class="text-lg font-bold mb-4 text-slate-800 flex items-center gap-2">
<svg class="w-5 h-5 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012-2h2a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path>
</svg>
回撤保护计算结果
</h2>
<div id="protectResultsContainer" class="space-y-3 opacity-50 pointer-events-none">
<div id="protectStatusBox" class="hidden rounded-lg p-3 flex items-center gap-2">
<div id="protectStatusIcon"></div>
<div>
<div id="protectStatusTitle" class="font-bold text-sm"></div>
<div id="protectStatusDesc" class="text-xs opacity-80"></div>
</div>
</div>
<div class="protect-card compact-card rounded-lg">
<div class="text-xs text-indigo-800 mb-0.5">实际盈亏比</div>
<div class="text-xl font-bold protect-number"><span id="actualRR">0</span>:1</div>
<div class="text-xs text-indigo-600 mt-0.5">目标: <span id="targetRRDisplay">10</span>:1</div>
</div>
<div id="retraceResultBox" class="hidden">
<div class="grid grid-cols-2 gap-3 mb-3">
<div class="protect-card compact-card rounded-lg border-l-green-500">
<div class="text-xs text-indigo-800 mb-0.5">回撤止盈价格</div>
<div class="text-lg font-bold text-indigo-900">¥<span id="retracePrice">0</span></div>
</div>
<div class="protect-card compact-card rounded-lg border-l-amber-500">
<div class="text-xs text-indigo-800 mb-0.5">回撤幅度</div>
<div class="text-lg font-bold text-amber-600">-<span id="retracePercentDisplay">35</span>%</div>
</div>
</div>
<div class="p-3 bg-indigo-50 rounded-lg border border-indigo-200">
<div class="text-xs text-indigo-800 mb-1.5 font-medium">利润保护详情</div>
<div class="space-y-1 text-xs">
<div class="flex justify-between">
<span class="text-slate-600">买入价格</span>
<span class="font-medium text-red-600">¥<span id="displayEntry">0</span></span>
</div>
<div class="flex justify-between">
<span class="text-slate-600">最高价格</span>
<span class="font-medium text-yellow-600">¥<span id="displayHigh">0</span></span>
</div>
<div class="flex justify-between">
<span class="text-slate-600">最大浮盈</span>
<span class="font-medium text-green-600">+<span id="maxProfit">0</span>%</span>
</div>
<div class="flex justify-between border-t border-indigo-200 pt-1">
<span class="text-slate-600">回撤止盈价</span>
<span class="font-bold text-indigo-900">¥<span id="displayRetrace">0</span></span>
</div>
<div class="flex justify-between">
<span class="text-slate-600">锁定利润</span>
<span class="font-bold text-amber-600">+<span id="lockedProfit">0</span>%</span>
</div>
</div>
</div>
</div>
<div id="notReachedBox" class="hidden bg-slate-100 rounded-lg p-4 text-center">
<svg class="w-10 h-10 mx-auto mb-2 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<div class="text-base font-medium text-slate-600">未达到目标收益</div>
<div class="text-xs text-slate-500 mt-0.5">当前盈亏比未达到设定目标</div>
</div>
</div>
<div id="protectEmptyState" class="text-center py-8 text-slate-400">
<svg class="w-12 h-12 mx-auto mb-3 opacity-30" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"></path>
</svg>
<p class="text-sm">请输入价格参数查看保护计算</p>
</div>
</div>
<div class="glass-panel rounded-xl p-4 shadow-xl">
<h3 class="font-bold text-slate-800 mb-2 flex items-center gap-2 text-sm">
<svg class="w-4 h-4 text-indigo-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
利润保护提示
</h3>
<ul class="space-y-1 text-xs text-slate-600">
<li class="flex items-start gap-1.5"><span class="text-indigo-500 mt-0.5">•</span><span>达到预期盈亏比后,建议启动利润保护机制</span></li>
<li class="flex items-start gap-1.5"><span class="text-indigo-500 mt-0.5">•</span><span>默认35%回撤止盈可根据市场波动性和个人策略调整</span></li>
<li class="flex items-start gap-1.5"><span class="text-indigo-500 mt-0.5">•</span><span>未达到目标收益前,且无离场信号时,让利润奔跑</span></li>
</ul>
</div>
</div>
</div>
</div>
<div class="mt-6 space-y-3">
<div class="text-center">
<div class="inline-block creator-info px-5 py-2.5 rounded-full text-sm font-medium shadow-lg">
<span class="flex items-center gap-2">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/>
</svg>
制作者:B站/公众号 <a href="https://b23.tv/KYfLfcH" target="_blank" class="underline hover:text-white transition-colors" style="color: #fbbf24;">知行图表交易</a>
</span>
</div>
</div>
<div class="text-center">
<div class="inline-block disclaimer px-5 py-2.5 rounded-xl text-xs text-slate-400">
<span class="flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
</svg>
仅用于价格计算,不构成任何投资建议
</span>
</div>
</div>
</div>
</div>
<script>
// 全局变量
let currentStopMode = 'price';
let currentRiskPercent = 2.0;
let currentTradeType = 'B1';
let currentProtectRR = 10;
let currentMode = 'courage';
// 历史记录变量 (Local Storage)
const HISTORY_KEY = 'zxchart_trade_history';
let tradeHistory = JSON.parse(localStorage.getItem(HISTORY_KEY)) || [];
const MODE_LEVEL_NAMES = {
courage: ['保守', '稳健', '积极', '重仓', '激进'],
sensitive: ['敏感', '保守', '稳健', '适中', '积极']
};
const MODE_RR = {
courage: { B1: 10, B2: 5 },
sensitive: { B1: 6, B2: 3 }
};
const BREAKEVEN_RR = {
courage: { B1: 4, B2: 1 },
sensitive: { B1: 2.5, B2: 1 }
};
const LEVEL_CLASSES = ['risk-conservative', 'risk-moderate', 'risk-aggressive', 'risk-heavy', 'risk-extreme'];
function getRRRatio(type) {
return MODE_RR[currentMode][type];
}
function updateHistoryUI() {
const select = document.getElementById('tradeHistorySelect');
if (!select) return;
select.innerHTML = '<option value="">最近开仓记录 ▼</option>';
tradeHistory.forEach((item, index) => {
const opt = document.createElement('option');
opt.value = index;
opt.textContent = `开:${item.entry} 损:${item.stop}`;
select.appendChild(opt);
});
}
function saveTradeToHistory(entry, stop) {
if (!entry || !stop) return;
const exists = tradeHistory.some(i => parseFloat(i.entry) === parseFloat(entry) && parseFloat(i.stop) === parseFloat(stop));
if (!exists) {
tradeHistory.unshift({ entry: entry, stop: stop });
if (tradeHistory.length > 10) tradeHistory.pop();
localStorage.setItem(HISTORY_KEY, JSON.stringify(tradeHistory));
updateHistoryUI();
}
}
function checkAndSaveHistory() {
const entry = parseFloat(document.getElementById('entryPrice').value);
let stop;
if (currentStopMode === 'price') {
stop = parseFloat(document.getElementById('stopPrice').value);
} else {
const percent = parseFloat(document.getElementById('stopPercent').value);
if (entry && percent) {
stop = entry * (1 - percent / 100);
}
}
if (entry > 0 && stop > 0 && stop < entry) {
saveTradeToHistory(entry.toFixed(2), stop.toFixed(2));
}
}
function loadTradeHistory() {
const select = document.getElementById('tradeHistorySelect');
const index = select.value;
if (index === "") return;
const item = tradeHistory[index];
if (item) {
document.getElementById('entryPrice').value = item.entry;
setStopMode('price');
document.getElementById('stopPrice').value = item.stop;
calculatePosition();
}
select.value = "";
}
function updateSliderTicks(mode) {
const slider = document.getElementById('riskSlider');
const container = document.getElementById('sliderTicks');
let ticks = [];
let max = 5.0;
if (mode === 'courage') {
max = 5.0;
slider.max = "5.0";
ticks = [0.1, 0.5, 1, 1.5, 2, 3, 4, 5];
} else {
max = 2.0;
slider.max = "2.0";
ticks = [0.1, 0.5, 1, 1.5, 2];
if (parseFloat(slider.value) > 2.0) {
slider.value = "2.0";
}
}
const min = 0.1;
let html = '';
ticks.forEach(val => {
const percent = ((val - min) / (max - min)) * 100;
html += `<span class="absolute -translate-x-1/2" style="left: ${percent}%;">${val}</span>`;
});
container.innerHTML = html;
updateRiskFromSlider();
}
function updateRiskFromSlider() {
const val = parseFloat(document.getElementById('riskSlider').value);
document.getElementById('riskSliderVal').textContent = val.toFixed(2) + '%';
currentRiskPercent = val;
document.getElementById('riskPercent').value = val;
let idx = 0;
if (currentMode === 'courage') {
if (val <= 1.0) idx = 0;
else if (val <= 2.0) idx = 1;
else if (val <= 3.0) idx = 2;
else if (val <= 4.0) idx = 3;
else idx = 4;
} else {
if (val <= 0.5) idx = 0;
else if (val <= 1.0) idx = 1;