<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aryaman Gandhi</title>
    <description>The latest articles on DEV Community by Aryaman Gandhi (@aryaman_gandhi).</description>
    <link>https://dev.to/aryaman_gandhi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4096423%2Ff21b1ae6-7028-4509-bb65-aba5ee133905.png</url>
      <title>DEV Community: Aryaman Gandhi</title>
      <link>https://dev.to/aryaman_gandhi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aryaman_gandhi"/>
    <language>en</language>
    <item>
      <title>I Built a Stock Market Game in a Few Days</title>
      <dc:creator>Aryaman Gandhi</dc:creator>
      <pubDate>Wed, 26 Aug 2026 23:52:18 +0000</pubDate>
      <link>https://dev.to/aryaman_gandhi/i-built-a-stock-market-game-in-a-few-days-k2m</link>
      <guid>https://dev.to/aryaman_gandhi/i-built-a-stock-market-game-in-a-few-days-k2m</guid>
      <description>&lt;p&gt;The idea&lt;/p&gt;

&lt;p&gt;You're given a random year (2019-2022), then you pick one stock per sector without seeing prices. Eight sectors, eight picks. Allocate $10K however you want. See how you would've performed in that year.&lt;br&gt;
The mechanic is pure strategy. You know the year upfront. So the question becomes: which stocks will do well in 2022? Or 2019? That forces you to think about what actually happened in those markets. Tech dominated 2019-2021, got crushed in 2022. Energy was dead for years then suddenly mattered.&lt;/p&gt;

&lt;p&gt;You can't rely on current sentiment. You have to think about historical context and sector rotation. Pick Apple for 2022 and you're in for a rough time. Pick it for 2019 and you're golden. The game forces you to actually know something about what happened in different years, not just have opinions about which companies are good.&lt;/p&gt;

&lt;p&gt;It's interesting because most people don't think about markets this way. We know what's happening now. We have opinions about what's good now. But actually understanding how different years played out differently? That's harder. And more useful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz6t3n2s1wrq50gwe8cbh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz6t3n2s1wrq50gwe8cbh.jpg" alt=" " width="799" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Building it&lt;/p&gt;

&lt;p&gt;I started with the roughest possible version. Just enough to see if the idea was even playable. A basic draft flow, mock data, and a simple calculation to show returns. Nothing polished. No styling, minimal logic, just the core mechanic working.&lt;/p&gt;

&lt;p&gt;But that rough version was worth everything. Because the moment I had something interactive, I knew the idea worked. I wasn't building abstractions anymore. I was playing a game I'd made. And that's when you actually know if something is fun or not. You can't know that from a design document. You have to play it.&lt;/p&gt;

&lt;p&gt;The tricky part was the data. I needed historical stock prices for ~140 tickers across 4 years (2019-2022). Not just any data either, I needed to organize it by year, handle tickers that didn't have complete data (some companies went public after 2019, some got acquired), and make it queryable without hitting an API at runtime. The whole game needed to work client-side, which meant all the data had to be baked in.&lt;/p&gt;

&lt;p&gt;Fetching the data itself was a challenge. The API I was using had rate limits, and pulling data for 140 tickers across 4 years meant a lot of requests. Had to add delays between requests, handle failures gracefully, and retry when things timed out. Once I had all the data, organizing it into a structure that made sense for the simulation took a couple iterations. But once the data pipeline was solid, everything else fell into place.&lt;/p&gt;

&lt;p&gt;After the data pipeline worked, I added tests because the return calculations were complex. You're buying shares on the first trading day of a year at the opening price, then selling on the last trading day at the closing price. If you mess that up, the whole game gives wrong results. Tests caught bugs that would've shipped broken.&lt;/p&gt;

&lt;p&gt;Built a UI that didn't look like it was thrown together in an hour. Used React components, Tailwind for styling, kept it clean and simple. Restructured things a few times to make the code cleaner.&lt;br&gt;
The whole process was straightforward though. I didn't overthink it. I didn't spend days planning the perfect architecture. I just built it, saw what worked, and iterated. That's faster than you'd think.&lt;/p&gt;

&lt;p&gt;Tools&lt;/p&gt;

&lt;p&gt;Used Cline to write most of the code. Also used Next.js, TypeScript, and Tailwind. Historical data from Twelve Data. Nothing fancy, just tools that work together.&lt;/p&gt;

&lt;p&gt;Cline handled the heavy lifting: the simulation logic, the UI components, catching edge cases I didn't think of. I could've used other tools, but Cline's reliability mattered. It never broke something that was already working. When I asked it to refactor the data pipeline, it didn't touch the simulation logic. When I asked it to add a new feature, it didn't accidentally break the tests. That consistency matters more than raw speed when you're trying to ship something.&lt;/p&gt;

&lt;p&gt;The other thing that helped: being able to think through problems conversationally. "Here's what I'm trying to do, here's why it's not working, what should I try?" That back-and-forth helped me understand the problem better, not just get code faster.&lt;/p&gt;

&lt;p&gt;What stuck&lt;/p&gt;

&lt;p&gt;Shipping something rough beats perfecting something theoretical. I catch myself trying to build perfectly all the time. Spending days thinking about architecture, arguing with myself about the right approach, optimizing before anything ships. This time I just didn't. Had something playable in hours. Everything after that was making it better, not building from scratch.&lt;/p&gt;

&lt;p&gt;Tests give you confidence to refactor. Each change made the code better and tests made sure nothing broke. Tests aren't overhead. They're freedom.&lt;/p&gt;

&lt;p&gt;What's interesting about the mechanic&lt;/p&gt;

&lt;p&gt;The game actually teaches you something about markets. Everyone thinks they know which stocks are good. But "good" is context-dependent. The same stock performs completely differently depending on the year.&lt;/p&gt;

&lt;p&gt;You realize how much sector rotation matters. Energy stocks were terrible for years. Mining stocks, oil companies, all garbage from an investor's perspective. Then 2022 hit and suddenly they were the best performers. Interest rate hikes, inflation, oil prices spiking. The entire context changed.&lt;/p&gt;

&lt;p&gt;Tech did the opposite. Up massively for three years straight. Anything tech-adjacent was printing money. Then 2022 came and valuations compressed hard. Companies that seemed unstoppable got cut in half.&lt;/p&gt;

&lt;p&gt;Playing the game forces you to think historically instead of just having opinions. You can't just say "Apple is good." You have to know why it was good in 2019 but rough in 2022. What changed? What was the macro environment like? Why did investors care about different things?&lt;/p&gt;

&lt;p&gt;That's actually useful knowledge. It teaches you that markets aren't random, but they're not predictable either. Different years reward different things. Understanding that is worth more than just having strong opinions about stocks.&lt;/p&gt;

&lt;p&gt;What's next&lt;/p&gt;

&lt;p&gt;I want to add features like leaderboards, charts, and multiplayer eventually. But for now, I'm just sitting with having shipped something. Something that works. Something people can actually play.&lt;br&gt;
That's the win. Not the perfect architecture. Not the most optimized code. Just: I had something to build, and now it exists, and people can use it.&lt;/p&gt;

&lt;p&gt;If you're thinking about building something, don't wait for it to be perfect. Build the rough version. See if anyone cares. Then iterate. That's how everything gets made.&lt;/p&gt;

&lt;p&gt;Check it out: &lt;a href="https://github.com/ethantao14/cline-stock-market-game" rel="noopener noreferrer"&gt;https://github.com/ethantao14/cline-stock-market-game&lt;/a&gt;&lt;/p&gt;

</description>
      <category>stockmarket</category>
      <category>ai</category>
      <category>coding</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
