On the Verge of the First Real Order, the Code Voted No
Auditing the code that actually moves real money turned up several genuine bugs, and it also prompted a fresh look at which broker to use
I mentioned a few days ago that I was preparing to expand live trading. Yesterday turned out to be a genuinely important day in that preparation.
On the verge of the first real order, the code voted no
The code path that actually places orders is the most carefully handled part of this project. Before putting it to real use, I had it audited from an outside perspective one more time — and the verdict was: don't place the first real order in the current state.
Several genuine bugs turned up. The safeguard meant to prevent duplicate orders had a hole: when the check itself failed, it silently let the order through instead of blocking it. I'd recently introduced a third "result unknown" state alongside success/failure, but there was still one path where that state wasn't caught properly and leaked through as a false success.
The design was supposed to record an order before actually placing it, but there was a path where the order still went out even if the recording itself failed. Now, if recording fails, the order doesn't go out either.
I also re-examined the assumption that the account might hold other positions the bot doesn't know about, and added a safeguard so the bot's tracked position can never exceed the actual balance.
Individually these look like small bugs, but every one of them was the kind that "normally doesn't trigger, only under specific conditions" — the kind you can't find without an audit. Since this is the only code path that touches real account funds, this audit was worth the time it took.
Reconsidered which broker to use
While expanding live trading, I also reconsidered whether to keep using the current broker's API or switch to a different one. The first pass concluded "no need to switch," but revisiting it within the same day flipped that conclusion.
The reasoning is simple: no real order has gone out yet, so this is the cheapest point to switch brokers. Switching after weeks of real use would mean throwing away accumulated verification and familiarity — right now, there's nothing to throw away.
Once decided, I tested the new broker's connection immediately — authentication, balance lookup, and ticker lookup all worked without issue.
Confirmed: no AI in the intraday loop
There's been an old idea floating around — running a lightweight AI judgment continuously during market hours. Yesterday I finally shelved it for good, after several rounds of review.
The core reasoning: information that needs a fast intraday reaction is mostly already priced in instantly, and the slower information where AI could actually add value is already being digested by the daily-cycle analysis. The case for running it continuously was weak, and the cost was not small.
Instead, intraday will keep only rule-based detection, with AI narration requested on demand only when needed. Decisions still get made at night, on a daily cycle.
Data archive — yesterday's blind spot, wrapped up today
Wrapped up the issue found the day before yesterday in the data archive(new tab): the blind spot where historical news-to-ticker linking only covered a subset of tickers.
Expanded the coverage to the full ticker universe and re-linked the articles already collected. No need to re-scrape anything — re-matching the existing data was enough.
Also this week
- Considered buying historical news from a paid service, decided against it for now — the current approach is good enough.
- Finished the risk-free portion of prep work for an upcoming large structural rework ahead of time: how experiment results get recorded, and documenting what each running process currently does.
- Consolidated network-error detection logic that had been scattered across several places into one spot — now there's just one place to fix.
Looking back, yesterday was a day spent asking, over and over, "how much should I distrust what I already have before expanding live trading further." Several things turned up that I wouldn't have known about without the audit.