-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautotrader.html
More file actions
987 lines (948 loc) · 48.1 KB
/
autotrader.html
File metadata and controls
987 lines (948 loc) · 48.1 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
<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>AutoTrader - Dave Liu</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="AutoTrader - A fully autonomous stock prediction system running 1,800+ daily models across the S&P 500. Built by Dave Liu.">
<meta property="og:title" content="AutoTrader - Dave Liu">
<meta property="og:description" content="A fully autonomous stock prediction system running 1,800+ daily models across the S&P 500, built from scratch on two VMs.">
<meta property="og:type" content="website">
<meta property="og:image" content="https://daliu.github.io/images/og-card.png">
<meta property="og:url" content="https://daliu.github.io/autotrader.html">
<link rel="canonical" href="https://daliu.github.io/autotrader.html">
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<!-- Google Analytics (GA4) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-GR5Z815VXW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-GR5Z815VXW');
</script>
<link rel="stylesheet" href="Bootstrap%20Theme%20Company%20Page_files/bootstrap.css">
<link href="Bootstrap%20Theme%20Company%20Page_files/css_002.css" rel="stylesheet" type="text/css">
<link href="Bootstrap%20Theme%20Company%20Page_files/css.css" rel="stylesheet" type="text/css">
<script src="Bootstrap%20Theme%20Company%20Page_files/jquery.js"></script>
<script src="Bootstrap%20Theme%20Company%20Page_files/bootstrap.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
body {
font: 400 15px Lato, sans-serif;
line-height: 1.8;
color: #818181;
}
p { font-size: 16px; }
.margin { margin-bottom: 45px; }
.bg-1 { background-color: #1abc9c; color: #ffffff; }
.bg-2 { background-color: #474e5d; color: #ffffff; }
.bg-3 { background-color: #ffffff; color: #555555; }
.bg-4 { background-color: #2f2f2f; color: #fff; }
h2 {
font-size: 24px;
text-transform: uppercase;
color: #303030;
font-weight: 600;
margin-bottom: 30px;
}
h3 {
font-size: 20px;
color: #303030;
font-weight: 600;
margin-bottom: 15px;
}
h4 {
font-size: 19px;
line-height: 1.375em;
color: #303030;
font-weight: 400;
margin-bottom: 15px;
}
.jumbotron {
background-color: #2c3e50;
color: #fff;
padding: 60px 25px;
font-family: Montserrat, sans-serif;
}
.jumbotron h1 { font-size: 36px; font-weight: 700; margin-bottom: 10px; }
.jumbotron p { font-size: 18px; color: #bdc3c7; }
.container-fluid { padding: 60px 50px; }
.bg-grey { background-color: #f6f6f6; }
.navbar {
margin-bottom: 0;
background-color: #2f2f2f;
z-index: 9999;
border: 0;
font-size: 12px !important;
line-height: 1.42857143 !important;
letter-spacing: 4px;
border-radius: 0;
font-family: Montserrat, sans-serif;
}
.navbar li a, .navbar .navbar-brand { color: #fff !important; }
.navbar-nav li a:hover, .navbar-nav li.active a {
color: #1abc9c !important;
background-color: #fff !important;
}
.navbar-default .navbar-toggle { border-color: transparent; color: #fff !important; }
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus { background-color: #3a3a3a !important; color: #1abc9c !important; }
.navbar-default .navbar-nav .dropdown-menu { background-color: #2f2f2f; border: 1px solid #444; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.navbar-default .navbar-nav .dropdown-menu > li > a { color: #fff !important; padding: 8px 20px; background-color: #2f2f2f !important; }
.navbar-default .navbar-nav .dropdown-menu > li > a:hover,
.navbar-default .navbar-nav .dropdown-menu > li > a:focus { color: #1abc9c !important; background-color: #3a3a3a !important; }
.navbar-default .navbar-nav .dropdown-menu .divider { background-color: #444; }
/* AutoTrader-specific styles */
.stat-card {
background: #fff;
border-left: 4px solid #1abc9c;
padding: 20px 25px;
margin-bottom: 20px;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.stat-card .stat-number {
font-size: 32px;
font-weight: 700;
color: #1abc9c;
display: block;
line-height: 1.2;
}
.stat-card .stat-label {
font-size: 14px;
color: #818181;
text-transform: uppercase;
letter-spacing: 1px;
}
.pipeline-section {
border: 1px solid #e0e0e0;
border-radius: 4px;
margin-bottom: 20px;
overflow: hidden;
}
.pipeline-header {
background-color: #474e5d;
color: #fff;
padding: 15px 20px;
cursor: pointer;
font-family: Montserrat, sans-serif;
font-size: 14px;
letter-spacing: 1px;
}
.pipeline-header:hover { background-color: #3a4049; }
.pipeline-header .caret-icon { float: right; transition: transform 0.3s; }
.pipeline-header.collapsed .caret-icon { transform: rotate(-90deg); }
.pipeline-body { padding: 20px 25px; background: #fff; }
.pipeline-body ul { padding-left: 20px; }
.pipeline-body li { margin-bottom: 8px; color: #555; }
.tech-badge {
display: inline-block;
background: #474e5d;
color: #fff;
padding: 6px 14px;
margin: 4px;
border-radius: 3px;
font-size: 13px;
font-family: Montserrat, sans-serif;
letter-spacing: 1px;
}
.tech-badge.green { background: #1abc9c; }
.pricing-row { display: flex; flex-wrap: wrap; margin: 0 -6px; }
.pricing-row > div { padding: 0 6px; margin-bottom: 12px; display: flex; }
.pricing-card {
background: #fff;
border-radius: 8px;
padding: 22px 20px;
text-align: center;
box-shadow: 0 2px 12px rgba(0,0,0,0.08);
transition: transform 0.2s, box-shadow 0.2s;
position: relative;
height: 100%;
width: 100%;
}
.pricing-card:hover { transform: translateY(-4px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.pricing-card.featured { border: 2px solid #1abc9c; }
.pricing-card .badge-popular {
position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
background: #1abc9c; color: #fff; padding: 4px 16px; border-radius: 12px;
font-family: Montserrat, sans-serif; font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
}
.pricing-card .tier-name { font-family: Montserrat, sans-serif; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: #888; margin-bottom: 10px; }
.pricing-card .tier-price { font-size: 42px; font-weight: 700; color: #303030; margin-bottom: 5px; }
.pricing-card .tier-price span { font-size: 16px; font-weight: 400; color: #888; }
.pricing-card .tier-desc { font-size: 14px; color: #888; margin-bottom: 20px; }
.pricing-card ul { list-style: none; padding: 0; text-align: left; margin-bottom: 25px; }
.pricing-card ul li { padding: 6px 0; font-size: 14px; color: #555; border-bottom: 1px solid #f0f0f0; }
.pricing-card ul li:last-child { border-bottom: none; }
.pricing-card ul li:before { content: "\2713"; color: #1abc9c; font-weight: 700; margin-right: 8px; }
.btn-subscribe {
display: inline-block; padding: 12px 30px; border-radius: 4px;
font-family: Montserrat, sans-serif; font-size: 13px; letter-spacing: 1px; text-transform: uppercase;
text-decoration: none; transition: all 0.2s;
}
.btn-subscribe.btn-primary-cta { background: #1abc9c; color: #fff; border: 2px solid #1abc9c; }
.btn-subscribe.btn-primary-cta:hover { background: #16a085; border-color: #16a085; color: #fff; }
.btn-subscribe.btn-outline { background: transparent; color: #1abc9c; border: 2px solid #1abc9c; }
.btn-subscribe.btn-outline:hover { background: #1abc9c; color: #fff; }
.btn-subscribe.btn-contact { background: transparent; color: #474e5d; border: 2px solid #474e5d; }
.btn-subscribe.btn-contact:hover { background: #474e5d; color: #fff; }
.tier-table { width: 100%; border-collapse: collapse; }
.tier-table th {
background: #474e5d;
color: #fff;
padding: 12px 15px;
text-align: center;
font-family: Montserrat, sans-serif;
font-size: 13px;
letter-spacing: 1px;
}
.tier-table td {
padding: 10px 15px;
border-bottom: 1px solid #e0e0e0;
text-align: center;
color: #555;
}
.tier-table tr:nth-child(even) { background: #f9f9f9; }
.tier-table .tier-name { font-weight: 600; color: #303030; }
.timeline-item {
position: relative;
padding-left: 30px;
margin-bottom: 30px;
border-left: 3px solid #1abc9c;
}
.timeline-item .timeline-time {
font-size: 12px;
color: #1abc9c;
text-transform: uppercase;
letter-spacing: 2px;
font-family: Montserrat, sans-serif;
margin-bottom: 5px;
}
.timeline-item .timeline-title {
font-size: 16px;
font-weight: 600;
color: #303030;
margin-bottom: 5px;
}
.timeline-item .timeline-desc { color: #818181; font-size: 14px; }
.arch-box {
background: #fff;
border: 2px solid #e0e0e0;
border-radius: 4px;
padding: 20px;
text-align: center;
margin-bottom: 15px;
min-height: 160px;
}
.arch-box h4 { color: #303030; margin-bottom: 10px; }
.arch-box p { font-size: 13px; color: #818181; margin-bottom: 0; }
.arch-box.primary { border-color: #1abc9c; }
.arch-box.primary h4 { color: #1abc9c; }
.section-divider {
width: 60px;
height: 3px;
background: #1abc9c;
margin: 0 0 30px 0;
}
.section-divider.center { margin: 0 auto 30px auto; }
code {
background: #f4f4f4;
padding: 2px 6px;
border-radius: 3px;
font-size: 13px;
color: #c0392b;
}
.feature-grid { margin-top: 15px; }
.feature-item {
background: #f9f9f9;
border-left: 3px solid #1abc9c;
padding: 12px 15px;
margin-bottom: 10px;
}
.feature-item strong { color: #303030; }
.feature-item span { color: #1abc9c; font-weight: 600; }
.callout {
background: #f9f9f9;
border-left: 4px solid #1abc9c;
padding: 20px 25px;
margin: 20px 0;
font-style: italic;
color: #555;
}
.slideanim { visibility: hidden; }
.slide {
animation-name: slide;
-webkit-animation-name: slide;
animation-duration: 1s;
-webkit-animation-duration: 1s;
visibility: visible;
}
@keyframes slide {
0% { opacity: 0; transform: translateY(70%); }
100% { opacity: 1; transform: translateY(0%); }
}
@media screen and (max-width: 768px) {
.col-sm-4 { text-align: center; margin: 25px 0; }
.jumbotron h1 { font-size: 28px; }
.container-fluid { padding: 40px 20px; }
.stat-card .stat-number { font-size: 24px; }
}
</style>
</head>
<body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Dave Liu</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="portfolio.html">Portfolio</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">Data About Me <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="index.html">Overview</a></li>
<li><a href="health/">Health Dashboard</a></li>
<li><a href="genomics/">Genomics</a></li>
<li><a href="analytics/">Site Analytics</a></li>
<li><a href="knowledge/">Knowledge Graph</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">AutoTrader <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="autotrader.html">Overview</a></li>
<li><a href="autotrader/daily/index.html">Daily Updates</a></li>
<li class="divider"></li>
<li><a href="#story">The Story</a></li>
<li><a href="#architecture">Architecture</a></li>
<li><a href="#pipelines">Pipelines</a></li>
<li><a href="#decisions">Design</a></li>
<li><a href="#tech">Tech Stack</a></li>
<li><a href="#pricing">Subscribe</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">Meta Council <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="https://meta-council.com" target="_blank">Try It</a></li>
<li><a href="research/meta-council-paper.pdf">Research Paper</a></li>
</ul>
</li>
<li><a href="https://www.linkedin.com/in/dave-l-a3139775/" target="_blank" rel="noopener noreferrer"><span class="fa fa-linkedin"></span></a></li>
<li><a href="https://github.com/daliu" target="_blank" rel="noopener noreferrer"><span class="fa fa-github"></span></a></li>
</ul>
</div>
</div>
</nav>
<!-- Hero -->
<div class="jumbotron text-center">
<h1>AutoTrader</h1>
<p>An ML-Powered Stock Prediction & Trading System</p>
<p style="font-size: 14px; color: #95a5a6; margin-top: 15px;">
Personal Project · 2024–Present · Live in Production
</p>
<p style="margin-top: 15px;">
<a href="https://moneysignals.us" target="_blank" rel="noopener noreferrer" style="color: #1abc9c; font-family: Montserrat, sans-serif; font-size: 13px; letter-spacing: 1px;">MONEYSIGNALS.US →</a>
<span style="margin: 0 10px; color: #555;">|</span>
<a href="autotrader/daily/index.html" style="color: #1abc9c; font-family: Montserrat, sans-serif; font-size: 13px; letter-spacing: 1px;">DAILY PREDICTIONS →</a>
</p>
</div>
<!-- The Story -->
<div id="story" class="container-fluid">
<h2>The Story</h2>
<div class="section-divider"></div>
<div class="row">
<div class="col-sm-8">
<p>AutoTrader started the way a lot of side projects do: with a question I couldn't let go of. I'd been working with recommendation systems at my day job, and it struck me that the core problem—predicting what a person will want next based on noisy, incomplete signals—isn't that different from predicting where a stock will move next based on noisy, incomplete market data.</p>
<p>So I started small. A few tickers, a basic feature set, a model that ran on my M3 laptop. But as I dug in, the scope grew naturally. A single ticker needed multi-timeframe analysis. Multi-timeframe analysis needed richer features. Richer features needed a real data pipeline. A real data pipeline needed cloud infrastructure. And before long, I was building a system that ingests data for 600+ tickers every night, engineers 400+ features from eight distinct sources, trains over 1,800 models, and delivers ranked predictions to subscribers before the opening bell.</p>
<p>Every component was designed and built by me from scratch. It runs autonomously on a multi-cloud setup (GCP + Azure) for about $235/month, and it's become the most technically satisfying project I've worked on—a place where I get to combine ML modeling, data engineering, infrastructure design, and product thinking all in one system.</p>
</div>
<div class="col-sm-4">
<div class="stat-card">
<span class="stat-number">1,800+</span>
<span class="stat-label">Trained Models</span>
</div>
<div class="stat-card">
<span class="stat-number">400+</span>
<span class="stat-label">Engineered Features</span>
</div>
<div class="stat-card">
<span class="stat-number">600+</span>
<span class="stat-label">Tickers Covered</span>
</div>
<div class="stat-card">
<span class="stat-number">~$235/mo</span>
<span class="stat-label">Total Infrastructure Cost</span>
</div>
</div>
</div>
</div>
<!-- Architecture -->
<div id="architecture" class="container-fluid bg-grey">
<h2>System Architecture</h2>
<div class="section-divider"></div>
<p>The system is split across two GCP virtual machines, coordinated through Google Cloud Storage and PostgreSQL. The separation isn't arbitrary: feature engineering is I/O-bound (lots of API calls and database writes), while model training is CPU-bound (lots of number crunching). Putting them on different VMs means I can right-size each machine's resources without overpaying for either workload.</p>
<p>Everything is orchestrated by cron jobs that hand off data downstream in sequence. There are no manual steps in the daily workflow—from raw market data to delivered email predictions, the system runs end-to-end without intervention.</p>
<!-- Nightly Timeline -->
<h3 style="margin-top: 30px;">Daily Workflow (EST)</h3>
<div class="row" style="margin-top: 20px;">
<div class="col-sm-12">
<div style="display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;">
<div class="timeline-item" style="flex: 1; min-width: 150px;">
<div class="timeline-time">12:10 AM</div>
<div class="timeline-title">Data Collection</div>
<div class="timeline-desc">VM2 pulls OHLCV data from 600+ tickers via the EODHD API, computes 400+ features per ticker, and writes everything to PostgreSQL and GCS. Takes about 45–60 minutes.</div>
</div>
<div class="timeline-item" style="flex: 1; min-width: 150px;">
<div class="timeline-time">3:00 AM (Sat)</div>
<div class="timeline-title">Comprehensive Training</div>
<div class="timeline-desc">VM3 retrains all ~1,800 models with Optuna hyperparameter optimization and walk-forward validation. Incremental training (100–200 models) runs on weekdays.</div>
</div>
<div class="timeline-item" style="flex: 1; min-width: 150px;">
<div class="timeline-time">5:00 AM</div>
<div class="timeline-title">Inference</div>
<div class="timeline-desc">VM3 loads every active model and generates predictions for the upcoming trading day. Each prediction combines a directional call with a magnitude estimate and a confidence score.</div>
</div>
<div class="timeline-item" style="flex: 1; min-width: 150px;">
<div class="timeline-time">5:30 AM</div>
<div class="timeline-title">Email Delivery</div>
<div class="timeline-desc">Tiered emails go out to subscribers with ranked predictions, market sentiment context, and analysis reports—all before the 9:30 AM open.</div>
</div>
</div>
</div>
</div>
<!-- VM Architecture -->
<h3 style="margin-top: 40px;">Infrastructure</h3>
<div class="row" style="margin-top: 15px;">
<div class="col-sm-3">
<div class="arch-box primary">
<h4>VM2: Data & Execution</h4>
<p>2 vCPU, 8 GB RAM · ~$49/mo</p>
<hr style="margin: 10px 0;">
<p>Data collection & features<br>
Inference & email delivery<br>
Trading execution (Alpaca)<br>
LLM event signals (Claude)</p>
</div>
</div>
<div class="col-sm-3">
<div class="arch-box primary">
<h4>VM3: Training (GCP)</h4>
<p>4 vCPU, 32 GB RAM · ~$50-80/mo</p>
<hr style="margin: 10px 0;">
<p>Dual model training (XGBoost)<br>
Optuna hyperparameter search<br>
Preemptible (auto-recovery)<br>
GCS model sync</p>
</div>
</div>
<div class="col-sm-3">
<div class="arch-box">
<h4>PostgreSQL + GCS</h4>
<p>2 vCPU, 8 GB · ~$52/mo</p>
<hr style="margin: 10px 0;">
<p>TimescaleDB (market data)<br>
Model registry & predictions<br>
GCS model artifact storage<br>
PgBouncer connection pooling</p>
</div>
</div>
<div class="col-sm-3">
<div class="arch-box primary">
<h4>Azure: Parallel Training</h4>
<p>Parallel training node</p>
<hr style="margin: 10px 0;">
<p>Morning/evening/night sessions<br>
Weekly & monthly models<br>
Distributed lock coordination<br>
SSH tunnel to GCP PostgreSQL</p>
</div>
</div>
</div>
<div class="row" style="margin-top: 10px;">
<div class="col-sm-12 text-center">
<p style="color: #818181; font-size: 14px;">
<strong>Data flow:</strong> EODHD API ($80/mo) → VM2 (collect & engineer) → PostgreSQL (store) → VM3 + Azure (train) → GCS (models) → VM2 (predict & trade) → Subscribers (email)
</p>
</div>
</div>
</div>
<!-- Pipelines -->
<div id="pipelines" class="container-fluid">
<h2>Pipeline Details</h2>
<div class="section-divider"></div>
<p style="margin-bottom: 25px;">Click any section below to expand or collapse it.</p>
<!-- Data Collection Pipeline -->
<div class="pipeline-section">
<div class="pipeline-header" data-toggle="collapse" data-target="#pipeline-data">
Data Collection & Feature Engineering
<span class="caret-icon">▼</span>
</div>
<div id="pipeline-data" class="collapse in pipeline-body">
<p>This is where the raw ingredients come from. Every night, the pipeline pulls fresh market data from the EODHD API for all S&P 500 constituents plus 184 ETFs, then transforms that data into a rich set of 500+ engineered features spanning technical, fundamental, sentiment, behavioral, and alternative data dimensions.</p>
<div class="row">
<div class="col-sm-6">
<h4>How It Works</h4>
<ul>
<li>Ingest OHLCV market data across multiple timeframes for all tracked tickers</li>
<li>Prioritize high-liquidity names to ensure freshest data for major positions</li>
<li>Store to PostgreSQL with GCS redundancy</li>
<li>Run the feature computation pipeline to generate 500+ features per ticker from 10+ distinct signal families</li>
<li>Collect multi-source sentiment and alternative data signals</li>
<li>Compute proprietary training labels designed to capture directional intent rather than simple close-to-close returns</li>
</ul>
</div>
<div class="col-sm-6">
<h4>Feature Sources (10+ Families, 500+ Features)</h4>
<div class="feature-grid">
<div class="feature-item"><strong>Technical Indicators</strong><br>Trend, momentum, volatility, volume, and pattern-based signals across multiple timeframes</div>
<div class="feature-item"><strong>Fundamental Data</strong><br>Valuation metrics, earnings estimates, and corporate event signals</div>
<div class="feature-item"><strong>Cross-Asset & Sector Signals</strong><br>Inter-market relationships, sector rotation dynamics, and risk regime indicators</div>
<div class="feature-item"><strong>Price Microstructure</strong><br>Higher-order derivatives of price dynamics and structural pattern recognition</div>
<div class="feature-item"><strong>Behavioral Economics</strong><br>Cognitive bias indicators: anchoring, disposition effect, herding intensity, and loss aversion asymmetries</div>
<div class="feature-item"><strong>Alternative Data & Sentiment</strong><br>Multi-source sentiment aggregation, social trend analysis, and event-driven signals with lagged impact modeling</div>
<div class="feature-item"><strong>Statistical & Regime Features</strong><br>Mean reversion signals, market phase detection, and volatility regime classification</div>
<div class="feature-item"><strong>Proprietary Composite Signals</strong><br>Calibrated multi-factor combinations derived from ongoing research into market microstructure</div>
</div>
</div>
</div>
</div>
</div>
<!-- Training Pipeline -->
<div class="pipeline-section">
<div class="pipeline-header" data-toggle="collapse" data-target="#pipeline-train">
Model Training
<span class="caret-icon">▼</span>
</div>
<div id="pipeline-train" class="collapse in pipeline-body">
<p>The core insight behind the training architecture is that direction and magnitude are fundamentally different prediction tasks and benefit from being modeled separately. Every ticker/timeframe combination gets two XGBoost models: a classifier that predicts whether the stock goes up or down, and a regressor that predicts by how much.</p>
<div class="row">
<div class="col-sm-6">
<h4>Dual Model Architecture</h4>
<p>Training two models per ticker lets each be optimized for what it's best at:</p>
<ul>
<li><strong>Direction Model:</strong> Predicts bullish or bearish. Optimized on classification accuracy. Trained on filtered data that removes noise days where direction is essentially random.</li>
<li><strong>Magnitude Model:</strong> Predicts expected move size. Optimized on directional accuracy. Trained on the full dataset to capture the complete distribution of outcomes.</li>
</ul>
<p>At inference time, the two predictions are combined into a single calibrated confidence score that captures both conviction and expected size of the move. Post-hoc calibration ensures the confidence values reflect true accuracy rates.</p>
</div>
<div class="col-sm-6">
<h4>Training Process</h4>
<ul>
<li><strong>Priority queue:</strong> Models queued by strategy (worst-performing first) so training time goes where it has the most impact</li>
<li><strong>Data loading:</strong> Features and labels pulled from PostgreSQL with GCS fallback</li>
<li><strong>Noise filtering:</strong> Low-movement days removed for direction model training to focus on meaningful signals</li>
<li><strong>Walk-forward validation:</strong> Expanding-window folds that respect temporal ordering (no future data leakage)</li>
<li><strong>Hyperparameter optimization:</strong> Automated search across model parameters using Bayesian optimization</li>
<li><strong>Evaluation:</strong> Multiple accuracy metrics tracked per fold including directional accuracy</li>
<li><strong>Lifecycle management:</strong> Top model versions retained per ticker/timeframe; older versions pruned automatically</li>
</ul>
<div class="callout">
Comprehensive training (all ~1,800 models) runs every Saturday and takes 2–4 hours. Incremental training (100–200 models) runs on weekdays in 20–60 minutes, focusing on new tickers and underperformers.
</div>
</div>
</div>
</div>
</div>
<!-- Inference Pipeline -->
<div class="pipeline-section">
<div class="pipeline-header" data-toggle="collapse" data-target="#pipeline-infer">
Inference & Prediction
<span class="caret-icon">▼</span>
</div>
<div id="pipeline-infer" class="collapse in pipeline-body">
<p>Every weekday morning at 5:00 AM, the inference pipeline loads all active models and generates a prediction for each ticker/timeframe pair. The output is a ranked list of the day's highest-confidence predictions, ready for delivery.</p>
<div class="row">
<div class="col-sm-6">
<h4>How It Works</h4>
<ul>
<li>Query the model registry for all active models (status = active)</li>
<li>For each ticker/timeframe: load the classifier and regressor from GCS</li>
<li>Load the most recent features for the current prediction date</li>
<li>Generate a direction prediction (bullish/bearish) with probability</li>
<li>Generate a magnitude prediction (% expected move)</li>
<li>Combine into a single confidence-ranked score</li>
<li>Store all predictions in PostgreSQL and upload a snapshot to GCS</li>
<li>Rank by confidence and split into top bullish and top bearish lists</li>
</ul>
</div>
<div class="col-sm-6">
<h4>Current Production Scale</h4>
<div class="stat-card">
<span class="stat-number">937</span>
<span class="stat-label">Predictions Generated Daily</span>
</div>
<div class="stat-card">
<span class="stat-number">358</span>
<span class="stat-label">Tickers with Active Models</span>
</div>
<div class="stat-card">
<span class="stat-number">~32/min</span>
<span class="stat-label">Prediction Throughput</span>
</div>
</div>
</div>
</div>
</div>
<!-- Email Delivery Pipeline -->
<div class="pipeline-section">
<div class="pipeline-header" data-toggle="collapse" data-target="#pipeline-email">
Email Delivery & Subscriptions
<span class="caret-icon">▼</span>
</div>
<div id="pipeline-email" class="collapse in pipeline-body">
<p>The delivery system takes predictions and wraps them in context: market sentiment, economic calendar events, and analysis reports. Subscribers receive content matched to their tier, delivered as polished HTML emails with optional attachments.</p>
<div class="row">
<div class="col-sm-6">
<h4>Delivery Workflow</h4>
<ul>
<li>Validate PostgreSQL tunnel connectivity (auto-start if needed)</li>
<li>Check data freshness via <code>TradingDayValidator</code>—trigger a sync if data is stale</li>
<li>Generate or load analysis reports for the current trading day</li>
<li>Load predictions from PostgreSQL</li>
<li>Collect market context: Put/Call ratio, Fear & Greed index, social sentiment (ApeWisdom), Forex Factory economic calendar</li>
<li>Load subscriber list and filter by tier</li>
<li>Render tier-specific HTML emails with appropriate attachments</li>
<li>Send via SMTP with a lock file to prevent duplicate sends</li>
<li>SMS notification to admin on success or failure</li>
</ul>
<div class="callout" style="margin-top: 20px;">
<strong>See it live:</strong> Browse the <a href="autotrader/daily/index.html" style="color: #1abc9c;">Daily Updates</a> page for real examples of the Basic tier email output, published every trading day.
</div>
</div>
<div class="col-sm-6">
<h4>Subscription Tiers</h4>
<p style="margin-bottom: 15px;">Content scales with tier—everyone gets predictions, but the depth of analysis and number of picks increases as you move up.</p>
<table class="tier-table">
<thead>
<tr>
<th>Tier</th>
<th>Predictions</th>
<th>Analysis</th>
<th>Extras</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tier-name">Basic</td>
<td>SPY only</td>
<td>F&G, headlines</td>
<td>—</td>
</tr>
<tr>
<td class="tier-name">Premium</td>
<td>Top 50</td>
<td>PCR, social, congress, full news</td>
<td>—</td>
</tr>
<tr>
<td class="tier-name">Professional</td>
<td>All 600+</td>
<td>LLM synthesis, entity tracker, alt-data</td>
<td>CSV + heatmaps</td>
</tr>
<tr>
<td class="tier-name">Secret</td>
<td>All 600+</td>
<td>Sonnet synthesis, raw model data</td>
<td>CSV + heatmaps + API</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- Key Design Decisions -->
<div id="decisions" class="container-fluid bg-grey">
<h2>Design Decisions</h2>
<div class="section-divider"></div>
<p style="margin-bottom: 30px;">A system like this involves hundreds of small choices. Here are the ones that shaped the architecture most significantly—and the reasoning behind each.</p>
<div class="row">
<div class="col-sm-6">
<h4>Why dual models instead of one?</h4>
<p>Early on I tried a single model that predicted signed returns directly. It was mediocre at both direction and magnitude. Splitting the problem into a classifier ("which way?") and a regressor ("how far?") lets each model focus on what it does best. The classifier trains on filtered data with noise days removed; the regressor sees the full distribution. The combined signal is stronger than either alone.</p>
<h4>Why walk-forward validation?</h4>
<p>Standard K-fold cross-validation would let the model see Tuesday's data while training on Thursday's. In financial data, that's cheating—any time-series pattern, regime change, or structural break gets leaked across the boundary. Walk-forward validation with expanding windows respects temporal ordering, which means the performance estimates I get are realistic rather than flattering.</p>
<h4>Why custom training labels instead of simple returns?</h4>
<p>Simple close-to-close returns miss the intraday story—a stock can gap up 2% then sell off all day. The training labels are designed to capture where actual trading conviction lies, producing better signal for the models even if they're noisier to compute.</p>
</div>
<div class="col-sm-6">
<h4>Why separate VMs?</h4>
<p>Feature engineering spends most of its time waiting on API responses and writing to databases (I/O-bound). Model training spends most of its time in XGBoost's gradient computations (CPU-bound). Running both on a single VM would mean paying for 16 GB of RAM during data collection when I only need 8, or paying for beefy CPUs during the data pipeline when they'd sit idle. The multi-VM split lets me right-size each workload—GCP handles data pipelines and a dedicated PostgreSQL instance, while an Azure VM provides parallel training capacity.</p>
<h4>Why filter noise days for the direction model?</h4>
<p>On days when a stock barely moves, predicting "up" or "down" is essentially a coin flip—and training on coin flips adds noise without signal. Filtering low-movement days lets the direction model focus on days with actual directional commitment, while the magnitude model still sees the full distribution.</p>
<h4>Why build everything from scratch?</h4>
<p>Partly because I wanted to understand every piece of the system at a level that using off-the-shelf solutions wouldn't give me. But also because the constraints of a personal project—tight budget, single maintainer, zero tolerance for pager fatigue—reward simplicity. Cron jobs, PostgreSQL, and GCS are boring, well-understood technologies. That's the point. I'd rather spend my engineering time on feature research and model architecture than debugging Kubernetes manifests.</p>
</div>
</div>
</div>
<!-- Technologies -->
<div id="tech" class="container-fluid">
<h2>Tech Stack</h2>
<div class="section-divider"></div>
<div class="row">
<div class="col-sm-6">
<h4>Machine Learning</h4>
<span class="tech-badge green">XGBoost</span>
<span class="tech-badge green">Optuna</span>
<span class="tech-badge green">Scikit-learn</span>
<span class="tech-badge green">TA-Lib</span>
<span class="tech-badge green">FAISS</span>
<span class="tech-badge green">Pandas</span>
<span class="tech-badge green">NumPy</span>
<span class="tech-badge green">SciPy</span>
<br><br>
<h4>Data Sources</h4>
<span class="tech-badge">Ticker & Price Data</span>
<span class="tech-badge">Options Flow</span>
<span class="tech-badge">Market Sentiment</span>
<span class="tech-badge">Social Sentiment</span>
<span class="tech-badge">Economic Calendar</span>
<span class="tech-badge">Investor Surveys</span>
</div>
<div class="col-sm-6">
<h4>Infrastructure</h4>
<span class="tech-badge">GCP Compute Engine</span>
<span class="tech-badge">Google Cloud Storage</span>
<span class="tech-badge">PostgreSQL</span>
<span class="tech-badge">SQLite</span>
<span class="tech-badge">Cron</span>
<span class="tech-badge">SSH Tunnels</span>
<br><br>
<h4>Trading & Delivery</h4>
<span class="tech-badge green">Alpaca API</span>
<span class="tech-badge green">SMTP / Gmail</span>
<span class="tech-badge green">SMS Alerts</span>
<span class="tech-badge green">Stripe</span>
<br><br>
<h4>Languages & Tools</h4>
<span class="tech-badge">Python</span>
<span class="tech-badge">Bash</span>
<span class="tech-badge">SQL</span>
<span class="tech-badge">Git</span>
<span class="tech-badge">Selenium</span>
</div>
</div>
</div>
<!-- Pricing -->
<div id="pricing" class="container-fluid bg-grey">
<h2>Subscribe</h2>
<div class="section-divider"></div>
<p style="margin-bottom: 10px;">AutoTrader delivers ML-driven market predictions to your inbox every trading day before the opening bell. 1,800+ models, 600+ tickers, 400+ features — fully autonomous.</p>
<p style="margin-bottom: 40px; color: #888; font-size: 14px;">All paid tiers include a 7-day free preview of the Basic tier so you can see the system in action.</p>
<h3>Email Subscriptions</h3>
<div class="pricing-row">
<!-- Basic -->
<div class="col-sm-4">
<div class="pricing-card" style="display: flex; flex-direction: column;">
<div class="tier-name">Basic</div>
<div class="tier-price">Free</div>
<div class="tier-desc">Daily market snapshot</div>
<ul style="flex-grow: 1;">
<li>SPY prediction</li>
<li>Fear & Greed index</li>
<li>Key events for tomorrow</li>
<li>2 business news headlines</li>
<li>Market sentiment snapshot</li>
</ul>
<form id="signup-form" style="margin-top: auto;" onsubmit="return false;">
<label for="signup-email" class="sr-only">Email address</label>
<input type="email" id="signup-email" placeholder="your@email.com" required
style="width: 100%; padding: 10px; border: 2px solid #e0e0e0; border-radius: 4px; font-size: 14px; margin-bottom: 8px; text-align: center; font-family: Lato, sans-serif;">
<div style="position: absolute; left: -9999px;" aria-hidden="true">
<input type="text" id="signup-hp" name="hp_field" tabindex="-1" autocomplete="off">
</div>
<button type="submit" id="signup-btn" class="btn-subscribe btn-outline"
style="width: 100%; cursor: pointer;">Sign Up Free</button>
<div id="signup-msg" style="margin-top: 8px; font-size: 13px; text-align: center; min-height: 20px;"></div>
</form>
</div>
</div>
<!-- Premium -->
<div class="col-sm-4">
<div class="pricing-card featured" style="display: flex; flex-direction: column;">
<div class="badge-popular">Most Popular</div>
<div class="tier-name">Premium</div>
<div class="tier-price">$29<span>/mo</span></div>
<div class="tier-desc">Active trader essentials</div>
<ul style="flex-grow: 1;">
<li>Top 20 predictions (all tickers)</li>
<li>Full news coverage</li>
<li>Put/Call ratio analysis</li>
<li>Top 50 ticker momentum table</li>
<li>Social sentiment (Reddit + YouTube)</li>
<li>Congress stock trades</li>
<li>Full economic calendar</li>
<li>Priority email delivery</li>
</ul>
<a href="https://buy.stripe.com/eVq9AUbLse2CdQ53Ir5c404" class="btn-subscribe btn-primary-cta">Subscribe</a>
</div>
</div>
<!-- Professional -->
<div class="col-sm-4">
<div class="pricing-card" style="display: flex; flex-direction: column;">
<div class="tier-name">Professional</div>
<div class="tier-price">$99<span>/mo</span></div>
<div class="tier-desc">Full signal access</div>
<ul style="flex-grow: 1;">
<li>All 600+ ticker predictions</li>
<li>All timeframes (daily, weekly, monthly)</li>
<li>LLM market synthesis & narrative</li>
<li>S&P 500 premium predictions</li>
<li>GICS heatmap attachments</li>
<li>CSV data exports</li>
<li>Full momentum table with AUC</li>
<li>Everything in Premium</li>
</ul>
<a href="https://buy.stripe.com/4gM00k4j0gaK27n3Ir5c403" class="btn-subscribe btn-outline">Subscribe</a>
</div>
</div>
</div>
<h3 style="margin-top: 20px;">API Access</h3>
<p style="margin-bottom: 12px;">Programmatic access to AutoTrader's predictions, features, and model data. Built for quants, algo traders, and fintech developers. <a href="https://api.moneysignals.us/docs" style="color: #1abc9c;">View API docs →</a></p>
<div class="pricing-row">
<!-- API Starter -->
<div class="col-sm-4">
<div class="pricing-card" style="display: flex; flex-direction: column;">
<div class="tier-name">API Starter</div>
<div class="tier-price">$49<span>/mo</span></div>
<div class="tier-desc">For side projects & exploration</div>
<ul style="flex-grow: 1;">
<li>Core prediction endpoints</li>
<li>1,000 API calls / day</li>
<li>Daily predictions (JSON)</li>
<li>Market sentiment data</li>
<li>Standard rate limiting</li>
</ul>
<a href="https://buy.stripe.com/6oUcN6aHobUu7rH4Mv5c402" class="btn-subscribe btn-outline">Get Started</a>
</div>
</div>
<!-- API Pro -->
<div class="col-sm-4">
<div class="pricing-card" style="display: flex; flex-direction: column;">
<div class="tier-name">API Pro</div>
<div class="tier-price">$199<span>/mo</span></div>
<div class="tier-desc">For algo traders & small funds</div>
<ul style="flex-grow: 1;">
<li>All 18 endpoints</li>
<li>10,000 API calls / day</li>
<li>Raw model predictions & features</li>
<li>Feature importance data</li>
<li>Historical prediction archive</li>
<li>CSV & JSON exports</li>
</ul>
<a href="https://buy.stripe.com/5kQ4gAdTA6Aa3br2En5c401" class="btn-subscribe btn-primary-cta">Get Started</a>
</div>
</div>
<!-- API Enterprise -->
<div class="col-sm-4">
<div class="pricing-card" style="display: flex; flex-direction: column;">
<div class="tier-name">Enterprise</div>
<div class="tier-price">Custom</div>
<div class="tier-desc">For teams & institutions</div>
<ul style="flex-grow: 1;">
<li>Unlimited API calls</li>
<li>Dedicated support & SLA</li>
<li>Custom endpoints & integrations</li>
<li>Bulk historical data access</li>
<li>Architecture licensing available</li>
</ul>
<a href="mailto:50685071@proton.me?subject=AutoTrader%20Enterprise%20%2F%20Architecture%20Licensing&body=I'm%20interested%20in%20Enterprise%20API%20access%20or%20architecture%20licensing.%0A%0AName%3A%20%0ACompany%3A%20%0AEmail%3A%20%0AUse%20case%3A%20" class="btn-subscribe btn-contact">Contact</a>
</div>
</div>
</div>
</div>
<!-- What's Next -->
<div class="container-fluid">
<h2>What's Next</h2>
<div class="section-divider"></div>
<div class="row">
<div class="col-sm-12">
<p>AutoTrader is a living system—it runs in production daily, but it's also my primary playground for exploring new ideas. A few things on the roadmap:</p>
<ul style="color: #555; padding-left: 20px;">
<li><strong>Ensemble methods:</strong> Exploring how to combine predictions across timeframes (daily, weekly, monthly) into a single multi-horizon signal, weighted by each model's recent accuracy.</li>
<li><strong>Transformer-based models:</strong> The current XGBoost approach works well on tabular features, but I'm curious whether attention mechanisms over raw price sequences could capture patterns that hand-engineered features miss.</li>
<li><strong>Portfolio optimization:</strong> Moving beyond individual ticker predictions to portfolio-level allocation—factoring in correlation, sector exposure, and risk constraints.</li>
<li><strong>Real-time inference:</strong> Currently predictions run once daily. Exploring whether intraday feature updates and streaming inference could capture opportunities that the overnight pipeline misses.</li>
</ul>
</div>
</div>
</div>
<!-- Footer -->
<footer class="container-fluid text-center" style="background: #2f2f2f; padding: 40px 50px; color: #95a5a6;">
<div style="margin-bottom: 15px;">
<a href="https://www.linkedin.com/in/dave-l-a3139775/" target="_blank" rel="noopener noreferrer" style="color: #fff; margin: 0 12px; font-size: 20px;"><span class="fa fa-linkedin"></span></a>
<a href="https://github.com/daliu" target="_blank" rel="noopener noreferrer" style="color: #fff; margin: 0 12px; font-size: 20px;"><span class="fa fa-github"></span></a>
<a href="mailto:50685071@proton.me" style="color: #fff; margin: 0 12px; font-size: 20px;"><span class="fa fa-envelope-o"></span></a>
</div>
<p style="margin-bottom: 5px;"><a href="portfolio.html" style="color: #1abc9c;">Portfolio</a> · <a href="index.html" style="color: #1abc9c;">Data About Me</a> · <a href="autotrader.html" style="color: #1abc9c;">AutoTrader</a> · <a href="health/" style="color: #1abc9c;">Health</a> · <a href="analytics/" style="color: #1abc9c;">Analytics</a></p>
<p style="font-size: 12px; margin-bottom: 0;">Dave Liu © 2026</p>
</footer>
<script>
$(document).ready(function(){
$(".navbar a, footer a[href='#myPage']").on('click', function(event) {
if (this.hash !== "") {
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 900, function(){
window.location.hash = hash;
});
}
});
// Toggle caret on collapse
$('.pipeline-header').on('click', function() {
$(this).toggleClass('collapsed');
});
$(window).scroll(function() {
$(".slideanim").each(function(){
var pos = $(this).offset().top;
var winTop = $(window).scrollTop();
if (pos < winTop + 600) {
$(this).addClass("slide");
}
});
});
});
// --- Basic tier signup ---
(function() {
var loadedAt = Date.now() / 1000;
var form = document.getElementById('signup-form');
if (!form) return;
var msgEl = document.getElementById('signup-msg');
var btn = document.getElementById('signup-btn');
form.addEventListener('submit', function(e) {
e.preventDefault();
msgEl.textContent = '';
msgEl.style.color = '#818181';
var email = document.getElementById('signup-email').value.trim();
var hp = document.getElementById('signup-hp').value;
if (!email) { msgEl.textContent = 'Please enter your email.'; msgEl.style.color = '#c0392b'; return; }
btn.disabled = true;
btn.textContent = 'Signing up...';
fetch('https://signup.moneysignals.us/signup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: email, name: '', hp_field: hp, _loaded_at: loadedAt })
})
.then(function(r) { return r.json(); })
.then(function(d) {
msgEl.textContent = d.message || (d.success ? 'Subscribed!' : 'Something went wrong.');
msgEl.style.color = d.success ? '#1abc9c' : '#c0392b';
if (d.success) document.getElementById('signup-email').value = '';
})
.catch(function() { msgEl.textContent = 'Network error. Please try again.'; msgEl.style.color = '#c0392b'; })
.finally(function() { btn.disabled = false; btn.textContent = 'Sign Up Free'; });
});
})();
</script>
</body></html>