Urgent.News

What's breaking now, across thousands of outlets.

Tech

The Bug That Passed Every Test and Still Lost Me Money

I am building an automated stock trading bot in public. I am not a developer by trade, so I lean hard on tests to feel safe shipping. Which is exactly why this one stung: a bug that passed every single test I had, and still lost me money the moment it touched the real market. The suite was green, so I trusted it Every test passed. I deployed. That green checkmark felt like permission. The problem…

A stock trading bot was built and put through rigorous testing, but a bug slipped through that lost the bot money. The bot was programmed to run a routine at the end of the trading day, but the tests used fixed timestamps instead of the real world scenario. The server ran on UTC while the market runs on Eastern time, causing the bot to make decisions based on incomplete data.

The tests proved the code was consistent but not correct, as they didn't account for external factors like time zones, holidays, and missing data. To fix the issue, the bot's tests now use realistic data with proper timezone awareness. The author emphasizes that a green test suite only indicates that the code is consistent, not correct, and stresses the importance of testing the environment, not just the function, especially when dealing with real-world transactions.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Crowdwide Is Now Public for Testing 🚀

So yeah... Crowdwide is finally public. I've been working on it for more than 15 days before the first deployment, and after a lot of debugging, fixing things, breaking things again, and dealing with…

More from Sunday 20 September →