今日已更新 196 条资讯 | 累计 29338 条内容
关于我们

My Algorithmic Trading Bot Silently Failed to Notify: The Curious Case of Missing `.env` Loads Across Scripts

oji - building AI in public 2026年08月05日 14:25 3 次阅读 来源:Dev.to

Hey everyone, it's your friendly neighborhood senior dev here. I'm 38, working as a full-time engineer during the week, and tinkering with AI-powered algorithmic trading bots on the weekends. Today, I want to share a story about a subtle but potentially catastrophic bug I found in my bot. Seriously, thank goodness I caught this before deploying with real capital. The TL;DR: My Discord notifications for order confirmations weren't firing, and the culprit was a forgotten .env load across multiple Python scripts. I think this is a pretty common pitfall when you're working on personal projects with several interconnected Python scripts. What Happened: A "Silent Failure" Uncovered by DRY_RUN Over the weekend, I was running my usual DRY_RUN tests for my forex bot. My bot's architecture splits responsibilities: planner.py handles strategy logic, and executor.py executes actual trades on the exchange. Looking at the console logs, executor.py seemed to be working perfectly. I saw logs like [DRY_RUN] Order placed: ... . But the Discord notifications, which are supposed to arrive after an order, simply weren't showing up. Initially, I thought it might be a Discord issue or just a delay. But after 30 minutes, still nothing. This felt wrong. The thought of this happening with real money sent shivers down my spine: "I thought I placed the order, but it never went through." "I was sure I closed that position, but it's still open." Bugs in notification systems are notorious for creating these kinds of silent failures, and they're genuinely scary. The Investigation: Aha! Found You... My first step was to isolate the problem. I directly invoked notify.py , the script responsible for sending notifications. It worked perfectly, sending a test message to Discord. This strongly suggested the issue was upstream, likely within executor.py , which calls notify.py . I took a closer look at executor.py 's logs. And there it was: the webhook URL, which should have been passed to the notificati

本文内容来源于互联网,版权归原作者所有
查看原文