DEV Community

hmza
hmza

Posted on

Did I just build a market crash simulator instead of a trading game?

Image description

So I built a trading game in C# Windows Forms — y'know, just your average market simulator, no big deal. Everything was going great… until it wasn’t. Turns out, my price algorithm is basically the Grim Reaper of stock charts. It gives micro gains a VIP pass and makes big jumps rarer than clean code on a Friday. The result? Prices nosedive like they saw a spider and never bounce back. It's less "Wall Street" and more "Fall Street." At this point, it's not a trading game — it's a slow-motion market apocalypse. 10/10 would not invest. But hey, dev life. 💀📉

Image description

Code for random change

 if (chance < 1)
     percentChange = 0.75; // 🚀 Very Big Jump (0.75%)
 else if (chance < 5)
     percentChange = 0.40 + rand.NextDouble() * 0.1; // 📈 Big Jump (0.40% - 0.50%)
 else if (chance < 10)
     percentChange = 0.20 + rand.NextDouble() * 0.1; // ⚡ Medium Jump (0.20% - 0.30%)
 else if (chance < 50)
     percentChange = 0.05 + rand.NextDouble() * 0.05; // 📉 Small Jump (0.05% - 0.10%)
 else
     percentChange = 0.001 + rand.NextDouble() * 0.005; // 🌊 Micro Noise (0.10% to 0.60%)
Enter fullscreen mode Exit fullscreen mode

Image description

Note to self: maybe tweak the algorithm so it doesn’t simulate the 2008 crash every round.

Top comments (0)