A flag meant to stop one account from rebuying transferred-out stock turned out to be global, and it force-sold the same stock right after another account received it. Also finished building a new automation tool for performance tuning.
This is the English version of a post originally written in Korean for my algorithmic trading system devlog(new tab).
A do-not-rebuy flag hit the wrong account
Over the past two days I've been physically transferring stock positions from the old account into the new one.
When a stock leaves the old account, I set a flag on it meaning "don't buy this back" — the point being to keep the old account from re-acquiring something it just gave away.
Going through the logs this morning, I found that this flag wasn't actually scoped per account. It lived in a single file shared across the whole system.
Because of that, the trading logic treated any account reading this file as if the flagged stock should be excluded from its rankings — including the new account, which had just received that same stock and was supposed to keep holding it.
The damage was real. Within hours of receiving the transfer yesterday, the new account force-sold several of those positions.
That's the exact opposite of what the transfer was supposed to do — move the assets over so the new account keeps managing them.
After this morning's second transfer, I confirmed the same risk was still sitting there and immediately cleared the flag file entirely.
The old account, it turned out, already had a separate safeguard in place (a mode that blocks all new trading), so the flag was never even necessary there — it was a redundant safety measure on one side that turned into a real bug on the other.
I haven't done the deeper fix yet — scoping the flag per account. If the transfer logic sets this flag the same way again next time, the same incident could repeat, so I wrote up two candidate code changes and left the decision for later.
A couple of ledger reconciliation slip-ups
Around midday, while checking on the transfer progress, I miscalculated total assets under management.
Going off ledger(new tab) values alone gave a number that didn't match the actual broker balance. It turned out there had been a real cash withdrawal from the account — bank withdrawals are outside what the system can detect automatically, so it never made it into the ledger.
A similar slip happened again in the afternoon, this time a personal withdrawal on the other account. Same fix: book it into the ledger to restore consistency.
Neither was an actual loss or trading error — both were just corrections to bring the ledger back in line with reality. Still, it reconfirmed a lesson: never trust the ledger alone when asked "what's the total," always cross-check against the actual broker balance.
Built a new automation tool for performance tuning
This project keeps swapping out LLMs and GPUs, and every time it does, performance tuning has to be redone from scratch.
Today I designed and built a tool to automate that whole process. After several rounds of back-and-forth with a different AI to refine the design, it landed on a loop: replay real traffic, search tuning parameters, verify the results, repeat.
The replay traffic is drawn from actual recent requests rather than synthetic load, and parameters that risk hurting output quality go through stricter verification than ones that are pure speed knobs.
I also split permissions so that the part of the system responsible for touching the GPU is separate from the part responsible for design — structurally preventing the design side from accidentally reaching into the live production service.
Today was just the build — I haven't run it once yet. The first real run is something I'll walk through myself next time.
Top comments (0)