-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatent_liquid.html
More file actions
854 lines (807 loc) · 39.9 KB
/
latent_liquid.html
File metadata and controls
854 lines (807 loc) · 39.9 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BBG> LATENT LIQUIDITY: SYSTEMIC RISK MONITOR</title>
<script src="https://cdn.plot.ly/plotly-2.27.0.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500&display=swap" rel="stylesheet">
<style>
:root {
--bg: #000000;
--surface-1: #0a0a0a;
--surface-2: #111111;
--border: rgba(0,255,65,0.10);
--border-hi: rgba(0,255,65,0.28);
--text: #e8e8e8;
--muted: #5a8a5a;
--dim: #2a4a2a;
--accent: #00ff41;
--accent2: #ff6600;
--accent3: #00d4ff;
--accent4: #ffcc00;
--amber: #ff9900;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
font-family: 'DM Sans', sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
padding: 24px 20px 60px;
overflow-x: hidden;
}
body::before {
content: '';
position: fixed; inset: 0; z-index: -1;
background-image:
linear-gradient(rgba(0,255,65,0.05) 1px, transparent 1px),
linear-gradient(90deg, rgba(0,255,65,0.05) 1px, transparent 1px);
background-size: 48px 48px;
pointer-events: none;
}
.page { max-width: 1200px; margin: 0 auto; }
/* HEADER */
header {
position: relative;
border: 1px solid var(--border-hi);
border-radius: 3px;
padding: 32px 36px 28px;
margin-bottom: 20px;
background: linear-gradient(135deg, rgba(0,8,0,0.99) 0%, rgba(0,4,0,1.0) 100%);
overflow: hidden;
}
header::after {
content: '';
position: absolute; top: -60px; right: -80px;
width: 340px; height: 340px;
background: radial-gradient(circle, rgba(0,255,65,0.06) 0%, transparent 70%);
pointer-events: none;
}
.header-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.header-left { flex: 1; min-width: 280px; }
.eyebrow {
font-family: 'DM Mono', monospace;
font-size: 0.72rem;
letter-spacing: 0.18em;
color: var(--accent);
text-transform: uppercase;
margin-bottom: 10px;
display: flex; align-items: center; gap: 8px;
}
.eyebrow::before {
content: ''; display: inline-block;
width: 18px; height: 2px; background: var(--accent);
}
h1 {
font-family: 'IBM Plex Mono', monospace;
font-size: 2.2rem; font-weight: 800;
line-height: 1.15; letter-spacing: 0.03em;
color: #fff; margin-bottom: 12px;
}
.tagline { font-size: 0.97rem; color: var(--muted); line-height: 1.65; max-width: 580px; }
.header-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.badge {
display: inline-flex; align-items: center; gap: 5px;
padding: 5px 11px; border-radius: 2px;
font-family: 'DM Mono', monospace; font-size: 0.72rem;
letter-spacing: 0.06em; border: 1px solid;
}
.badge-blue { color: var(--accent); border-color: rgba(0,255,65,0.35); background: rgba(0,255,65,0.07); }
.badge-green { color: var(--accent3); border-color: rgba(0,212,255,0.35); background: rgba(0,212,255,0.07); }
.badge-purple { color: var(--accent4); border-color: rgba(255,204,0,0.35); background: rgba(255,204,0,0.07); }
.badge-orange { color: var(--accent2); border-color: rgba(255,102,0,0.35); background: rgba(255,102,0,0.07); }
.badge-amber { color: var(--amber); border-color: rgba(255,153,0,0.35); background: rgba(255,153,0,0.07); }
.header-actions {
display: flex; gap: 10px; flex-direction: column;
align-items: flex-end; flex-shrink: 0;
}
.btn {
display: inline-flex; align-items: center; gap: 7px;
padding: 10px 18px; border-radius: 3px;
border: 1px solid var(--border-hi);
text-decoration: none; color: var(--text);
background: rgba(255,255,255,0.04);
font-family: 'DM Sans', sans-serif; font-weight: 500; font-size: 0.9rem;
cursor: pointer; transition: all .18s ease; white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.08); border-color: var(--accent); color: #fff; }
.btn.primary {
background: linear-gradient(135deg, #007a1e 0%, var(--accent) 100%);
color: #04080f; border: none; font-weight: 700;
}
.btn.primary:hover { opacity: 0.88; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,255,65,0.35); }
/* METRICS BANNER */
.metrics-banner {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 1px;
background: var(--border);
border: 1px solid var(--border);
border-radius: 3px;
overflow: hidden;
margin-bottom: 20px;
}
@media (max-width: 900px) { .metrics-banner { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 500px) { .metrics-banner { grid-template-columns: repeat(2, 1fr); } }
.metric-cell {
background: var(--surface-1);
padding: 16px 18px;
display: flex; flex-direction: column; gap: 5px;
position: relative; overflow: hidden;
}
.metric-cell::before {
content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.metric-cell:nth-child(1)::before { background: var(--accent2); }
.metric-cell:nth-child(2)::before { background: var(--accent); }
.metric-cell:nth-child(3)::before { background: var(--accent3); }
.metric-cell:nth-child(4)::before { background: var(--accent4); }
.metric-cell:nth-child(5)::before { background: var(--amber); }
.metric-label {
font-family: 'DM Mono', monospace; font-size: 0.62rem;
letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.metric-value {
font-family: 'IBM Plex Mono', monospace; font-size: 1.55rem;
font-weight: 700; letter-spacing: 0.03em; line-height: 1;
}
.metric-value.red { color: var(--accent2); }
.metric-value.blue { color: var(--accent); }
.metric-value.green { color: var(--accent3); }
.metric-value.purple { color: var(--accent4); }
.metric-value.amber { color: var(--amber); }
.metric-sub { font-size: 0.72rem; color: var(--dim); font-family: 'DM Mono', monospace; }
/* COMPARISON STRIP */
.compare-strip {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-bottom: 20px;
}
@media (max-width: 600px) { .compare-strip { grid-template-columns: 1fr; } }
.compare-card {
background: var(--surface-1);
border: 1px solid var(--border);
border-radius: 3px;
padding: 20px 22px;
position: relative; overflow: hidden;
}
.compare-card.dpf { border-top: 2px solid var(--accent); }
.compare-card.bpf { border-top: 2px solid var(--amber); }
.compare-card-title {
font-family: 'DM Mono', monospace; font-size: 0.7rem;
letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 12px;
}
.compare-card.dpf .compare-card-title { color: var(--accent); }
.compare-card.bpf .compare-card-title { color: var(--amber); }
.compare-metrics { display: flex; flex-direction: column; gap: 8px; }
.compare-row { display: flex; justify-content: space-between; align-items: center; }
.compare-key { font-size: 0.82rem; color: var(--muted); }
.compare-val {
font-family: 'DM Mono', monospace; font-size: 0.88rem;
font-weight: 500; color: var(--text);
}
.compare-val.win { color: var(--accent3); font-weight: 700; }
/* PANEL */
.panel {
background: var(--surface-1);
border: 1px solid var(--border);
border-radius: 3px;
padding: 22px 24px;
margin-bottom: 16px;
transition: border-color .2s;
}
.panel:hover { border-color: var(--border-hi); }
.panel-header {
display: flex; justify-content: space-between; align-items: center;
margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
h2 {
font-family: 'IBM Plex Mono', monospace; font-size: 1.05rem; font-weight: 700;
letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px;
}
h2 .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
h2 .dot-red { background: var(--accent2); box-shadow: 0 0 6px var(--accent2); }
h2 .dot-blue { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
h2 .dot-purple { background: var(--accent4); box-shadow: 0 0 6px var(--accent4); }
h2 .dot-green { background: var(--accent3); box-shadow: 0 0 6px var(--accent3); }
h2 .dot-amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
/* FILTER TOGGLE */
.filter-toggle { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toggle-btn {
padding: 7px 14px; border-radius: 2px;
border: 1px solid; background: transparent;
font-family: 'DM Mono', monospace; font-size: 0.75rem;
cursor: pointer; transition: all .18s;
}
.toggle-btn.dpf { color: var(--accent); border-color: rgba(62,198,255,0.3); }
.toggle-btn.dpf.active,
.toggle-btn.dpf:hover { background: rgba(0,255,65,0.12); border-color: var(--accent); }
.toggle-btn.bpf { color: var(--amber); border-color: rgba(246,195,68,0.3); }
.toggle-btn.bpf.active,
.toggle-btn.bpf:hover { background: rgba(255,153,0,0.12); border-color: var(--amber); }
.toggle-btn.both { color: var(--accent3); border-color: rgba(92,245,178,0.3); }
.toggle-btn.both.active,
.toggle-btn.both:hover { background: rgba(0,212,255,0.10); border-color: var(--accent3); }
/* ERA BUTTONS */
.era-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.era-btn {
display: inline-flex; align-items: center; gap: 6px;
padding: 8px 14px; border-radius: 2px; border: 1px solid;
background: transparent; font-family: 'DM Mono', monospace;
font-size: 0.75rem; cursor: pointer; transition: all .18s ease;
}
.era-btn::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.era-btn:hover { transform: translateY(-1px); }
.era-btn.crisis { color: var(--accent2); border-color: rgba(255,102,0,0.35); }
.era-btn.crisis::before { background: var(--accent2); box-shadow: 0 0 5px var(--accent2); }
.era-btn.crisis:hover { background: rgba(255,102,0,0.1); border-color: var(--accent2); }
.era-btn.brexit { color: var(--amber); border-color: rgba(255,153,0,0.35); }
.era-btn.brexit::before { background: var(--amber); box-shadow: 0 0 5px var(--amber); }
.era-btn.brexit:hover { background: rgba(255,153,0,0.1); border-color: var(--amber); }
.era-btn.covid { color: var(--accent3); border-color: rgba(0,212,255,0.35); }
.era-btn.covid::before { background: var(--accent3); box-shadow: 0 0 5px var(--accent3); }
.era-btn.covid:hover { background: rgba(0,212,255,0.1); border-color: var(--accent3); }
.era-btn.svb { color: var(--accent4); border-color: rgba(255,204,0,0.35); }
.era-btn.svb::before { background: var(--accent4); box-shadow: 0 0 5px var(--accent4); }
.era-btn.svb:hover { background: rgba(255,204,0,0.1); border-color: var(--accent4); }
/* CONTROLS */
.controls-grid { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.input-group { display: flex; flex-direction: column; gap: 5px; }
.input-group label {
font-family: 'DM Mono', monospace; font-size: 0.68rem;
letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}
.input-group input[type="date"] {
padding: 9px 12px; border-radius: 2px;
border: 1px solid var(--border-hi); background: var(--surface-2);
color: var(--text); font-family: 'DM Mono', monospace; font-size: 0.88rem;
outline: none; transition: border-color .18s; color-scheme: dark;
}
.input-group input[type="date"]:focus { border-color: var(--accent); }
.summary-bar {
background: var(--surface-2); border: 1px solid var(--border);
border-radius: 2px; padding: 10px 14px;
font-family: 'DM Mono', monospace; font-size: 0.8rem;
color: var(--muted); line-height: 1.6;
}
.summary-bar span { color: var(--accent); }
/* PLOTS */
.plot { width: 100%; height: 340px; }
.loader {
display: flex; align-items: center; justify-content: center;
height: 340px; gap: 12px; color: var(--muted);
font-family: 'DM Mono', monospace; font-size: 0.85rem;
}
.spinner {
width: 20px; height: 20px;
border: 2px solid var(--border-hi); border-top-color: var(--accent);
border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* GALLERY */
.gallery-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 14px;
}
figure {
margin: 0; border: 1px solid var(--border); border-radius: 3px;
background: var(--surface-2); overflow: hidden;
cursor: zoom-in; transition: border-color .2s, transform .2s;
}
figure:hover { border-color: var(--border-hi); transform: translateY(-2px); }
figure img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
figure.gif-figure img { aspect-ratio: 4/3; object-fit: contain; background: #000000; }
figcaption {
padding: 10px 14px; color: var(--muted);
font-family: 'DM Mono', monospace; font-size: 0.75rem; line-height: 1.5;
}
figcaption strong { color: var(--text); }
figcaption code { color: var(--accent); }
/* TERMINAL */
.terminal { background: #000000; border: 1px solid rgba(0,255,65,0.20); border-radius: 2px; overflow: hidden; }
.terminal-bar {
display: flex; align-items: center; gap: 7px;
padding: 10px 14px; background: rgba(255,255,255,0.03);
border-bottom: 1px solid rgba(0,255,65,0.15);
}
.terminal-bar span { width: 10px; height: 10px; border-radius: 50%; }
.terminal-bar .r { background: #ff5f57; }
.terminal-bar .y { background: #febc2e; }
.terminal-bar .g { background: #28c840; }
.terminal-title { margin-left: 8px; font-family: 'DM Mono', monospace; font-size: 0.72rem; color: var(--dim); }
.terminal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.cmd { display: flex; align-items: flex-start; gap: 10px; font-family: 'DM Mono', monospace; font-size: 0.83rem; line-height: 1.5; }
.cmd .prompt { color: var(--accent3); user-select: none; flex-shrink: 0; }
.cmd .command { color: var(--text); }
.cmd .comment { color: var(--dim); }
.cmd .hl { color: var(--accent); }
/* MODAL */
#modal {
display: none; position: fixed; inset: 0;
background: rgba(0,0,0,0.96); z-index: 9999;
align-items: center; justify-content: center;
padding: 24px; backdrop-filter: blur(6px);
}
.modal-inner {
max-width: 1100px; width: 100%;
background: var(--surface-2); border: 1px solid var(--border-hi);
border-radius: 3px; padding: 14px; position: relative;
}
#modalClose {
position: absolute; top: 10px; right: 10px;
background: rgba(255,255,255,0.08); border: 1px solid var(--border-hi);
color: var(--text); padding: 6px 12px; border-radius: 2px;
cursor: pointer; font-family: 'DM Mono', monospace; font-size: 0.78rem;
z-index: 2; transition: background .15s;
}
#modalClose:hover { background: rgba(255,255,255,0.14); }
#modalImg { width: 100%; max-height: 82vh; border-radius: 2px; object-fit: contain; }
/* FOOTER */
footer {
margin-top: 24px; padding-top: 18px;
border-top: 1px solid var(--border);
display: flex; justify-content: space-between;
align-items: center; flex-wrap: wrap; gap: 10px;
}
.footer-note { font-family: 'DM Mono', monospace; font-size: 0.75rem; color: var(--dim); }
.footer-note a { color: var(--accent); text-decoration: none; }
.footer-note a:hover { text-decoration: underline; }
@keyframes fadeUp { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:none; } }
.page > * { animation: fadeUp .4s ease both; }
.page > *:nth-child(1) { animation-delay:.05s; }
.page > *:nth-child(2) { animation-delay:.10s; }
.page > *:nth-child(3) { animation-delay:.15s; }
.page > *:nth-child(4) { animation-delay:.20s; }
.page > *:nth-child(5) { animation-delay:.25s; }
.page > *:nth-child(6) { animation-delay:.30s; }
.page > *:nth-child(7) { animation-delay:.35s; }
.page > *:nth-child(8) { animation-delay:.40s; }
body::after {
content: '';
position: fixed; inset: 0; z-index: 9998;
background: repeating-linear-gradient(
0deg, transparent, transparent 3px,
rgba(0,0,0,0.07) 3px, rgba(0,0,0,0.07) 4px
);
pointer-events: none;
}
@media (max-width: 600px) { h1 { font-size: 1.6rem; } body { padding: 14px 12px 48px; } }
</style>
</head>
<body>
<div class="page">
<!-- HEADER -->
<header>
<div class="header-top">
<div class="header-left">
<div class="eyebrow">BBG> QUANTITATIVE RESEARCH · PORTFOLIO PROJECT</div>
<h1>Latent Liquidity &<br>Systemic Risk Dashboard</h1>
<p class="tagline">
Bayesian state-space model inferring latent market stress from daily microstructure data.
Two particle filter architectures — an adaptive Differentiable PF with Sinkhorn OT resampling
and a fixed-parameter Bootstrap PF — are compared across filtering quality and 30-day
early-warning performance.
</p>
<div class="header-badges">
<span class="badge badge-blue">DPF · Sinkhorn OT</span>
<span class="badge badge-amber">Bootstrap PF</span>
<span class="badge badge-purple">SVL + DRD Covariance</span>
<span class="badge badge-green">Crisis Early Warning</span>
<span class="badge badge-orange">9 Historical Episodes</span>
</div>
</div>
<div class="header-actions">
<a class="btn primary" href="https://github.com/meamresh/latent_liquidity_quant" target="_blank" rel="noreferrer">
<svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.3 3.44 9.8 8.21 11.39.6.11.82-.26.82-.58v-2.03c-3.34.73-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.09-.74.08-.73.08-.73 1.2.08 1.84 1.23 1.84 1.23 1.07 1.84 2.81 1.31 3.49 1 .11-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.12-.3-.54-1.52.12-3.18 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 3-.4c1.02.004 2.04.14 3 .4 2.28-1.55 3.29-1.23 3.29-1.23.66 1.66.24 2.88.12 3.18.77.84 1.24 1.91 1.24 3.22 0 4.61-2.81 5.63-5.48 5.92.43.37.81 1.1.81 2.22v3.29c0 .32.22.7.82.58C20.56 21.8 24 17.3 24 12c0-6.63-5.37-12-12-12z"/></svg>
View Repository
</a>
<a class="btn" href="results.html">DPF vs BPF Results →</a>
<a class="btn" href="theory-methods.html">Theory & Methods →</a>
<a class="btn primary" href="https://github.com/meamresh/latent_liquidity_quant/blob/main/paper/latent_liquidity_quant.pdf" target="_blank" rel="noreferrer">
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.3 3.44 9.8 8.21 11.39.6.11.82-.26.82-.58v-2.03c-3.34.73-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.09-.74.08-.73.08-.73 1.2.08 1.84 1.23 1.84 1.23 1.07 1.84 2.81 1.31 3.49 1 .11-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.12-.3-.54-1.52.12-3.18 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 3-.4c1.02.004 2.04.14 3 .4 2.28-1.55 3.29-1.23 3.29-1.23.66 1.66.24 2.88.12 3.18.77.84 1.24 1.91 1.24 3.22 0 4.61-2.81 5.63-5.48 5.92.43.37.81 1.1.81 2.22v3.29c0 .32.22.7.82.58C20.56 21.8 24 17.3 24 12c0-6.63-5.37-12-12-12z"/></svg>
Read Paper
</a>
</div>
</div>
</header>
<!-- METRICS BANNER -->
<div class="metrics-banner">
<div class="metric-cell">
<div class="metric-label">DPF Endo. Episode AUC</div>
<div class="metric-value red">0.567</div>
<div class="metric-sub">vs BPF 0.500 ▲</div>
</div>
<div class="metric-cell">
<div class="metric-label">DPF Daily ROC-AUC</div>
<div class="metric-value blue">0.682</div>
<div class="metric-sub">vs BPF 0.670 ▲</div>
</div>
<div class="metric-cell">
<div class="metric-label">DPF Crisis/Calm Ratio</div>
<div class="metric-value green">340×</div>
<div class="metric-sub">GFC 0.78 · calm 0.002</div>
</div>
<div class="metric-cell">
<div class="metric-label">Warning Lead Time</div>
<div class="metric-value purple">47–60d</div>
<div class="metric-sub">5 of 9 episodes detected</div>
</div>
<div class="metric-cell">
<div class="metric-label">Training Sample</div>
<div class="metric-value amber">4,526</div>
<div class="metric-sub">trading days · 2007–2026</div>
</div>
</div>
<!-- FILTER COMPARISON CARDS -->
<div class="compare-strip">
<div class="compare-card dpf">
<div class="compare-card-title">◉ DPF — Differentiable Particle Filter</div>
<div class="compare-metrics">
<div class="compare-row">
<span class="compare-key">Architecture</span>
<span class="compare-val">Sinkhorn OT resampling (ε=0.5)</span>
</div>
<div class="compare-row">
<span class="compare-key">Parameters</span>
<span class="compare-val">Online gradient (Adam, η=5e-4)</span>
</div>
<div class="compare-row">
<span class="compare-key">Particles</span>
<span class="compare-val">N = 500</span>
</div>
<div class="compare-row">
<span class="compare-key">Brier Score</span>
<span class="compare-val win">0.212 ✓</span>
</div>
<div class="compare-row">
<span class="compare-key">Endo. Episode AUC</span>
<span class="compare-val win">0.567 ✓</span>
</div>
<div class="compare-row">
<span class="compare-key">Signal-to-noise</span>
<span class="compare-val win">2.67 ✓</span>
</div>
</div>
</div>
<div class="compare-card bpf">
<div class="compare-card-title">◎ BPF — Bootstrap Particle Filter</div>
<div class="compare-metrics">
<div class="compare-row">
<span class="compare-key">Architecture</span>
<span class="compare-val">Multinomial resampling</span>
</div>
<div class="compare-row">
<span class="compare-key">Parameters</span>
<span class="compare-val">Fixed (hand-calibrated)</span>
</div>
<div class="compare-row">
<span class="compare-key">Particles</span>
<span class="compare-val">N = 1000</span>
</div>
<div class="compare-row">
<span class="compare-key">Posterior CI width</span>
<span class="compare-val win">0.219 ✓</span>
</div>
<div class="compare-row">
<span class="compare-key">Tail prob. AUC</span>
<span class="compare-val win">0.726 ✓</span>
</div>
<div class="compare-row">
<span class="compare-key">Mean lead time</span>
<span class="compare-val win">50.2d ✓</span>
</div>
</div>
</div>
</div>
<!-- INTERACTIVE CHARTS CONTROL -->
<div class="panel">
<div class="panel-header">
<h2><span class="dot dot-blue"></span>Interactive Time Window</h2>
<div style="font-family:'DM Mono',monospace;font-size:0.72rem;color:var(--dim);">Select an era or custom range</div>
</div>
<div class="filter-toggle" id="filterToggle">
<button class="toggle-btn dpf active" data-mode="dpf">DPF only</button>
<button class="toggle-btn bpf" data-mode="bpf">BPF only</button>
<button class="toggle-btn both" data-mode="both">Compare both</button>
</div>
<div class="era-buttons">
<button class="era-btn crisis" data-start="2007-06-01" data-end="2009-06-30">2008 GFC</button>
<button class="era-btn brexit" data-start="2015-08-01" data-end="2017-01-01">Eurozone / Brexit</button>
<button class="era-btn covid" data-start="2019-11-01" data-end="2021-01-01">COVID-19</button>
<button class="era-btn svb" data-start="2021-10-01" data-end="2023-06-01">Rate Shock / SVB</button>
</div>
<div class="controls-grid">
<div class="input-group">
<label>Start Date</label>
<input type="date" id="startDate">
</div>
<div class="input-group">
<label>End Date</label>
<input type="date" id="endDate">
</div>
<button class="btn primary" id="applyBtn">Apply Range</button>
<button class="btn" id="resetBtn">Full History</button>
</div>
<div class="summary-bar" id="summary">Loading data…</div>
</div>
<!-- CRISIS PROBABILITY PLOT -->
<div class="panel">
<div class="panel-header">
<h2><span class="dot dot-red"></span>60-day Forward Crisis Probability</h2>
<span style="font-family:'DM Mono',monospace;font-size:0.72rem;color:var(--dim);">Logistic early-warning layer · dashed = 0.50 threshold</span>
</div>
<div id="probPlot" class="plot">
<div class="loader"><div class="spinner"></div>Rendering…</div>
</div>
</div>
<!-- STRESS PLOT -->
<div class="panel">
<div class="panel-header">
<h2><span class="dot dot-blue"></span>Latent Liquidity Stress L<sub>t</sub> with 90% CI</h2>
<span style="font-family:'DM Mono',monospace;font-size:0.72rem;color:var(--dim);">Threshold L=2 · bar = tail prob P(L>2)</span>
</div>
<div id="stressPlot" class="plot">
<div class="loader"><div class="spinner"></div>Rendering…</div>
</div>
</div>
<!-- LATENT FACTORS PLOT -->
<div class="panel">
<div class="panel-header">
<h2><span class="dot dot-purple"></span>Latent Factors h<sub>t</sub> (log-vol) and z<sub>t</sub> (correlation driver)</h2>
<span style="font-family:'DM Mono',monospace;font-size:0.72rem;color:var(--dim);">DPF posterior means</span>
</div>
<div id="latentPlot" class="plot">
<div class="loader"><div class="spinner"></div>Rendering…</div>
</div>
</div>
<!-- GALLERY: KEY OUTPUTS -->
<div class="panel">
<div class="panel-header">
<h2><span class="dot dot-green"></span>Key Output Figures</h2>
<span style="font-family:'DM Mono',monospace;font-size:0.72rem;color:var(--dim);">Click to enlarge · see <a href="results.html" style="color:var(--accent);">results page</a> for full comparison</span>
</div>
<div class="gallery-grid">
<figure class="zoomable" data-src="assets/latent-liquidity/figure_5_performance_dashboard.png">
<img src="assets/latent-liquidity/figure_5_performance_dashboard.png" alt="Performance dashboard">
<figcaption><strong>Performance Dashboard</strong> — DPF vs BPF across all key metrics<br><code>figure_5_performance_dashboard.png</code><br>
<a href="https://github.com/meamresh/latent_liquidity_quant/tree/main/results/plots/comparison/figure_5_performance_dashboard.png" target="_blank">View High-Res Source</a>
</figcaption>
</figure>
<figure class="zoomable" data-src="assets/latent-liquidity/figure_6_crisis_type_breakdown.png">
<img src="assets/latent-liquidity/figure_6_crisis_type_breakdown.png" alt="Endogenous vs exogenous">
<figcaption><strong>Endogenous vs Exogenous Breakdown</strong> — why exogenous shocks produce no advance warning<br><code>figure_6_crisis_type_breakdown.png</code>
<a href="https://github.com/meamresh/latent_liquidity_quant/tree/main/results/plots/comparison/figure_6_crisis_type_breakdown.png" target="_blank">View High-Res Source</a>
</figcaption>
</figure>
<figure class="zoomable" data-src="assets/latent-liquidity/figure_1_stress_comparison.png">
<img src="assets/latent-liquidity/figure_1_stress_comparison.png" alt="L_t comparison">
<figcaption><strong>L<sub>t</sub> Stress Comparison</strong> — DPF vs BPF posterior with 90% CIs<br><code>figure_1_stress_comparison.png</code>
<a href="https://github.com/meamresh/latent_liquidity_quant/tree/main/results/plots/comparison/figure_1_stress_comparison.png" target="_blank">View High-Res Source</a>
</figcaption>
</figure>
<figure class="gif-figure zoomable" data-src="assets/latent-liquidity/gfc.gif">
<img src="assets/latent-liquidity/gfc.gif" alt="GFC animated comparison">
<figcaption><strong>GFC Animation (2007–2009)</strong> — dual-filter forecast cones evolving in real time<br><code>research/animate_comparison.py</code>
<a href="https://github.com/meamresh/latent_liquidity_quant/tree/main/results/plots/comparison/gfc.gif" target="_blank">View High-Res Source</a>
</figcaption>
</figure>
<figure class="gif-figure zoomable" data-src="assets/latent-liquidity/brexit.gif">
<img src="assets/latent-liquidity/brexit.gif" alt="Brexit animated comparison">
<figcaption><strong>Brexit Window Animation (2016)</strong> — captures early market microstructure dynamics<br><code>research/animate_comparison.py</code>
<a href="https://github.com/meamresh/latent_liquidity_quant/tree/main/results/plots/comparison/brexit.gif" target="_blank">View High-Res Source</a>
</figcaption>
</figure>
<figure class="gif-figure zoomable" data-src="assets/latent-liquidity/covid.gif">
<img src="assets/latent-liquidity/covid.gif" alt="COVID animated comparison">
<figcaption><strong>COVID Window Animation (2019–2021)</strong> — illustrates zero advance warning for exogenous shock<br><code>research/animate_comparison.py</code>
<a href="https://github.com/meamresh/latent_liquidity_quant/tree/main/results/plots/comparison/covid.gif" target="_blank">View High-Res Source</a>
</figcaption>
</figure>
</div>
</div>
<!-- REPRODUCE -->
<div class="panel">
<div class="panel-header">
<h2><span class="dot dot-green"></span>Reproduce Results</h2>
<a class="btn" href="results.html">Full results page →</a>
</div>
<div class="terminal">
<div class="terminal-bar">
<span class="r"></span><span class="y"></span><span class="g"></span>
<span class="terminal-title">bash:</span>
</div>
<div class="terminal-body">
<div class="cmd">
<span class="prompt">$</span>
<span><span class="command">pip install -r requirements.txt</span></span>
</div>
<div class="cmd">
<span class="prompt">$</span>
<span>
<span class="command">python main.py run</span>
<span class="comment"> # full pipeline: train → predict → calibrate → predict → bench</span>
</span>
</div>
<div class="cmd">
<span class="prompt">#</span>
<span><span class="comment">Or run individual steps:</span></span>
</div>
<div class="cmd">
<span class="prompt">$</span>
<span>
<span class="command">python main.py train</span>
<span class="comment"> # learn DPF parameters (rolling 120d windows)</span>
</span>
</div>
<div class="cmd">
<span class="prompt">$</span>
<span>
<span class="command">python main.py predict <span class="hl">--filter dpf</span></span>
<span class="comment"> # DPF filter + forward simulation</span>
</span>
</div>
<div class="cmd">
<span class="prompt">$</span>
<span>
<span class="command">python main.py calibrate <span class="hl">--filter dpf</span></span>
<span class="comment"> # fit logistic warning model</span>
</span>
</div>
<div class="cmd">
<span class="prompt">$</span>
<span>
<span class="command">python main.py bench</span>
<span class="comment"> # DPF vs BPF comparison + all figures</span>
</span>
</div>
<div class="cmd">
<span class="prompt">$</span>
<span>
<span class="command">python main.py animate <span class="hl">--start 2007-06-01 --end 2009-06-01</span></span>
<span class="comment"> # animated GIF</span>
</span>
</div>
</div>
</div>
</div>
<footer>
<div class="footer-note">
Data: <a href="https://github.com/meamresh/latent_liquidity_quant" target="_blank">github.com/meamresh/latent_liquidity_quant</a> ·
<code>results/dpf_crisis_res.npz</code> + <code>results/crisis_res.npz</code>
</div>
<div class="footer-note">
<a href="theory-methods.html">Theory →</a> ·
<a href="results.html">Results →</a>
</div>
</footer>
</div>
<!-- MODAL -->
<div id="modal">
<div class="modal-inner">
<button id="modalClose">✕ Close</button>
<img id="modalImg" src="" alt="">
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
const dpfUrl = 'assets/latent-liquidity/dpf_crisis_res.json';
const bpfUrl = 'assets/latent-liquidity/crisis_res.json';
let dpfRaw = null, bpfRaw = null;
let mode = 'dpf';
const layout = (extra={}) => ({
margin: { t:10, r:55, l:55, b:40 },
hovermode: 'x unified',
paper_bgcolor: 'rgba(0,0,0,0)',
plot_bgcolor: 'rgba(0,0,0,0)',
font: { family:"'DM Mono',monospace", color:'#5a8a5a', size:11 },
xaxis: { gridcolor:'rgba(0,255,65,0.06)', linecolor:'rgba(0,255,65,0.12)', tickcolor:'rgba(0,255,65,0.12)' },
yaxis: { gridcolor:'rgba(0,255,65,0.06)', linecolor:'rgba(0,255,65,0.12)', tickcolor:'rgba(0,255,65,0.12)' },
legend: { bgcolor:'rgba(0,0,0,0)', font:{ color:'#7ab87a' } },
hoverlabel: { bgcolor:'#0a0a0a', bordercolor:'rgba(0,255,65,0.3)', font:{ family:"'DM Mono',monospace", color:'#e8e8e8', size:11 } },
...extra
});
function slice(raw, s, e) {
const sm = s ? new Date(s).getTime() : -Infinity;
const em = e ? new Date(e).getTime() : Infinity;
const mask = raw.dates.map(d => { const t=new Date(d).getTime(); return t>=sm&&t<=em; });
const p = arr => arr.filter((_,i)=>mask[i]);
return { dates:p(raw.dates), crisis:p(raw.crisis_prob), L:p(raw.L_mean), L05:p(raw.L_q05), L95:p(raw.L_q95), tail:p(raw.P_L_gt_2), h:p(raw.h_mean), z:p(raw.z_mean) };
}
function plotAll(start, end) {
const dpf = dpfRaw ? slice(dpfRaw, start, end) : null;
const bpf = bpfRaw ? slice(bpfRaw, start, end) : null;
const d = mode==='bpf' ? bpf : dpf;
if (!d || !d.dates.length) return;
['probPlot','stressPlot','latentPlot'].forEach(id => { document.getElementById(id).innerHTML=''; });
// Summary
document.getElementById('summary').innerHTML =
`<span>Window:</span> ${d.dates[0]} → ${d.dates[d.dates.length-1]} · ` +
`<span>N:</span> ${d.dates.length} obs · ` +
`<span>Mode:</span> ${mode.toUpperCase()}`;
// Crisis prob
const probTraces = [];
if ((mode==='dpf'||mode==='both') && dpf) {
probTraces.push({ x:dpf.dates, y:dpf.crisis, type:'scatter', mode:'lines', fill:'tozeroy', fillcolor:'rgba(0,255,65,0.08)', line:{color:'#00ff41',width:2}, name:'DPF crisis prob', hovertemplate:'<b>%{x}</b><br>DPF: %{y:.3f}<extra></extra>' });
}
if ((mode==='bpf'||mode==='both') && bpf) {
probTraces.push({ x:bpf.dates, y:bpf.crisis, type:'scatter', mode:'lines', fill:'tozeroy', fillcolor:'rgba(255,153,0,0.06)', line:{color:'#ff9900',width:2,dash:mode==='both'?'dot':'solid'}, name:'BPF crisis prob', hovertemplate:'BPF: %{y:.3f}<extra></extra>' });
}
Plotly.newPlot('probPlot', probTraces, layout({ yaxis:{title:'Probability',range:[0,1.05]}, shapes:[{ type:'line', x0:d.dates[0], x1:d.dates[d.dates.length-1], y0:0.5, y1:0.5, line:{dash:'dot',color:'rgba(255,102,0,0.55)',width:1.5} }] }), {responsive:true});
// Stress
const stressTraces = [];
if ((mode==='dpf'||mode==='both') && dpf) {
stressTraces.push(
{ x:dpf.dates, y:dpf.L95, type:'scatter', mode:'lines', line:{color:'rgba(0,255,65,0)'}, showlegend:false, hoverinfo:'skip' },
{ x:dpf.dates, y:dpf.L05, type:'scatter', mode:'lines', fill:'tonexty', fillcolor:'rgba(0,255,65,0.10)', line:{color:'rgba(0,255,65,0)'}, showlegend:false, hoverinfo:'skip' },
{ x:dpf.dates, y:dpf.L, type:'scatter', mode:'lines', line:{color:'#00ff41',width:2}, name:'DPF L_t', hovertemplate:'<b>%{x}</b><br>L_t: %{y:.3f}<extra></extra>' }
);
}
if ((mode==='bpf'||mode==='both') && bpf) {
stressTraces.push(
{ x:bpf.dates, y:bpf.L, type:'scatter', mode:'lines', line:{color:'#ff9900',width:2,dash:mode==='both'?'dot':'solid'}, name:'BPF L_t', hovertemplate:'BPF L_t: %{y:.3f}<extra></extra>' }
);
}
if (d.tail) {
stressTraces.push({ x:d.dates, y:d.tail, type:'bar', marker:{color:'rgba(255,102,0,0.28)',line:{width:0}}, name:'P(L>2)', yaxis:'y2', hovertemplate:'P(L>2): %{y:.3f}<extra></extra>' });
}
Plotly.newPlot('stressPlot', stressTraces, layout({ yaxis:{title:'L_t'}, yaxis2:{title:'Tail prob',overlaying:'y',side:'right',range:[0,1.05],gridcolor:'rgba(0,0,0,0)'}, shapes:[{ type:'line', x0:d.dates[0], x1:d.dates[d.dates.length-1], y0:2, y1:2, line:{dash:'dot',color:'rgba(0,255,65,0.5)',width:1.5} }], bargap:0 }), {responsive:true});
// Latent (always DPF if available)
const src = dpf || bpf;
Plotly.newPlot('latentPlot', [
{ x:src.dates, y:src.h, type:'scatter', mode:'lines', line:{color:'#00d4ff',width:2}, name:'h_t (log-vol)', hovertemplate:'<b>%{x}</b><br>h: %{y:.3f}<extra></extra>' },
{ x:src.dates, y:src.z, type:'scatter', mode:'lines', line:{color:'#ffcc00',width:2}, name:'z_t (corr. driver)', hovertemplate:'z: %{y:.3f}<extra></extra>' }
], layout(), {responsive:true});
}
async function init() {
try {
const [r1, r2] = await Promise.all([
fetch(dpfUrl).then(r => r.ok ? r.json() : null).catch(()=>null),
fetch(bpfUrl).then(r => r.ok ? r.json() : null).catch(()=>null),
]);
dpfRaw = r1; bpfRaw = r2;
if (!dpfRaw && !bpfRaw) throw new Error('No data files found');
const si = document.getElementById('startDate');
const ei = document.getElementById('endDate');
const apply = () => plotAll(si.value, ei.value);
document.getElementById('resetBtn').onclick = () => { si.value=''; ei.value=''; apply(); };
document.getElementById('applyBtn').onclick = apply;
document.querySelectorAll('[data-start][data-end]').forEach(b => {
b.onclick = () => { si.value=b.dataset.start; ei.value=b.dataset.end; apply(); };
});
document.querySelectorAll('.toggle-btn').forEach(b => {
b.onclick = () => {
document.querySelectorAll('.toggle-btn').forEach(x=>x.classList.remove('active'));
b.classList.add('active');
mode = b.dataset.mode;
apply();
};
});
plotAll();
} catch(err) {
document.getElementById('summary').textContent = '⚠ Load data from JSON exports: ' + err.message;
['probPlot','stressPlot','latentPlot'].forEach(id => {
document.getElementById(id).innerHTML = `<div class="loader" style="color:#ff6600;flex-direction:column;gap:8px;"><span>Data not loaded</span><span style="font-size:0.75rem;color:var(--dim);">Export NPZ → JSON via scripts/export_json.py</span></div>`;
});
}
}
init();
// Gallery modal
document.querySelectorAll('.zoomable').forEach(f => {
f.onclick = () => {
document.getElementById('modalImg').src = f.dataset.src;
document.getElementById('modal').style.display = 'flex';
};
});
const hide = () => { document.getElementById('modal').style.display='none'; };
document.getElementById('modalClose').onclick = e => { e.stopPropagation(); hide(); };
document.getElementById('modal').addEventListener('click', e => { if(e.target.id==='modal') hide(); });
window.addEventListener('keydown', e => { if(e.key==='Escape') hide(); });
});
</script>
</body>
</html>