Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1422 lines (1422 loc) · 111 KB
/
Copy pathindex.html
File metadata and controls
1422 lines (1422 loc) · 111 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="en" data-dashboard-version="2026-06-28-public-status-v1">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>Polymarket Strategy Lab</title>
<style>
:root {
color-scheme: light;
--line:#d9e0ea;
--soft-line:#edf1f6;
--text:#172033;
--muted:#667085;
--bg:#f4f6f8;
--panel:#ffffff;
--panel-soft:#f9fafb;
--accent:#2563eb;
--bad:#b42318;
--good:#047857;
--warn:#b7791f;
--shadow:0 10px 30px rgba(16,24,40,.07);
}
* { box-sizing: border-box; }
body { margin:0; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background:var(--bg); color:var(--text); }
header { padding:18px 24px; border-bottom:1px solid var(--line); background:rgba(255,255,255,.94); display:flex; justify-content:space-between; gap:16px; align-items:flex-end; position:sticky; top:0; z-index:5; backdrop-filter:saturate(160%) blur(10px); }
h1 { margin:0; font-size:21px; line-height:1.2; font-weight:760; }
.refresh { text-align:right; line-height:1.5; }
main { padding:18px 24px 36px; max-width:1480px; margin:0 auto; }
.muted { color:var(--muted); font-size:12px; }
.tabs { margin-bottom:14px; display:flex; gap:8px; flex-wrap:wrap; }
.tab { border:1px solid var(--line); background:var(--panel); color:var(--muted); padding:9px 13px; border-radius:8px; font-weight:720; cursor:pointer; box-shadow:0 4px 14px rgba(16,24,40,.04); }
.tab.active { color:#fff; background:var(--accent); border-color:var(--accent); }
.tab-panel { display:none; }
.tab-panel.active { display:block; }
.grid { display:grid; gap:12px; grid-template-columns: repeat(6, minmax(132px, 1fr)); }
.metric, section, .runner { background:var(--panel); border:1px solid var(--line); border-radius:8px; box-shadow:var(--shadow); }
.metric { padding:13px 14px; min-height:82px; border-left:3px solid transparent; }
.metric b { display:block; font-size:23px; margin-top:7px; line-height:1.05; font-variant-numeric:tabular-nums; }
.metric:nth-child(5) { border-left-color:var(--good); }
.metric:nth-child(6), .metric:nth-child(7) { border-left-color:var(--accent); }
.metric:nth-child(10), .metric:nth-child(11) { border-left-color:var(--warn); }
.runner { margin-bottom:14px; padding:16px; display:grid; gap:16px; grid-template-columns: 176px 1fr; align-items:start; }
.runner > div { min-width:0; }
.overview-section { display:grid; gap:14px; }
.overview-separator { margin:18px 0 4px; border-top:1px solid var(--line); }
.section-label { color:var(--muted); font-size:12px; font-weight:760; text-transform:uppercase; letter-spacing:.02em; }
.runner.compact { grid-template-columns: 180px 1fr; margin-bottom:0; }
.runner-state { display:inline-flex; align-items:center; gap:8px; font-weight:780; font-size:19px; }
.dot { width:12px; height:12px; border-radius:50%; background:var(--bad); display:inline-block; }
.dot.good { background:var(--good); box-shadow:0 0 0 4px rgba(4,120,87,.12); }
.dot.warn { background:var(--warn); box-shadow:0 0 0 4px rgba(183,121,31,.14); }
.runner-details { display:grid; gap:10px; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
.runner-details b { display:block; margin-top:3px; font-size:15px; line-height:1.15; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.runner-log { margin-top:12px; padding:12px; border:1px solid var(--soft-line); border-radius:8px; background:#0f172a; color:#dbeafe; font:12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space:pre-wrap; overflow-wrap:anywhere; max-width:100%; max-height:168px; overflow:auto; box-shadow:inset 0 0 0 1px rgba(255,255,255,.03); }
.runner-board { margin-bottom:14px; }
.runner-table { table-layout:fixed; min-width:1180px; }
.runner-table th, .runner-table td { white-space:normal; line-height:1.35; overflow-wrap:anywhere; }
.runner-table th:nth-child(1), .runner-table td:nth-child(1) { width:185px; }
.runner-table th:nth-child(2), .runner-table td:nth-child(2) { width:96px; }
.runner-table th:nth-child(3), .runner-table td:nth-child(3) { width:90px; }
.runner-table th:nth-child(4), .runner-table td:nth-child(4) { width:90px; }
.runner-table th:nth-child(5), .runner-table td:nth-child(5) { width:86px; }
.runner-table th:nth-child(6), .runner-table td:nth-child(6) { width:92px; }
.runner-table th:nth-child(7), .runner-table td:nth-child(7) { width:88px; }
.runner-table th:nth-child(8), .runner-table td:nth-child(8) { width:88px; }
.runner-table th:nth-child(9), .runner-table td:nth-child(9) { width:auto; }
.runner-name { display:flex; align-items:center; gap:8px; font-weight:760; }
.runner-sub { color:var(--muted); font-size:11px; margin-top:3px; }
.era-grid { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:12px; }
.era-card { border:1px solid var(--soft-line); border-radius:8px; padding:14px; background:var(--panel-soft); }
.era-card.current { border-left:3px solid var(--good); background:#fbfffd; }
.era-card.archive { border-left:3px solid var(--warn); }
.era-head { display:flex; justify-content:space-between; gap:10px; align-items:start; margin-bottom:10px; }
.era-title { font-weight:780; font-size:16px; }
.era-read { color:var(--muted); font-size:12px; line-height:1.45; }
.era-stats { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:8px; margin-top:12px; }
.era-stat { padding:9px 10px; border:1px solid var(--soft-line); border-radius:7px; background:#fff; min-height:58px; }
.era-stat span { display:block; color:var(--muted); font-size:11px; }
.era-stat b { display:block; margin-top:5px; font-size:18px; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.lab-table { table-layout:fixed; min-width:1380px; }
.lab-table th, .lab-table td { white-space:normal; line-height:1.35; overflow-wrap:anywhere; }
.lab-table th:nth-child(1), .lab-table td:nth-child(1) { width:190px; }
.lab-table th:nth-child(2), .lab-table td:nth-child(2) { width:132px; }
.lab-table th:nth-child(3), .lab-table td:nth-child(3) { width:118px; }
.lab-table th:nth-child(4), .lab-table td:nth-child(4) { width:72px; }
.lab-table th:nth-child(5), .lab-table td:nth-child(5) { width:82px; }
.lab-table th:nth-child(6), .lab-table td:nth-child(6) { width:86px; }
.lab-table th:nth-child(7), .lab-table td:nth-child(7) { width:78px; }
.lab-table th:nth-child(8), .lab-table td:nth-child(8) { width:82px; }
.lab-table th:nth-child(9), .lab-table td:nth-child(9) { width:250px; }
.lab-table th:nth-child(10), .lab-table td:nth-child(10) { width:auto; }
.verdict { display:inline-flex; align-items:center; justify-content:center; min-width:82px; padding:3px 7px; border-radius:999px; font-weight:760; font-size:11px; }
.verdict.candidate { color:#065f46; background:#dff7ea; }
.verdict.observe { color:#92400e; background:#fef0c7; }
.verdict.more-data { color:#1d4ed8; background:#dbeafe; }
.verdict.reject { color:#991b1b; background:#fee4e2; }
.fold-detail { font:11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color:var(--text); }
.automation-flow { display:grid; grid-template-columns: repeat(7, minmax(112px, 1fr)); gap:10px; }
.automation-step { border:1px solid var(--soft-line); border-radius:8px; background:#fff; padding:12px; min-height:118px; position:relative; }
.automation-step::after { content:""; position:absolute; right:-8px; top:50%; width:8px; height:1px; background:var(--line); }
.automation-step:last-child::after { display:none; }
.automation-step .step-label { font-weight:780; margin:6px 0 4px; }
.automation-step .step-status { display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:760; text-transform:uppercase; color:var(--muted); }
.automation-step.good { border-left:3px solid var(--good); }
.automation-step.warn { border-left:3px solid var(--warn); }
.automation-step.bad { border-left:3px solid var(--bad); }
.automation-step.idle { border-left:3px solid var(--accent); }
.automation-step .step-metric { color:var(--text); font-size:13px; line-height:1.35; overflow-wrap:anywhere; }
.automation-grid { display:grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap:14px; align-items:start; }
.queue-shell { display:grid; gap:14px; }
.queue-summary { display:grid; gap:10px; grid-template-columns: 1.15fr 1.85fr; align-items:stretch; }
.queue-summary-main { border:1px solid var(--soft-line); border-left:4px solid var(--accent); border-radius:8px; padding:13px; background:var(--panel-soft); }
.queue-summary-main.good { border-left-color:var(--good); }
.queue-summary-main b { display:block; font-size:17px; margin-bottom:6px; }
.queue-meta { display:grid; gap:8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.queue-meta div { border:1px solid var(--soft-line); border-radius:8px; padding:10px; background:#fff; min-height:58px; }
.queue-meta span { display:block; color:var(--muted); font-size:11px; }
.queue-meta b { display:block; margin-top:4px; font-size:14px; line-height:1.2; overflow-wrap:anywhere; }
.queue-lane { border:1px solid var(--soft-line); border-radius:8px; background:#fff; overflow:hidden; }
.queue-lane-title { padding:10px 12px; background:var(--panel-soft); border-bottom:1px solid var(--soft-line); font-weight:780; display:flex; justify-content:space-between; gap:10px; }
.queue-section-title { padding:9px 12px; border-bottom:1px solid var(--soft-line); background:#fff; color:var(--muted); font-size:11px; font-weight:800; letter-spacing:.04em; text-transform:uppercase; display:flex; justify-content:space-between; gap:10px; }
.queue-items { display:grid; }
.queue-item { display:grid; grid-template-columns: 150px 130px 1fr 115px; gap:12px; padding:11px 12px; border-bottom:1px solid var(--soft-line); align-items:start; }
.queue-item:last-child { border-bottom:0; }
.queue-item.history { border-left:3px solid var(--good); }
.queue-item.pending { border-left:3px solid var(--accent); }
.queue-item .queue-time { font-variant-numeric:tabular-nums; font-weight:650; }
.queue-item .queue-title { font-weight:720; }
.queue-item .queue-detail { margin-top:3px; color:var(--muted); font-size:12px; line-height:1.35; overflow-wrap:anywhere; }
.queue-status { display:inline-flex; align-items:center; justify-content:center; border-radius:999px; padding:3px 8px; font-size:11px; font-weight:780; background:#e5e7eb; color:var(--text); }
.queue-status.done { background:#dff7ea; color:#065f46; }
.queue-status.pending { background:#dbeafe; color:#1d4ed8; }
details.queue-older { border-top:1px solid var(--soft-line); }
details.queue-older summary { cursor:pointer; padding:10px 12px; color:var(--muted); font-weight:720; background:#fff; }
.automation-decision { border:1px solid var(--soft-line); border-radius:8px; padding:14px; background:var(--panel-soft); }
.automation-decision b { display:block; font-size:18px; margin:4px 0 8px; }
.automation-decision .gate { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:8px; margin-top:10px; }
.automation-decision .gate div { border:1px solid var(--soft-line); border-radius:7px; background:#fff; padding:10px; }
.automation-table { table-layout:fixed; min-width:900px; }
.automation-table th, .automation-table td { white-space:normal; line-height:1.35; overflow-wrap:anywhere; }
.breakdown-table { table-layout:fixed; min-width:1320px; }
.breakdown-table th, .breakdown-table td { white-space:normal; line-height:1.35; overflow-wrap:anywhere; }
.breakdown-table th:nth-child(1), .breakdown-table td:nth-child(1) { width:190px; }
.breakdown-table th:nth-child(2), .breakdown-table td:nth-child(2) { width:52px; }
.breakdown-table th:nth-child(3), .breakdown-table td:nth-child(3) { width:80px; }
.breakdown-table th:nth-child(4), .breakdown-table td:nth-child(4) { width:78px; }
.breakdown-table th:nth-child(5), .breakdown-table td:nth-child(5) { width:120px; }
.breakdown-table th:nth-child(6), .breakdown-table td:nth-child(6) { width:120px; }
.breakdown-table th:nth-child(7), .breakdown-table td:nth-child(7) { width:125px; }
.breakdown-table th:nth-child(8), .breakdown-table td:nth-child(8) { width:125px; }
.breakdown-table th:nth-child(9), .breakdown-table td:nth-child(9) { width:120px; }
.breakdown-table th:nth-child(10), .breakdown-table td:nth-child(10) { width:auto; }
.overview-block { margin-top:14px; }
.compare { display:grid; gap:12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compare-card { background:var(--panel); border:1px solid var(--line); border-radius:8px; box-shadow:var(--shadow); padding:15px; }
.compare-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:14px; }
.compare-title { font-weight:780; font-size:16px; }
.compare-sub { color:var(--muted); font-size:12px; margin-top:2px; }
.compare-stats { display:grid; gap:10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.compare-stat span { color:var(--muted); font-size:12px; display:block; }
.compare-stat b { display:block; margin-top:3px; font-size:18px; line-height:1.1; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
section { margin-top:14px; padding:15px; overflow:auto; }
h2 { font-size:15px; margin:0 0 12px; display:flex; align-items:center; gap:8px; }
h2::before { content:""; width:7px; height:18px; border-radius:4px; background:var(--accent); display:inline-block; }
.sample { margin-top:14px; padding:15px; background:var(--panel); border:1px solid var(--line); border-radius:8px; box-shadow:var(--shadow); display:grid; gap:14px; grid-template-columns: 260px 1fr; align-items:center; }
.sample-stage { font-size:18px; font-weight:780; }
.sample-track { height:10px; border-radius:999px; background:#e5e7eb; overflow:hidden; }
.sample-fill { height:100%; width:0; background:linear-gradient(90deg,#2563eb,#047857); border-radius:inherit; }
.sample-scale { margin-top:7px; display:flex; justify-content:space-between; gap:10px; color:var(--muted); font-size:11px; }
.decision { display:grid; gap:14px; grid-template-columns: 1fr 1fr; align-items:start; }
.decision-card { background:var(--panel); border:1px solid var(--line); border-radius:8px; box-shadow:var(--shadow); padding:15px; }
.decision-title { font-size:15px; font-weight:780; margin-bottom:8px; }
.decision-main { font-size:22px; line-height:1.15; font-weight:780; margin-bottom:6px; overflow-wrap:anywhere; }
.decision-row { display:flex; justify-content:space-between; gap:12px; padding:7px 0; border-top:1px solid var(--soft-line); }
.decision-row:first-of-type { border-top:0; }
.decision-row b { font-variant-numeric:tabular-nums; }
.command-center { display:grid; grid-template-columns: 1.35fr .65fr; gap:14px; align-items:stretch; }
.command-main { border:1px solid var(--line); border-left:5px solid var(--warn); border-radius:8px; background:#fff; box-shadow:var(--shadow); padding:18px; }
.command-main.good { border-left-color:var(--good); }
.command-main.bad { border-left-color:var(--bad); }
.command-kicker { color:var(--muted); font-size:12px; font-weight:760; text-transform:uppercase; letter-spacing:.02em; }
.command-title { font-size:26px; line-height:1.12; font-weight:820; margin:8px 0 10px; }
.command-detail { color:var(--text); line-height:1.45; }
.command-actions { display:grid; gap:8px; margin-top:14px; }
.command-action { border:1px solid var(--soft-line); border-radius:8px; padding:10px 12px; background:var(--panel-soft); }
.command-action b { display:block; margin-bottom:3px; }
.command-side { display:grid; gap:10px; }
.watch-card { border:1px solid var(--line); border-radius:8px; background:#fff; box-shadow:var(--shadow); padding:14px; }
.watch-card span { display:block; color:var(--muted); font-size:12px; }
.watch-card b { display:block; margin-top:5px; font-size:24px; font-variant-numeric:tabular-nums; }
.live-board { display:grid; gap:14px; }
.live-hero { display:grid; gap:14px; grid-template-columns: 1.15fr .85fr; align-items:stretch; }
.live-verdict { border:1px solid var(--line); border-left:6px solid var(--bad); border-radius:8px; background:#fff; box-shadow:var(--shadow); padding:18px; }
.live-verdict.good { border-left-color:var(--good); }
.live-verdict.warn { border-left-color:var(--warn); }
.live-label { color:var(--muted); font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:.03em; }
.live-title { font-size:30px; line-height:1.05; font-weight:840; margin:8px 0 10px; }
.live-detail { line-height:1.45; font-size:14px; }
.live-reasons { display:grid; gap:8px; margin-top:14px; }
.live-reason { border:1px solid var(--soft-line); border-radius:8px; padding:10px 12px; background:var(--panel-soft); display:grid; grid-template-columns:120px 1fr; gap:10px; }
.live-reason b { font-size:12px; }
.live-reason span { font-size:13px; line-height:1.35; }
.live-metrics { display:grid; gap:10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.live-metric { border:1px solid var(--line); border-radius:8px; background:#fff; box-shadow:var(--shadow); padding:14px; min-height:82px; }
.live-metric span { display:block; color:var(--muted); font-size:12px; }
.live-metric b { display:block; margin-top:6px; font-size:25px; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.research-loop { margin-top:14px; border:1px solid var(--line); border-left:5px solid var(--warn); border-radius:8px; background:#fff; box-shadow:var(--shadow); padding:14px; display:grid; gap:12px; grid-template-columns: 1.25fr 2fr; align-items:center; }
.research-loop.good { border-left-color:var(--good); }
.research-loop.bad { border-left-color:var(--bad); }
.research-loop-title { font-size:18px; font-weight:820; display:flex; align-items:center; gap:8px; }
.research-loop-title .dot { flex:0 0 auto; }
.research-loop-sub { margin-top:3px; color:var(--muted); font-size:12px; line-height:1.35; }
.research-loop-grid { display:grid; gap:8px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.research-loop-grid div { border:1px solid var(--soft-line); border-radius:8px; background:var(--panel-soft); padding:9px 10px; min-height:55px; }
.research-loop-grid span { display:block; color:var(--muted); font-size:11px; }
.research-loop-grid b { display:block; margin-top:4px; font-size:15px; line-height:1.15; overflow-wrap:anywhere; }
.next-panel { border:1px solid var(--line); border-radius:8px; background:#fff; box-shadow:var(--shadow); padding:15px; }
.next-panel h2 { margin-bottom:10px; }
.next-list { display:grid; gap:8px; margin:0; padding:0; list-style:none; }
.next-list li { border:1px solid var(--soft-line); border-radius:8px; padding:10px 12px; background:var(--panel-soft); line-height:1.4; }
.analysis-list { display:grid; gap:10px; }
.analysis-item { display:grid; gap:6px; grid-template-columns: 120px 1fr; align-items:start; padding:11px 12px; border:1px solid var(--soft-line); border-left:4px solid var(--accent); border-radius:8px; background:#fff; }
.analysis-item.warn { border-left-color:var(--warn); }
.analysis-item.bad { border-left-color:var(--bad); }
.analysis-item.good { border-left-color:var(--good); }
.analysis-item b { font-size:13px; }
.analysis-item span { color:var(--text); font-size:13px; line-height:1.45; }
.read-panel { display:grid; gap:12px; grid-template-columns: 1.1fr .9fr; align-items:start; }
.read-main { padding:14px; border:1px solid var(--soft-line); border-left:4px solid var(--good); border-radius:8px; background:#fff; }
.read-main.warn { border-left-color:var(--warn); }
.read-main.bad { border-left-color:var(--bad); }
.read-main b { display:block; font-size:18px; margin-bottom:6px; }
.read-main div { color:var(--text); line-height:1.45; }
.read-list { display:grid; gap:8px; }
.read-row { display:flex; justify-content:space-between; gap:12px; padding:9px 10px; border:1px solid var(--soft-line); border-radius:8px; background:#fff; }
.read-row b { font-variant-numeric:tabular-nums; }
.decision-table { table-layout:fixed; min-width:1120px; }
.decision-table th, .decision-table td { white-space:normal; line-height:1.35; overflow-wrap:anywhere; }
.decision-table th:nth-child(1), .decision-table td:nth-child(1) { width:150px; }
.decision-table th:nth-child(2), .decision-table td:nth-child(2) { width:130px; }
.decision-table th:nth-child(3), .decision-table td:nth-child(3) { width:130px; }
.decision-table th:nth-child(4), .decision-table td:nth-child(4) { width:130px; }
.decision-table th:nth-child(5), .decision-table td:nth-child(5) { width:120px; }
.decision-table th:nth-child(6), .decision-table td:nth-child(6) { width:auto; }
.decision-main-text { font-weight:650; color:var(--text); }
.decision-next-text { margin-top:5px; color:var(--muted); }
.decision-next-text b { color:var(--text); font-weight:650; }
table { width:100%; border-collapse:separate; border-spacing:0; font-size:12px; }
th, td { padding:8px 9px; border-bottom:1px solid var(--soft-line); text-align:left; vertical-align:top; white-space:nowrap; }
th { color:var(--muted); font-weight:680; background:var(--panel-soft); position:sticky; top:0; }
tbody tr:hover { background:#f8fafc; }
.coverage-note { margin:0 0 10px; color:var(--muted); font-size:12px; }
.coverage-table td:nth-child(1) { font-weight:720; }
.coverage-table td:nth-child(2) { color:var(--muted); }
.coverage-table .empty-row td { color:var(--muted); }
.cols { display:grid; gap:14px; grid-template-columns: 1.2fr .8fr; }
.trade-cols { display:grid; gap:14px; grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr); align-items:start; }
#recent table, #open table, #highprob-trades table, #highprob-open table, #near-expiry-trades table, #near-expiry-open table { table-layout:fixed; }
#recent th:nth-child(1), #recent td:nth-child(1), #highprob-trades th:nth-child(1), #highprob-trades td:nth-child(1), #near-expiry-trades th:nth-child(1), #near-expiry-trades td:nth-child(1) { width:128px; }
#recent th:nth-child(2), #recent td:nth-child(2), #highprob-trades th:nth-child(2), #highprob-trades td:nth-child(2), #near-expiry-trades th:nth-child(2), #near-expiry-trades td:nth-child(2) { width:72px; }
#recent th:nth-child(3), #recent td:nth-child(3), #highprob-trades th:nth-child(3), #highprob-trades td:nth-child(3), #near-expiry-trades th:nth-child(3), #near-expiry-trades td:nth-child(3) { width:62px; }
#recent th:nth-child(4), #recent td:nth-child(4), #highprob-trades th:nth-child(4), #highprob-trades td:nth-child(4), #near-expiry-trades th:nth-child(4), #near-expiry-trades td:nth-child(4) { width:70px; }
#recent th:nth-child(5), #recent td:nth-child(5), #highprob-trades th:nth-child(5), #highprob-trades td:nth-child(5), #near-expiry-trades th:nth-child(5), #near-expiry-trades td:nth-child(5) { width:84px; }
#recent th:nth-child(6), #recent td:nth-child(6), #highprob-trades th:nth-child(6), #highprob-trades td:nth-child(6), #near-expiry-trades th:nth-child(6), #near-expiry-trades td:nth-child(6) { width:64px; }
#recent th:nth-child(7), #recent td:nth-child(7), #highprob-trades th:nth-child(7), #highprob-trades td:nth-child(7), #near-expiry-trades th:nth-child(7), #near-expiry-trades td:nth-child(7) { width:74px; }
#recent th:nth-child(8), #recent td:nth-child(8), #highprob-trades th:nth-child(8), #highprob-trades td:nth-child(8), #near-expiry-trades th:nth-child(8), #near-expiry-trades td:nth-child(8) { width:84px; }
#open th:nth-child(1), #open td:nth-child(1), #highprob-open th:nth-child(1), #highprob-open td:nth-child(1), #near-expiry-open th:nth-child(1), #near-expiry-open td:nth-child(1) { width:142px; }
#open th:nth-child(2), #open td:nth-child(2), #highprob-open th:nth-child(2), #highprob-open td:nth-child(2), #near-expiry-open th:nth-child(2), #near-expiry-open td:nth-child(2) { width:74px; }
#open th:nth-child(3), #open td:nth-child(3), #highprob-open th:nth-child(3), #highprob-open td:nth-child(3), #near-expiry-open th:nth-child(3), #near-expiry-open td:nth-child(3) { width:82px; }
#open th:nth-child(4), #open td:nth-child(4), #highprob-open th:nth-child(4), #highprob-open td:nth-child(4), #near-expiry-open th:nth-child(4), #near-expiry-open td:nth-child(4) { width:92px; }
#open th:nth-child(5), #open td:nth-child(5), #highprob-open th:nth-child(5), #highprob-open td:nth-child(5), #near-expiry-open th:nth-child(5), #near-expiry-open td:nth-child(5) { width:64px; }
#open th:nth-child(6), #open td:nth-child(6), #highprob-open th:nth-child(6), #highprob-open td:nth-child(6), #near-expiry-open th:nth-child(6), #near-expiry-open td:nth-child(6) { width:60px; }
#open th:nth-child(7), #open td:nth-child(7), #highprob-open th:nth-child(7), #highprob-open td:nth-child(7), #near-expiry-open th:nth-child(7), #near-expiry-open td:nth-child(7) { width:84px; }
#recent td, #open td, #highprob-trades td, #highprob-open td, #near-expiry-trades td, #near-expiry-open td { overflow:hidden; text-overflow:ellipsis; }
.good { color:var(--good); } .bad { color:var(--bad); }
.status { display:inline-flex; align-items:center; min-width:54px; justify-content:center; padding:3px 7px; border-radius:999px; font-weight:700; font-size:11px; }
.status.win { color:#065f46; background:#dff7ea; }
.status.loss { color:#991b1b; background:#fee4e2; }
.status.open { color:#92400e; background:#fef0c7; }
.market-link { color:#1d4ed8; font-weight:680; text-decoration:none; }
.market-link:hover { text-decoration:underline; }
.chart-wrap { position:relative; }
.legend { position:absolute; top:10px; right:14px; display:flex; gap:14px; color:var(--muted); font-size:12px; background:rgba(255,255,255,.86); padding:5px 7px; border:1px solid var(--soft-line); border-radius:999px; }
.legend span { display:inline-flex; align-items:center; gap:6px; }
.swatch { width:18px; height:3px; border-radius:2px; display:inline-block; }
.swatch.pnl { background:var(--accent); }
.swatch.yesno { background:#b7791f; }
details.diagnostics { margin-top:14px; background:var(--panel); border:1px solid var(--line); border-radius:8px; box-shadow:var(--shadow); overflow:hidden; }
details.diagnostics summary { cursor:pointer; padding:15px; font-weight:760; list-style:none; display:flex; align-items:center; gap:8px; }
details.diagnostics summary::-webkit-details-marker { display:none; }
details.diagnostics summary::before { content:""; width:7px; height:18px; border-radius:4px; background:var(--warn); display:inline-block; }
details.diagnostics .content { padding:0 15px 15px; overflow:auto; }
.hidden-data { display:none; }
canvas { width:100%; height:260px; border:1px solid var(--soft-line); border-radius:8px; background:linear-gradient(#fff,#fbfcfe); }
@media (max-width: 980px) { .grid, .status-metrics { grid-template-columns: repeat(2, 1fr); } .cols, .trade-cols, .runner, .runner.compact, .sample, .status-strip, .compare, .decision, .read-panel, .era-grid, .command-center, .live-hero, .research-loop, .automation-grid, .automation-flow, .queue-summary, .queue-meta, .queue-item { grid-template-columns: 1fr; } .automation-step::after { display:none; } .runner-details { grid-template-columns: repeat(2, 1fr); } header { display:block; } .era-stats, .live-metrics, .research-loop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
</style>
</head>
<body>
<header>
<div><h1>Polymarket Strategy Lab</h1><div class="muted">public paper trading, arbitrage research, and live-readiness monitor</div></div>
<div class="muted refresh"><div>auto-refresh: 10s</div><div id="updated"></div></div>
</header>
<main>
<div class="tabs">
<button class="tab active" data-tab="overview">Status</button>
<button class="tab" data-tab="arb-execution">Execution</button>
<button class="tab" data-tab="automation">Automation</button>
<button class="tab" data-tab="archive">Archive</button>
</div>
<div class="tab-panel active" id="tab-overview">
<div id="live-decision"></div>
<div id="research-loop"></div>
<section class="runner-board"><h2>Runner Status</h2><div class="muted" style="margin-bottom:10px">Remote health page: check this first. Stale/stopped rows mean the VPS runner or publisher needs attention.</div><div id="overview-runner-board"></div></section>
<section class="overview-block"><h2>Scan Schedule</h2><div class="muted" style="margin-bottom:10px">Default VPS scan cadence. Execution runners are intentionally faster; research runners are intentionally slower to limit API and CPU load.</div><div id="scan-schedule"></div></section>
<section class="overview-block"><h2>Current Data Window</h2><div class="muted" style="margin-bottom:10px">Current VPS-era data is the operating sample. Historical local data is kept only for research context.</div><div id="current-era"></div></section>
<section><h2>OPEN Positions</h2><div id="overview-open"></div></section>
<div class="hidden-data">
<div id="overview-no-trade"></div>
<div id="strategy-decisions"></div>
<div id="overview-focus"></div>
<div id="overview-direction-compare"></div>
<div id="overview-arb-read"></div>
<div id="overview-arb-metrics"></div>
<canvas id="curve" width="1200" height="260"></canvas>
<canvas id="arb-curve" width="1200" height="260"></canvas>
</div>
</div>
<div class="tab-panel" id="tab-arb-execution">
<section><h2>Execution Readiness</h2><div id="arb-execution-readiness"></div></section>
<section><h2>Arb Execution Summary</h2><div class="muted" style="margin-bottom:10px">Only the currently useful arbitrage execution path is shown here: discovery, strict paper candidate, and live-like execution lab.</div><div id="arb-execution-board"></div></section>
<section><h2>Universe Coverage</h2><div class="coverage-note">Shows what each arb runner is actually scanning. This separates BTC/ETH/SOL short crypto markets from generic BINARY_TOP markets.</div><div id="arb-universe-coverage"></div></section>
<details class="diagnostics"><summary>Execution Failure Reasons</summary><div class="content"><section><div id="arb-execution-reasons"></div></section></div></details>
<details class="diagnostics"><summary>Recent Arb Attempts</summary><div class="content"><section><div id="arb-execution-attempts"></div></section></div></details>
</div>
<div class="tab-panel" id="tab-automation">
<section><h2>Automation Flow</h2><div class="muted" style="margin-bottom:10px">Quasi-realtime view from public summary.json. This shows what the automated research loop is doing and where live promotion is blocked.</div><div id="automation-flow"></div></section>
<section><h2>Research Queue</h2><div id="automation-queue"></div></section>
<section><h2>Decision Gates</h2><div id="automation-decision"></div></section>
</div>
<div class="tab-panel" id="tab-archive">
<section><h2>Strategy Decision Board</h2><div class="muted" style="margin-bottom:10px">Historical decisions and rejected ideas live here. The Status tab is the current operating view.</div><div id="archive-strategy-decisions"></div></section>
<section><h2>Archived Direction Runners</h2><div class="muted" style="margin-bottom:10px">Direction-family runners are retained as research history, not current live candidates.</div><div id="archive-direction-board"></div></section>
<section><h2>Research Snapshot</h2><div id="archive-research"></div></section>
<details class="diagnostics"><summary>Detailed Historical Research</summary><div class="content">
<section class="overview-block"><h2>Strategy Validation Matrix</h2><div class="muted" style="margin-bottom:10px">Walk-forward validation over historical opportunities. This is research context, not a live instruction.</div><div id="strategy-validation"></div></section>
<section class="overview-block"><h2>Deterioration-Aware Candidates</h2><div class="muted" style="margin-bottom:10px">Offline filters generated from recent fold losses.</div><div id="deterioration-candidates"></div></section>
<section class="overview-block"><h2>Fold Breakdown</h2><div class="muted" style="margin-bottom:10px">Loss concentration by side, price band, BTC regime, volatility bucket, and expiry bucket.</div><div id="fold-breakdown"></div></section>
<section><h2>Auto Analysis Notes</h2><div class="muted" style="margin-bottom:10px">Generated status notes. The Decision Board above is the primary follow-up tracker.</div><div id="overview-analysis"></div></section>
</div></details>
<details class="diagnostics"><summary>Diagnostics</summary><div class="content">
<section><h2>Runner Status</h2><div id="diagnostics-runner-board"></div></section>
<section><h2>Runner Logs</h2><div id="diagnostics-logs"></div></section>
<section><h2>API / Execution Errors</h2><div id="diagnostics-errors"></div></section>
</div></details>
</div>
<div class="tab-panel" id="tab-direction">
<div class="grid" id="direction-summary"></div>
<section><h2>Direction No-Trade Diagnosis</h2><div class="muted">Recent windows ending at the latest scan. This explains why scans did not become placed trades.</div><div id="no-trade-reasons"></div></section>
<div class="runner" id="runner"></div>
<div class="trade-cols">
<section><h2>Recent 20 Trades</h2><div id="recent"></div></section>
<section><h2>OPEN Positions</h2><div id="open"></div></section>
</div>
<section><h2>Direction PnL Curve</h2><div class="chart-wrap"><div class="legend"><span><i class="swatch pnl"></i>PnL</span></div><canvas id="direction-detail-curve" width="1200" height="260"></canvas></div></section>
<div class="overview-separator"></div>
<div class="section-label">Analysis</div>
<div class="sample" id="sample-status"></div>
<section><h2>Offline Optimizer</h2><div class="muted">Grid search over historical opportunities with a time split. Validation metrics are the part after the split, so this is a guard against pure in-sample curve fitting.</div><div id="optimizer-stats"></div></section>
<details class="diagnostics"><summary>Detailed Direction Analysis</summary><div class="content">
<section><h2>Strategy Stats</h2><div id="strategy-stats"></div></section>
<section><h2>Strategy Replay</h2><div id="replay-stats"></div></section>
<section><h2>Trade Quality</h2><div class="cols"><div id="quality-prob"></div><div id="quality-other"></div></div></section>
<section><h2>Market Environment</h2><div class="cols"><div id="environment-trend"></div><div id="environment-volatility"></div></div></section>
<div class="cols">
<section><h2>Event Segments</h2><div id="segments"></div></section>
<section><h2>signals=1 placed=0 Reasons</h2><div id="reasons"></div></section>
</div>
</div></details>
</div>
<div class="tab-panel" id="tab-highprob">
<div class="grid" id="highprob-summary"></div>
<section><h2>High-Prob No-Trade Diagnosis</h2><div id="highprob-diagnosis"></div></section>
<div class="runner" id="highprob-runner"></div>
<div class="trade-cols">
<section><h2>Recent 20 Trades</h2><div id="highprob-trades"></div></section>
<section><h2>OPEN Positions</h2><div id="highprob-open"></div></section>
</div>
<section><h2>High-Prob Probability Curve</h2><div class="chart-wrap"><div class="legend"><span><i class="swatch pnl"></i>Max Prob</span></div><canvas id="highprob-prob-curve" width="1200" height="260"></canvas></div></section>
<div class="overview-separator"></div>
<div class="section-label">Analysis</div>
<div class="cols">
<section><h2>Scan Funnel</h2><div id="highprob-funnel"></div></section>
<section><h2>Probability Buckets</h2><div id="highprob-buckets"></div></section>
</div>
<section><h2>Recent Candidate Opportunities</h2><div id="highprob-recent"></div></section>
<section><h2>High-Prob Notes</h2><div class="muted">Independent direction dry-run using MIN_PROB=0.90 and data_highprob. It only trades when the momentum-derived model probability reaches 90% or higher.</div></section>
</div>
<div class="tab-panel" id="tab-nochop">
<div class="grid" id="nochop-summary"></div>
<section><h2>No-Chop No-Trade Diagnosis</h2><div id="nochop-diagnosis"></div></section>
<div class="runner" id="nochop-runner"></div>
<div class="trade-cols">
<section><h2>Recent 20 Trades</h2><div id="nochop-trades"></div></section>
<section><h2>OPEN Positions</h2><div id="nochop-open"></div></section>
</div>
<section><h2>No-Chop Probability Curve</h2><div class="chart-wrap"><div class="legend"><span><i class="swatch pnl"></i>Max Prob</span></div><canvas id="nochop-prob-curve" width="1200" height="260"></canvas></div></section>
<div class="overview-separator"></div>
<div class="section-label">Analysis</div>
<div class="cols">
<section><h2>Scan Funnel</h2><div id="nochop-funnel"></div></section>
<section><h2>Probability Buckets</h2><div id="nochop-buckets"></div></section>
</div>
<section><h2>Recent Candidate Opportunities</h2><div id="nochop-recent"></div></section>
<section><h2>No-Chop Notes</h2><div class="muted">Independent dry-run using MIN_PROB=0.90, EXCLUDE_BTC_CHOP=true, BTC_CHOP_THRESHOLD=0.0005, and data_nochop_highprob. It scans every 15 seconds by default.</div></section>
</div>
<div class="tab-panel" id="tab-midvol">
<div class="grid" id="midvol-summary"></div>
<section><h2>Mid-Vol No-Trade Diagnosis</h2><div id="midvol-diagnosis"></div></section>
<div class="runner" id="midvol-runner"></div>
<div class="trade-cols">
<section><h2>Recent 20 Trades</h2><div id="midvol-trades"></div></section>
<section><h2>OPEN Positions</h2><div id="midvol-open"></div></section>
</div>
<section><h2>Mid-Vol Probability Curve</h2><div class="chart-wrap"><div class="legend"><span><i class="swatch pnl"></i>Max Prob</span></div><canvas id="midvol-prob-curve" width="1200" height="260"></canvas></div></section>
<div class="overview-separator"></div>
<div class="section-label">Analysis</div>
<div class="cols">
<section><h2>Scan Funnel</h2><div id="midvol-funnel"></div></section>
<section><h2>Probability Buckets</h2><div id="midvol-buckets"></div></section>
</div>
<section><h2>Recent Candidate Opportunities</h2><div id="midvol-recent"></div></section>
<section><h2>Mid-Vol Notes</h2><div class="muted">Independent direction dry-run using MIN_PROB=0.90, VOL_BUCKET_FILTER=mid, and data_midvol_highprob. It only opens new positions during mid realized-volatility windows.</div></section>
</div>
<div class="tab-panel" id="tab-near-expiry">
<div class="grid" id="near-expiry-summary"></div>
<section><h2>Near-Expiry No-Trade Diagnosis</h2><div id="near-expiry-diagnosis"></div></section>
<div class="runner" id="near-expiry-runner"></div>
<div class="trade-cols">
<section><h2>Recent 20 Trades</h2><div id="near-expiry-trades"></div></section>
<section><h2>OPEN Positions</h2><div id="near-expiry-open"></div></section>
</div>
<section><h2>Near-Expiry Probability Curve</h2><div class="chart-wrap"><div class="legend"><span><i class="swatch pnl"></i>Max Prob</span></div><canvas id="near-expiry-prob-curve" width="1200" height="260"></canvas></div></section>
<div class="overview-separator"></div>
<div class="section-label">Analysis</div>
<div class="cols">
<section><h2>Scan Funnel</h2><div id="near-expiry-funnel"></div></section>
<section><h2>Probability Buckets</h2><div id="near-expiry-buckets"></div></section>
</div>
<section><h2>Recent Candidate Opportunities</h2><div id="near-expiry-recent"></div></section>
<section><h2>Near-Expiry Notes</h2><div class="muted">Independent dry-run using a near-expiry distance model. It only considers markets close to settlement and estimates win probability from BTC distance to the market start price, remaining time, and recent volatility.</div></section>
</div>
<div class="tab-panel" id="tab-arbitrage">
<div class="grid" id="arb-main-summary"></div>
<section><h2>Arb Scanner Read</h2><div id="arb-main-read"></div></section>
<div class="runner" id="arb-exec-runner"></div>
<section><h2>Arb Scanner Universes</h2><div class="muted" style="margin-bottom:10px">Grouped scanner output for BTC/ETH/SOL 5m and 15m Up/Down markets plus BINARY_TOP high-volume two-outcome markets. Legacy rows without universe are counted as BTC_5M.</div><div id="arb-universes"></div></section>
<section><h2>Arb Scanner YES+NO Curve</h2><div class="chart-wrap"><div class="legend"><span><i class="swatch yesno"></i>YES+NO</span></div><canvas id="arb-main-curve" width="1200" height="260"></canvas></div></section>
<section><h2>Scanner Metrics</h2><div class="grid" id="arb-main-metrics"></div><div id="arb-main-reasons"></div></section>
<div class="trade-cols">
<section><h2>OPEN Scanner Paper Positions</h2><div id="arb-main-open"></div></section>
<section><h2>Recent Scanner Paper Trades</h2><div id="arb-main-recent"></div></section>
</div>
<section><h2>Recent Scanner Attempts</h2><div id="arb-main-attempts"></div></section>
<details class="diagnostics"><summary>Legacy Scanner / Micro Diagnostics</summary><div class="content">
<div class="runner" id="arb-runner"></div>
<div class="runner" id="arb-micro-runner"></div>
<section><h2>Micro-Live Dry-Run</h2><div class="grid" id="arb-micro-metrics"></div><div id="arb-micro-reasons"></div></section>
<section><h2>Arbitrage Replay</h2><div id="arb-replay"></div></section>
<section><h2>Recent Arbitrage Opportunities</h2><div id="arb-recent"></div></section>
<section><h2>Recent Micro Attempts</h2><div id="arb-micro-recent"></div></section>
</div></details>
</div>
<div class="tab-panel" id="tab-arb-conservative">
<div class="grid" id="arb-conservative-summary"></div>
<section><h2>Arb Paper Exec Read</h2><div id="arb-conservative-read"></div></section>
<div class="runner" id="arb-conservative-runner"></div>
<section><h2>Arb Paper Exec YES+NO Curve</h2><div class="chart-wrap"><div class="legend"><span><i class="swatch yesno"></i>YES+NO</span></div><canvas id="arb-conservative-curve" width="1200" height="260"></canvas></div></section>
<section><h2>Paper Execution Metrics</h2><div class="grid" id="arb-conservative-metrics"></div><div id="arb-conservative-reasons"></div></section>
<div class="trade-cols">
<section><h2>OPEN Paper Exec Positions</h2><div id="arb-conservative-open"></div></section>
<section><h2>Recent Paper Exec Trades</h2><div id="arb-conservative-recent"></div></section>
</div>
<section><h2>Recent Paper Exec Attempts</h2><div id="arb-conservative-attempts"></div></section>
</div>
<div class="tab-panel" id="tab-arb-lab">
<div class="grid" id="arb-lab-summary"></div>
<section><h2>Live Readiness</h2><div id="arb-lab-readiness"></div></section>
<section><h2>Execution Risk Read</h2><div id="arb-lab-read"></div></section>
<div class="runner" id="arb-lab-runner"></div>
<section><h2>Lab YES+NO Curve</h2><div class="chart-wrap"><div class="legend"><span><i class="swatch yesno"></i>YES+NO</span></div><canvas id="arb-lab-curve" width="1200" height="260"></canvas></div></section>
<section><h2>Live-Like Risk Metrics</h2><div class="grid" id="arb-lab-metrics"></div><div id="arb-lab-reasons"></div></section>
<div class="trade-cols">
<section><h2>OPEN Lab Paper Positions</h2><div id="arb-lab-open"></div></section>
<section><h2>Recent Lab Paper Trades</h2><div id="arb-lab-recent"></div></section>
</div>
<section><h2>Recent Lab Attempts</h2><div id="arb-lab-attempts"></div></section>
</div>
<div class="tab-panel" id="tab-logs">
<section><h2>Direction Runner Log</h2><div class="runner-log" id="direction-log"></div></section>
<section><h2>Arb Scanner Log</h2><div class="runner-log" id="arb-exec-log"></div></section>
<section><h2>Arb Paper Exec Log</h2><div class="runner-log" id="arb-conservative-log"></div></section>
<section><h2>Arb Execution Lab Log</h2><div class="runner-log" id="arb-lab-log"></div></section>
<section><h2>Legacy Arbitrage Scanner Log</h2><div class="runner-log" id="arb-log"></div></section>
<details class="diagnostics"><summary>Diagnostics: API / Execution Errors</summary><div class="content" id="errors"></div></details>
</div>
</main>
<script>
const fmt = (v, digits=2) => typeof v === 'number' ? v.toFixed(digits) : (v ?? '');
const pct = v => `${fmt((v || 0) * 100, 2)}%`;
const money = v => `$${fmt(v || 0, 2)}`;
const pnl = v => `<span class="${(v || 0) >= 0 ? 'good' : 'bad'}">${money(v)}</span>`;
const status = v => `<span class="status ${v === 'WON' ? 'win' : (v === 'LOST' ? 'loss' : 'open')}">${v || ''}</span>`;
const time = v => v ? new Date(v).toLocaleString() : 'n/a';
const shortTime = v => v ? new Date(v).toLocaleString([], { month: 'numeric', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : 'n/a';
const ageFromTs = v => {
const t = v ? Date.parse(v) : NaN;
if (!Number.isFinite(t)) return 'n/a';
return `${Math.max(0, Math.round((Date.now() - t) / 1000))}s`;
};
const market = (v, row) => row.market_url ? `<a class="market-link" href="${row.market_url}" target="_blank" rel="noopener noreferrer">${v}</a>` : (v || '');
const reason = v => {
const descriptions = {
duplicate_open_market: 'Same market already has an OPEN position',
no_token_id: 'No CLOB token id for this side',
orderbook_fetch_failed: 'Could not fetch CLOB order book',
no_asks: 'No sell-side liquidity available',
below_min_order_size: 'Budget cannot meet Polymarket minimum order size',
budget_too_small: 'Budget too small to buy any shares',
fee_makes_edge_negative: 'Fee-adjusted price removes the model edge',
spread_or_price_unacceptable: 'Ask/spread was not acceptable',
unknown_execution_skip: 'Skipped for an uncategorized execution reason'
};
const key = (v || '').split(':').pop();
return key ? `<b>${key}</b><div class="muted">${descriptions[key] || ''}</div>` : '';
};
function table(rows, cols) {
if (!rows.length) return '<div class="muted">No rows</div>';
return `<table><thead><tr>${cols.map(c => `<th>${c[0]}</th>`).join('')}</tr></thead><tbody>` +
rows.map(r => `<tr>${cols.map(c => `<td>${c[2] ? c[2](r[c[1]], r) : (r[c[1]] ?? '')}</td>`).join('')}</tr>`).join('') +
'</tbody></table>';
}
function setHtml(elementId, html) {
const el = document.getElementById(elementId);
if (el) el.innerHTML = html;
}
function drawSeries(canvasId, points, valueKey, options = {}) {
const canvas = document.getElementById(canvasId);
if (!canvas) return;
const ctx = canvas.getContext('2d');
ctx.clearRect(0,0,canvas.width,canvas.height);
ctx.strokeStyle = '#edf1f6'; ctx.lineWidth = 1;
for (let i = 0; i < 5; i++) {
const y = 25 + i * 48;
ctx.beginPath(); ctx.moveTo(64,y); ctx.lineTo(1148,y); ctx.stroke();
}
ctx.strokeStyle = '#d9e0ea'; ctx.beginPath(); ctx.moveTo(64,20); ctx.lineTo(64,225); ctx.lineTo(1148,225); ctx.lineTo(1148,20); ctx.stroke();
if (!points.length) return;
const allTimes = points.map(p => Date.parse(p.ts)).filter(Number.isFinite);
const minTime = Math.min(...allTimes), maxTime = Math.max(...allTimes);
const xFor = ts => {
const t = Date.parse(ts);
if (!Number.isFinite(t) || maxTime === minTime) return 64;
return 64 + ((t - minTime) / (maxTime - minTime)) * 1084;
};
const vals = points.map(p => p[valueKey]).filter(v => typeof v === 'number');
if (!vals.length) return;
const minBase = options.zeroBase === false ? Math.min(...vals) : Math.min(0, ...vals);
const maxBase = options.zeroBase === false ? Math.max(...vals) : Math.max(0, ...vals);
const padding = options.zeroBase === false ? Math.max(0.000001, (maxBase - minBase) * 0.08) : 0;
const min = minBase - padding, max = maxBase + padding;
const span = Math.max(options.minSpan || 1, max - min);
const coords = points.map((p, i) => ({
x: xFor(p.ts),
y: 225 - ((p[valueKey] - min) / span) * 200
}));
ctx.fillStyle = '#667085'; ctx.font = '11px system-ui';
for (let i = 0; i < 5; i++) {
const y = 225 - i * 50;
const value = min + (span * i / 4);
ctx.fillText(options.format ? options.format(value) : fmt(value, 2), 8, y + 4);
}
for (let i = 0; i < 5; i++) {
const x = 64 + i * (1084 / 4);
const t = new Date(minTime + (maxTime - minTime) * i / 4);
ctx.fillText(t.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }), x - 18, 246);
ctx.strokeStyle = '#edf1f6'; ctx.beginPath(); ctx.moveTo(x,225); ctx.lineTo(x,20); ctx.stroke();
}
if (coords.length) {
ctx.beginPath();
coords.forEach((p, i) => i === 0 ? ctx.moveTo(p.x, p.y) : ctx.lineTo(p.x, p.y));
ctx.lineTo(coords[coords.length - 1].x, 225); ctx.lineTo(coords[0].x, 225); ctx.closePath();
const fill = ctx.createLinearGradient(0, 20, 0, 225);
fill.addColorStop(0, options.fill || 'rgba(37,99,235,.18)');
fill.addColorStop(1, 'rgba(37,99,235,0)');
ctx.fillStyle = fill; ctx.fill();
ctx.strokeStyle = options.color || '#2563eb'; ctx.lineWidth = 2.5; ctx.beginPath();
coords.forEach((p, i) => i === 0 ? ctx.moveTo(p.x,p.y) : ctx.lineTo(p.x,p.y));
ctx.stroke();
const last = coords[coords.length - 1];
ctx.fillStyle = options.color || '#2563eb'; ctx.beginPath(); ctx.arc(last.x,last.y,4,0,Math.PI*2); ctx.fill();
}
ctx.fillStyle = '#172033'; ctx.font = '12px system-ui';
ctx.fillText(options.label || '', 8, 16);
}
function bindTabs() {
document.querySelectorAll('.tab').forEach(button => {
button.addEventListener('click', () => {
const tab = button.dataset.tab;
document.querySelectorAll('.tab').forEach(item => item.classList.toggle('active', item === button));
document.querySelectorAll('.tab-panel').forEach(panel => panel.classList.toggle('active', panel.id === `tab-${tab}`));
setTimeout(scrollLogsToBottom, 0);
});
});
}
function scrollLogsToBottom() {
document.querySelectorAll('.runner-log').forEach(log => {
log.scrollTop = log.scrollHeight;
});
}
function renderRunner(elementId, runner, subtitle, options = {}) {
const stale = runner.stale;
const ok = runner.running && !stale;
const label = runner.running ? (stale ? 'STALE' : 'RUNNING') : 'STOPPED';
const dot = ok ? 'good' : (runner.running ? 'warn' : '');
const details = [
runner.pid ? ['PID', runner.pid, ''] : null,
['Latest Scan', time(runner.latest_scan), runner.latest_scan || ''],
['Age', runner.latest_scan_age_sec == null ? 'n/a' : `${runner.latest_scan_age_sec}s`],
runner.expected_interval_sec ? ['Interval', `${runner.expected_interval_sec}s`, ''] : null,
runner.log_file ? ['Log', runner.log_file, ''] : null
].filter(Boolean);
const el = document.getElementById(elementId);
if (!el) return;
const logHtml = options.showLog === false ? '' : `<div class="runner-log" id="${elementId}-log">${(runner.log_tail || []).join('\n')}</div>`;
el.innerHTML =
`<div><div class="runner-state"><span class="dot ${dot}"></span>${label}</div><div class="muted">${subtitle}</div></div>` +
`<div><div class="runner-details">${details.map(d => `<div><div class="muted">${d[0]}</div><b title="${d[2] || ''}">${d[1]}</b></div>`).join('')}</div>` +
`${logHtml}</div>`;
const log = document.getElementById(`${elementId}-log`);
if (log) log.scrollTop = log.scrollHeight;
}
function renderLog(elementId, lines) {
const el = document.getElementById(elementId);
if (!el) return;
el.textContent = (lines || []).join('\n');
el.scrollTop = el.scrollHeight;
}
function renderArbPaperRead(elementId, exec) {
const settled = exec.paper_settled || 0;
const pnlValue = exec.paper_pnl_usd || 0;
const roiValue = exec.paper_roi || 0;
const fullHedge = exec.full_hedge_possible || 0;
const attempts = exec.total_attempts || 0;
const legRisk = exec.leg_risk || 0;
const fullRate = attempts ? fullHedge / attempts : 0;
let cls = 'warn';
let headline = 'Positive but still too small for live';
let detail = 'Arbitrage paper is the only currently positive stream, but it still needs more settled full-hedge trades before sizing or live execution.';
if (settled >= 50 && pnlValue > 0 && legRisk <= fullHedge) {
cls = 'good';
headline = 'Primary candidate: positive paper arb sample';
detail = 'Settled paper full-hedge trades are positive and the sample is large enough for a deeper execution-risk review.';
} else if (pnlValue <= 0) {
cls = 'bad';
headline = 'Not positive on settled paper trades';
detail = 'Do not promote this until settled paper PnL turns positive and the full-hedge sample grows.';
}
const rows = [
['Settled paper trades', settled],
['Paper PnL / ROI', `${money(pnlValue)} / ${pct(roiValue)}`],
['Paper win rate', pct(exec.paper_win_rate || 0)],
['Avg / worst trade', `${money(exec.paper_avg_pnl_usd || 0)} / ${money(exec.paper_worst_pnl_usd || 0)}`],
['Full hedge rate', `${fullHedge}/${attempts} (${pct(fullRate)})`],
['Leg-risk attempts', legRisk],
];
setHtml(elementId, `<div class="read-panel">
<div class="read-main ${cls}"><b>${headline}</b><div>${detail}</div></div>
<div class="read-list">${rows.map(([k, v]) => `<div class="read-row"><span class="muted">${k}</span><b>${v}</b></div>`).join('')}</div>
</div>`);
}
function renderArbOverview(data) {
const exec = data.arb_conservative_runner || {};
const items = [
['Paper Exec PnL', money(exec.paper_pnl_usd || 0)],
['Paper Exec ROI', pct(exec.paper_roi || 0)],
['Paper Settled', exec.paper_settled || 0],
['Paper OPEN', exec.paper_open || 0],
['Full Hedge', exec.full_hedge_possible || 0],
['Leg Risk', exec.leg_risk || 0],
];
renderArbPaperRead('overview-arb-read', exec);
setHtml('overview-arb-metrics', items.map(m => `<div class="metric"><span class="muted">${m[0]}</span><b>${m[1]}</b></div>`).join(''));
}
function renderArbCandidate(prefix, runner, curve) {
const candidate = runner.live_candidate || {};
const execMetrics = [
['Paper Arb PnL', money(runner.paper_pnl_usd)], ['Paper Arb ROI', pct(runner.paper_roi)], ['Paper Trades', runner.paper_total_trades],
['Paper Settled', runner.paper_settled], ['Paper OPEN', runner.paper_open], ['Attempts', runner.total_attempts],
['Full Hedge', runner.full_hedge_possible], ['Full Hedge Rate', pct(runner.full_hedge_rate)],
['Leg Risk', runner.leg_risk], ['Paper Win Rate', pct(runner.paper_win_rate)], ['Avg Paper PnL', money(runner.paper_avg_pnl_usd)],
['Worst Paper PnL', money(runner.paper_worst_pnl_usd)], ['Best YES+NO', fmt(runner.best_quote_yes_no_cost, 6)], ['Best Theo Full PnL', money(runner.best_full_net_pnl_usd)],
['Theo Full PnL', money(runner.total_full_net_pnl_usd)], ['Total Unwind Loss', money(runner.total_unwind_loss_usd)],
['Risk-Adjusted PnL', money(runner.risk_adjusted_pnl_usd)], ['Leg Risk / Hedge', fmt(runner.leg_risk_to_full_hedge, 3)],
['P95 Latency', `${runner.latency_p95_ms || 0}ms`], ['Max Latency', `${runner.latency_max_ms || 0}ms`],
['API Error Rate', pct(runner.api_error_rate || 0)], ['Missing Quotes', runner.missing_quote_count || 0]
];
const candidateMetrics = prefix === 'arb-lab' ? [
['Candidate Attempts', candidate.attempts || 0],
['Candidate Full Hedge', candidate.full_hedge_possible || 0],
['Candidate Leg Risk', candidate.leg_risk || 0],
['Candidate Risk PnL', money(candidate.risk_adjusted_pnl_usd || 0)],
['Candidate Leg / Hedge', fmt(candidate.leg_risk_to_full_hedge || 0, 3)],
['Candidate P95 Latency', `${candidate.latency_p95_ms || 0}ms`],
['Max YES+NO', fmt(candidate.max_yes_no_cost || 0, 2)],
['Max Quote Latency', `${candidate.max_quote_latency_ms || 0}ms`],
] : execMetrics.slice(0, 8);
setHtml(`${prefix}-summary`, candidateMetrics.map(m => `<div class="metric"><span class="muted">${m[0]}</span><b>${m[1]}</b></div>`).join(''));
if (prefix === 'arb-lab') renderLiveReadiness(`${prefix}-readiness`, runner.live_readiness);
renderArbPaperRead(`${prefix}-read`, runner);
setHtml(`${prefix}-metrics`, execMetrics.map(m => `<div class="metric"><span class="muted">${m[0]}</span><b>${m[1]}</b></div>`).join(''));
setHtml(`${prefix}-reasons`, `<div class="muted" style="margin:12px 0 6px">Why the two-leg execution simulator skipped or saw leg risk</div>` + table(runner.skip_reasons, [['Reason','reason'],['Count','count']]));
setHtml(`${prefix}-open`, table(runner.paper_open_positions, [['Opened','opened_at', shortTime],['Status','status'],['Cost','total_cost_usd', money],['Final YES+NO','final_yes_no_cost'],['Order','execution_order'],['Market','market_id', market]]));
setHtml(`${prefix}-recent`, table(runner.paper_recent, [['Opened','opened_at', shortTime],['Status','status'],['Cost','total_cost_usd', money],['Payout','payout_usd', money],['PnL','pnl_usd', pnl],['ROI','roi', pct],['Resolved','resolved_outcome'],['Market','market_id', market]]));
setHtml(`${prefix}-attempts`, table(runner.recent, [['Time','ts', shortTime],['Market','market_id', market],['Quote YES+NO','quote_yes_no_cost'],['Order','execution_order'],['Full Hedge','full_hedge_possible'],['Leg Risk','partial_fill'],['Full PnL','net_pnl_if_full_usd', pnl],['Unwind Loss','unwind_loss_usd', money],['Skip','skip_reason']]));
drawSeries(`${prefix}-curve`, curve, 'quote_yes_no_cost', { label: 'YES+NO', format: v => fmt(v, 4), color: '#b7791f', fill: 'rgba(183,121,31,.14)', zeroBase: false, minSpan: 0.0001 });
}
function renderLiveReadiness(elementId, readiness) {
if (!readiness) {
setHtml(elementId, '<div class="muted">No readiness data yet</div>');
return;
}
const ready = readiness.ready;
const gates = readiness.gates || [];
const rows = gates.map(gate => `<tr>
<td><span class="status ${gate.passed ? 'win' : 'loss'}">${gate.passed ? 'PASS' : 'FAIL'}</span></td>
<td>${gate.name || ''}</td>
<td><b>${gate.value ?? ''}</b></td>
<td>${gate.threshold || ''}</td>
</tr>`).join('');
setHtml(elementId, `<div class="read-panel">
<div class="read-main ${ready ? 'good' : 'bad'}"><b>${readiness.status || 'UNKNOWN'}</b><div>${readiness.summary || ''}</div></div>
<table><thead><tr><th>Status</th><th>Gate</th><th>Current</th><th>Required</th></tr></thead><tbody>${rows}</tbody></table>
</div>`);
}
function compactRunnerStatus(runner) {
const stale = runner && runner.stale;
const running = runner && runner.running;
const cls = running && !stale ? 'good' : stale ? 'warn' : '';
const label = running ? (stale ? 'STALE' : 'RUNNING') : 'STOPPED';
return `<span class="${cls}">${label}</span>`;
}
function runnerAge(runner) {
return runner && runner.latest_scan_age_sec != null ? `${runner.latest_scan_age_sec}s` : 'n/a';
}
function renderRunnerComparison(rows) {
const body = (rows || []).map(row => {
const dot = row.running && !row.stale ? 'good' : (row.running ? 'warn' : '');
const stateClass = row.running && !row.stale ? 'good' : (row.running ? '' : 'bad');
return `<tr>
<td><div class="runner-name"><span class="dot ${dot}"></span>${row.name || ''}</div><div class="runner-sub">${row.subtitle || ''}</div></td>
<td><b class="${stateClass}">${row.status || ''}</b></td>
<td><b>${pnl(row.pnl || 0)}</b></td>
<td>${pct(row.roi || 0)}</td>
<td>${row.trades || 0}</td>
<td>${row.open || 0}</td>
<td>${row.age || 'n/a'}</td>
<td>${row.pid || 'n/a'}</td>
<td>${row.read || ''}</td>
</tr>`;
}).join('');
setHtml('overview-runner-board', body
? `<table class="runner-table"><thead><tr><th>Runner</th><th>Status</th><th>PnL</th><th>ROI</th><th>Sample</th><th>OPEN / Risk</th><th>Latest</th><th>PID</th><th>Read</th></tr></thead><tbody>${body}</tbody></table>`
: '<div class="muted">No runner rows yet</div>'
);
}
function runnerTableHtml(rows) {
const body = (rows || []).map(row => {
const dot = row.running && !row.stale ? 'good' : (row.running ? 'warn' : '');
const stateClass = row.running && !row.stale ? 'good' : (row.running ? '' : 'bad');
return `<tr>
<td><div class="runner-name"><span class="dot ${dot}"></span>${row.name || ''}</div><div class="runner-sub">${row.subtitle || ''}</div></td>
<td><b class="${stateClass}">${row.status || ''}</b></td>
<td><b>${pnl(row.pnl || 0)}</b></td>
<td>${pct(row.roi || 0)}</td>
<td>${row.trades || 0}</td>
<td>${row.open || 0}</td>
<td>${row.age || 'n/a'}</td>
<td>${row.read || ''}</td>
</tr>`;
}).join('');
return body
? `<table class="runner-table"><thead><tr><th>Runner</th><th>Status</th><th>PnL</th><th>ROI</th><th>Sample</th><th>OPEN / Risk</th><th>Latest</th><th>Read</th></tr></thead><tbody>${body}</tbody></table>`
: '<div class="muted">No runner rows yet</div>';
}
function renderScanSchedule(rows) {
setHtml('scan-schedule', table(rows || [], [
['Runner','runner'],
['Purpose','purpose'],
['Interval','interval_label'],
['Notes','notes']
]));
}
function renderArbExecutionTab(data) {
const rows = (data.runner_comparison || []).filter(row => (row.name || '').startsWith('Arb'));
setHtml('arb-execution-board', runnerTableHtml(rows));
renderUniverseCoverage(data.arb_universe_coverage || []);
renderLiveReadiness('arb-execution-readiness', data.micro_live_readiness);
const exec = data.arb_execution_lab_runner || {};
const paper = data.arb_conservative_runner || {};
const reasons = [
['Lab skip reasons', exec.skip_reasons || []],
['Paper skip reasons', paper.skip_reasons || []]
].map(([title, rows]) => {
const body = (rows || []).slice(0, 8).map(row => `<tr><td>${row.reason || ''}</td><td>${row.count || 0}</td></tr>`).join('');
return `<div><h2>${title}</h2>${body ? `<table><thead><tr><th>Reason</th><th>Count</th></tr></thead><tbody>${body}</tbody></table>` : '<div class="muted">No rows</div>'}</div>`;
}).join('');
setHtml('arb-execution-reasons', `<div class="cols">${reasons}</div>`);
const attempts = (exec.recent || []).slice(0, 12);
setHtml('arb-execution-attempts', table(attempts, [
['Time','ts', shortTime],
['Universe','universe'],
['YES+NO','quote_yes_no_cost'],
['Full Hedge','full_hedge_possible'],
['Reason','skip_reason'],
['Market','market_id', market]
]));
}
function renderUniverseCoverage(rows) {
if (!rows || !rows.length) {
setHtml('arb-universe-coverage', '<div class="muted">No universe coverage data yet</div>');
return;
}
const body = rows.map(row => {
const empty = !row.attempts;
return `<tr class="${empty ? 'empty-row' : ''}">
<td>${row.runner || ''}</td>
<td>${row.universe || ''}</td>
<td>${row.attempts || 0}</td>
<td>${row.full_hedge || 0}</td>
<td>${row.leg_risk || 0}</td>
<td>${row.full_hedge_rate != null ? pct(row.full_hedge_rate) : '0.00%'}</td>
<td>${row.best_yes_no_cost ? fmt(row.best_yes_no_cost, 6) : 'n/a'}</td>
<td>${row.latest_yes_no_cost ? fmt(row.latest_yes_no_cost, 6) : 'n/a'}</td>
<td>${row.top_skip_reason || ''}</td>
<td>${row.latest ? shortTime(row.latest) : 'n/a'}</td>
</tr>`;
}).join('');
setHtml('arb-universe-coverage', `<table class="coverage-table"><thead><tr><th>Runner</th><th>Universe</th><th>Attempts</th><th>Full Hedge</th><th>Leg Risk</th><th>Full Hedge Rate</th><th>Best YES+NO</th><th>Latest YES+NO</th><th>Top Skip</th><th>Latest</th></tr></thead><tbody>${body}</tbody></table>`);
}
function renderDiagnosticsTab(data) {
setHtml('diagnostics-runner-board', runnerTableHtml(data.runner_comparison || []));
const logs = [
['Arb Scanner', data.arb_exec_runner && data.arb_exec_runner.log_tail],
['Arb Paper Exec', data.arb_conservative_runner && data.arb_conservative_runner.log_tail],
['Arb Execution Lab', data.arb_execution_lab_runner && data.arb_execution_lab_runner.log_tail]
].map(([title, lines]) => `<section><h2>${title}</h2><div class="runner-log">${(lines || []).join('\n')}</div></section>`).join('');
setHtml('diagnostics-logs', logs);
setHtml('diagnostics-errors', table(data.errors || [], [['Time','ts', shortTime],['Errors','errors'],['Execution','execution_errors']]));
}
function renderArchiveTab(data) {
const directionRows = (data.runner_comparison || []).filter(row => !(row.name || '').startsWith('Arb'));
setHtml('archive-direction-board', runnerTableHtml(directionRows));
setHtml('archive-strategy-decisions', decisionTableHtml(data.strategy_decisions || []));
const validation = (data.strategy_validation || []).slice(0, 6);
const body = validation.map(row => `<tr>
<td><b>${row.name || ''}</b><div class="muted">${row.description || ''}</div></td>
<td>${row.verdict || ''}</td>
<td>${row.trades || 0}</td>
<td>${row.positive_folds || 0}/${row.folds || 0}</td>
<td>${pnl(row.pnl || 0)}</td>
<td>${row.warning || ''}</td>
</tr>`).join('');
setHtml('archive-research', body
? `<table><thead><tr><th>Strategy</th><th>Verdict</th><th>Trades</th><th>Good Folds</th><th>PnL</th><th>Warning</th></tr></thead><tbody>${body}</tbody></table>`
: '<div class="muted">No research rows yet</div>');
}
function overviewRunnerRow(row) {
const dot = row.running && !row.stale ? 'good' : (row.running ? 'warn' : '');
const statusLabel = row.running ? (row.stale ? 'STALE' : 'RUNNING') : 'STOPPED';
return `<div class="runner-row">
<div class="runner-row-main">
<div class="runner-row-title"><span class="dot ${dot}"></span>${row.title}</div>
<div class="runner-row-sub">${row.subtitle}</div>
</div>
<div class="runner-cell primary"><span>Status</span><b class="${row.running && !row.stale ? 'good' : row.stale ? '' : 'bad'}">${statusLabel}</b></div>
<div class="runner-cell primary"><span>PnL</span><b>${row.pnl}</b></div>
<div class="runner-cell"><span>ROI</span><b>${row.roi}</b></div>
<div class="runner-cell"><span>${row.activityLabel}</span><b>${row.activity}</b></div>
<div class="runner-cell"><span>OPEN / Risk</span><b>${row.open}</b></div>
<div class="runner-cell"><span>Latest</span><b>${row.age}</b></div>
<div class="runner-cell note"><span>Read</span><b>${row.note}</b></div>
</div>`;
}
function renderDirectionCompare(data) {
const rows = [
['Base', 'MIN_PROB 0.65', data, data.runner],
['High-Prob', 'MIN_PROB 0.90', data.high_prob, data.high_prob.runner],
['Mid-Vol High-Prob', 'MIN_PROB 0.90 + mid vol', data.midvol_highprob, data.midvol_highprob.runner],
['Near-Expiry', '30-90s mispricing', data.near_expiry, data.near_expiry.runner]
];
const html = rows.map(([title, sub, stats, runner]) => {
const items = [
['Status', compactRunnerStatus(runner)],
['Trades', stats.total_trades || 0],
['OPEN', stats.open_count || 0],
['PnL', money(stats.pnl || 0)],
['ROI', pct(stats.roi || 0)],
['Win Rate', pct(stats.win_rate || 0)],
['Scans', stats.total_scans || 0],
['Age', runner && runner.latest_scan_age_sec != null ? `${runner.latest_scan_age_sec}s` : 'n/a']
];
return `<div class="compare-card"><div class="compare-head"><div><div class="compare-title">${title}</div><div class="compare-sub">${sub}</div></div><div class="muted">${runner && runner.pid ? `PID ${runner.pid}` : 'PID n/a'}</div></div><div class="compare-stats">${items.map(([k,v]) => `<div class="compare-stat"><span>${k}</span><b>${v}</b></div>`).join('')}</div></div>`;
}).join('');
setHtml('overview-direction-compare', html);
}
function renderOverviewCore(data) {
renderLiveDecision(data.live_decision || {}, data);
renderResearchLoop(data.research_orchestrator || {});
renderRunnerComparison(data.runner_comparison || []);
renderCurrentEra(data.current_era || {});
}
function renderLiveDecision(decision, data) {
const readiness = data.micro_live_readiness || {};
const status = decision.status || readiness.status || 'NOT_READY';
const tone = decision.tone || (status === 'READY_FOR_MICRO_LIVE' ? 'good' : status === 'WATCH' ? 'warn' : 'bad');
const metrics = decision.metrics || [
['Full Hedge', readiness.execution_lab ? readiness.execution_lab.full_hedge || 0 : 0],
['Paper PnL', readiness.paper_runner ? pnl(readiness.paper_runner.pnl || 0) : '$0.00'],
['Leg Risk', readiness.execution_lab ? readiness.execution_lab.leg_risk || 0 : 0],
['Unwind Loss', readiness.execution_lab ? money(readiness.execution_lab.unwind_loss || 0) : '$0.00']
];
const reasons = decision.reasons || [{label:'Blocked', text: readiness.summary || 'No readiness data yet.'}];
const actions = decision.next_actions || ['Keep collecting paper execution data; do not enable real-money orders.'];
setHtml('live-decision', `
<div class="live-board">
<div class="live-hero">
<div class="live-verdict ${tone}">
<div class="live-label">Live Decision</div>
<div class="live-title">${decision.title || status}</div>
<div class="live-detail">${decision.detail || readiness.summary || ''}</div>
<div class="live-reasons">
${reasons.map(item => `<div class="live-reason"><b>${item.label || ''}</b><span>${item.text || ''}</span></div>`).join('')}
</div>
</div>
<div class="live-metrics">
${metrics.map(item => `<div class="live-metric"><span>${item[0]}</span><b>${item[1]}</b></div>`).join('')}
</div>
</div>
<div class="next-panel">
<h2>Next 24h Decision</h2>
<ul class="next-list">${actions.map(item => `<li>${item}</li>`).join('')}</ul>
</div>
</div>
`);
}
function renderResearchLoop(loop) {
if (!loop || !loop.generated_at) {
setHtml('research-loop', '');
return;
}
const decision = loop.decision || {};
const status = decision.status || 'UNKNOWN';
const positive = loop.positive_counts || {};
const candidates = loop.candidates || [];
const watchlist = loop.watchlist || [];
const nearMiss = loop.near_miss || [];
const runnerAllowed = decision.runner_control_allowed === true;
const cls = runnerAllowed ? 'good' : (candidates.length ? 'warn' : 'bad');
const dot = runnerAllowed ? 'good' : (candidates.length || watchlist.length || nearMiss.length ? 'warn' : '');
const nearText = nearMiss.length ? nearMiss.slice(0, 3).join(', ') + (nearMiss.length > 3 ? ` +${nearMiss.length - 3}` : '') : 'none';
setHtml('research-loop', `
<div class="research-loop ${cls}">
<div>
<div class="research-loop-title"><span class="dot ${dot}"></span>Research Loop: ${status}</div>
<div class="research-loop-sub">Last run ${time(loop.generated_at)} · ${decision.summary || ''}</div>
</div>
<div class="research-loop-grid">
<div><span>Positive</span><b>3w ${positive.three_way || 0} / nested ${positive.nested || 0} / basket ${positive.basket || 0}</b></div>
<div><span>Candidate</span><b>${candidates.length ? candidates.join(', ') : 'none'}</b></div>
<div><span>Watch / Near-miss</span><b>${watchlist.length ? watchlist.join(', ') : 'none'} / ${nearText}</b></div>
<div><span>Runner / Live</span><b>${runnerAllowed ? 'allowed' : 'blocked'} / ${decision.live_allowed ? 'allowed' : 'blocked'}</b></div>
</div>
</div>
`);
}
function renderAutomation(data) {
const auto = data.automation || {};
const flow = auto.pipeline || [];
const toneFor = status => {
const normalized = String(status || '').toUpperCase();
if (['OK', 'RUNNING', 'READY'].includes(normalized)) return 'good';
if (['WATCH', 'WAITING', 'QUEUED', 'OBSERVE'].includes(normalized)) return 'warn';
if (['BLOCKED', 'STOPPED', 'ERROR'].includes(normalized)) return 'bad';
return 'idle';
};
setHtml('automation-flow', `
<div class="automation-flow">