<?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: Krishna Jha</title>
    <description>The latest articles on DEV Community by Krishna Jha (@kosmoscpp).</description>
    <link>https://dev.to/kosmoscpp</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%2F3987249%2F4f5792ae-ab72-4bfd-a772-3725786c6a55.jpg</url>
      <title>DEV Community: Krishna Jha</title>
      <link>https://dev.to/kosmoscpp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kosmoscpp"/>
    <language>en</language>
    <item>
      <title>My port of Python SemVer to Golang for my First Hackathon</title>
      <dc:creator>Krishna Jha</dc:creator>
      <pubDate>Tue, 11 Aug 2026 03:18:28 +0000</pubDate>
      <link>https://dev.to/kosmoscpp/my-port-of-python-semver-to-golang-for-my-first-hackathon-11o4</link>
      <guid>https://dev.to/kosmoscpp/my-port-of-python-semver-to-golang-for-my-first-hackathon-11o4</guid>
      <description>&lt;h2&gt;
  
  
  Porting python-semver to Go on a phone, an old PC, and 41 hours
&lt;/h2&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%2Fkxsxjekp4ri0612efoex.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%2Fkxsxjekp4ri0612efoex.jpg" alt="building the go semver live and doing a 5k fuzzing test" width="800" height="448"&gt;&lt;/a&gt;&lt;br&gt;
I'm Krishna, 18, in Class 12 prepping for JEE. When PORT MORTEM 2026 showed up, I didn't have a laptop for it. What I had was a Samsung A05 with Termux, and an old Core 2 Duo PC running Linux Mint Xfce that I could only get to the next morning.. But I really wanted to participate in a Hackathon, So my plan became: start on the phone doing whatever needs zero compute, move to the PC once I could sit at it, and don't pick a repo that punishes me for being resource constrained.&lt;/p&gt;

&lt;p&gt;I picked python-semver. It parses and compares version strings like 1.2.3-alpha.1. No I/O, no state, just numbers and string rules.. It was also easy to understand, i.e. easy to get what this even does. The hackathons own examples pointed at node-semver as a good target for exactly this reason, python-semver is basically its Python sibling, and Python is the language I actually know well from every other project I've built.&lt;/p&gt;

&lt;p&gt;Track: Open Pair, since Python to Go isn't one of the official pairings.&lt;/p&gt;

&lt;p&gt;I did created the folder and all from my phone and used git from Termux to push the folder and asked Claude for what will I need to do, to prove the fuzzing and how to make a hashmap(my first time doing so!), after getting that, i added it to the push, also i generated that Personal Access Token (PAT) for 30 days, copied it and pinned it into my clipboard.&lt;br&gt;
The next day, i did my first fuzzing test, then something broke..&lt;/p&gt;
&lt;h3&gt;
  
  
  What actually broke
&lt;/h3&gt;

&lt;p&gt;I built a differential fuzz harness in Python that generates random and adversarial version strings, feeds them into both the real python-semver and my compiled Go binary, and diffs the results. First real run at 5000 cases came back with 5 mismatches. All of them involved a version where patch was 0 ;)&lt;/p&gt;

&lt;p&gt;Turned out to be a bug in my own test harness, not the port. I'd set omitempty on the numeric JSON fields in the Go bridge, and omitempty silently drops any field equal to its zero value, including a legitimately zero patch number. So the bridge would send no "patch" field at all instead of "patch": 0, and my Python side read the missing key as None, which obviously didn't match 0. Removed omitempty from the numeric fields, reran, 0 mismatches ;)&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%2Fyk9kt9toijbxes12h9kd.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%2Fyk9kt9toijbxes12h9kd.jpg" alt="README.md Entry about the real bug, also the 5k fuzzing test on top" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next one was a real bug. bump_build("8.35.21+V00") gave "V1" in my Go port but "V01" in python-semver. The original preserves the zero padded width when incrementing a numeric identifier inside a string, mine just parsed the digits to an int and reformatted plain, losing the padding. Fixed it by padding the result back to the original digit width instead of doing a plain integer to string conversion. Reran at 5000 cases, then again across a handful of different seeds to make sure it wasn't a one off. Stayed at 0 (Phew).&lt;/p&gt;
&lt;h3&gt;
  
  
  The mistake I had almost shipped
&lt;/h3&gt;

&lt;p&gt;Part of this hackathon's rule is you hash the original repo's test suite at the start so nobody can quietly edit the tests to make their port pass. I did that on day one, but I cloned the default branch instead of pinning to a released version. Meanwhile my fuzz harness was running against whatever pip install semver actually gives you, which is the last published release, not main.&lt;/p&gt;

&lt;p&gt;For most of the functions I ported this didn't matter because the code was identical between main and the release. It only became visible once I started porting next_version,which was not even in the original plan btw, but I decided to do it..which had been rewritten on main and wasn't in the published release yet. My hand traced expected output didn't match what pip's semver actually returned, and diffing the two sources side by side showed exactly why!&lt;/p&gt;

&lt;p&gt;Fixed it by checking out the actual release tag (3.0.4) in my local clone, recomputing the test suite hash against that pinned commit, and updating the README to reference the correct commit hash. Everything I'd already fuzzed before that point was still valid since none of that logic had changed between main and the release, but the citation in my README was wrong until I caught it.&lt;/p&gt;
&lt;h3&gt;
  
  
  The decision I'd take back
&lt;/h3&gt;

&lt;p&gt;Hashing against main instead of a pinned release tag on day one. It cost me nothing in the end because I caught it before submitting, but it easily could have been the kind of inconsistency a judge notices and starts poking at. Lesson learned: always pin to an actual release, never a moving branch, when you're making a provenance claim.&lt;/p&gt;
&lt;h3&gt;
  
  
  What I cut on purpose
&lt;/h3&gt;

&lt;p&gt;I didn't port match(), the range syntax thing like &amp;gt;=1.0.0 &amp;lt;2.0.0. It's basically its own small parser, meaningfully more scope than everything else combined, and I'd rather ship something fully proven than something bigger with an unfuzzed corner. I did end up adding next_version() later since it turned out to just be composition of functions I'd already ported and proven, so the risk to add it was low.&lt;/p&gt;
&lt;h3&gt;
  
  
  Where it landed
&lt;/h3&gt;

&lt;p&gt;Parse, compare, all three bump functions, bump_prerelease, bump_build, finalize_version, next_version, is_valid, all ported and passing differential fuzzing against the real python-semver 3.0.4 across roughly 30,000 generated cases and multiple random seeds, 0 mismatches on the final build. &lt;br&gt;
And guess what?, it's 3.1x faster in parsing and a 363x faster in Comparing! (Ik it might be due to python being python and golang being golang, but ain't it amazing?)&lt;/p&gt;

&lt;p&gt;I didn't had a mic for my PC, I had two options (for making the video), use DroidCam to record while speaking, but my PC setup is near street, so it would be noisy.. or (the one I did) Record audio somewhere quiet (it didn't came out that much quiet though), play it and start recording with it.&lt;/p&gt;

&lt;p&gt;Repo's here: &lt;a href="https://github.com/kosmoscpp/port-semver-go" rel="noopener noreferrer"&gt;https://github.com/kosmoscpp/port-semver-go&lt;/a&gt;&lt;br&gt;
Video:&lt;br&gt;
&lt;a href="https://youtu.be/SYA3pwTXHAw?si=gstEMU4o_qNAHDY9" rel="noopener noreferrer"&gt;https://youtu.be/SYA3pwTXHAw?si=gstEMU4o_qNAHDY9&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tagging Hackathon Raptors 🦖&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__4002660"&gt;
    &lt;a href="/partnerships_raptors" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=150,height=150,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4002660%2F01625488-66e5-458e-8aca-2d72445b0c9d.jpg" alt="partnerships_raptors image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/partnerships_raptors"&gt;Raptor&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/partnerships_raptors"&gt;We're the Hackathon Raptors Association, hosting regular #hackathons aimed at improving quality of life 🦖&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>dohackathon</category>
      <category>python</category>
      <category>go</category>
    </item>
    <item>
      <title>I Built a Real-Time Indian Stock Market Simulator in Python — Here's How 📊</title>
      <dc:creator>Krishna Jha</dc:creator>
      <pubDate>Tue, 16 Jun 2026 10:59:15 +0000</pubDate>
      <link>https://dev.to/kosmoscpp/i-built-a-real-time-indian-stock-market-simulator-in-python-heres-how-4kh6</link>
      <guid>https://dev.to/kosmoscpp/i-built-a-real-time-indian-stock-market-simulator-in-python-heres-how-4kh6</guid>
      <description>&lt;p&gt;You know that feeling when you want to learn stock trading but don't want to risk actual money? Or when you want to test a trading strategy without losing your savings? That's exactly what inspired me to build &lt;strong&gt;NSE Live Terminal&lt;/strong&gt;—a full-featured paper trading simulator for Indian stocks, and I'm making it open-source for everyone.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is NSE Live Terminal?
&lt;/h2&gt;

&lt;p&gt;NSE Live Terminal is a &lt;strong&gt;real-time stock market simulation dashboard&lt;/strong&gt; where you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🛒 Execute market buy/sell orders on 12 major Indian stocks&lt;/li&gt;
&lt;li&gt;📊 Watch live intraday charts powered by Plotly&lt;/li&gt;
&lt;li&gt;💼 Track your portfolio with real-time P&amp;amp;L calculations&lt;/li&gt;
&lt;li&gt;🏆 Compete on a live leaderboard with other traders&lt;/li&gt;
&lt;li&gt;⚡ Get data refreshed every 15 seconds automatically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The best part?&lt;/strong&gt; You start with ₹1 Crore (10 million rupees) in virtual cash—plenty to experiment!&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I Built This
&lt;/h2&gt;

&lt;p&gt;Paper trading is &lt;em&gt;criminally&lt;/em&gt; underrated. Most people dive into real stock trading without practicing first. But there's a disconnect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Traditional paper trading apps are boring or behind paywalls&lt;/li&gt;
&lt;li&gt;You don't get real-time data for Indian stocks&lt;/li&gt;
&lt;li&gt;Building your own means you actually &lt;em&gt;understand&lt;/em&gt; how markets work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I decided to build one that's &lt;strong&gt;modern, interactive, and free&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Tech Stack (It's Simpler Than You Think)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Frontend: Streamlit (Python UI framework)
Database: SQLite3 (Local file-based DB)
Data Source: Yahoo Finance (yfinance SDK)
Charting: Plotly
Deployment: Railway (Docker containerized)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why these choices?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Streamlit:&lt;/strong&gt; Zero frontend knowledge required. Deploy in 5 minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SQLite:&lt;/strong&gt; No backend server. Perfect for projects that don't need scaling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;yfinance:&lt;/strong&gt; Free real-time stock data for NSE instruments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plotly:&lt;/strong&gt; Beautiful, responsive charts with minimal code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Railway:&lt;/strong&gt; Dead simple Docker deployment with a free tier.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Core Features Breakdown
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1️⃣ Authentication (Clean &amp;amp; Simple)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# User enters nickname + 4-digit PIN
# Auto-creates account on first login
# All data stored locally in SQLite
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No email verification nonsense. Just pick a username and PIN. Instant access.&lt;/p&gt;

&lt;h3&gt;
  
  
  2️⃣ Live Trading Engine
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Real-time price from yfinance
# Buy/Sell execution with balance validation
# Auto-calculates average buy price
# Instant P&amp;amp;L computation
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you buy stocks, the app automatically calculates your average cost basis. When you sell, it updates your portfolio and shows you profit/loss instantly.&lt;/p&gt;

&lt;h3&gt;
  
  
  3️⃣ The 12-Stock Universe
&lt;/h3&gt;

&lt;p&gt;We track these major Indian blue-chips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tech:&lt;/strong&gt; TCS, Infosys&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Banking:&lt;/strong&gt; HDFC Bank, ICICI Bank, SBI&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Energy/Infra:&lt;/strong&gt; Reliance Industries, Adani Ports, NTPC&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto:&lt;/strong&gt; Maruti Suzuki, M&amp;amp;M&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consumer:&lt;/strong&gt; ITC, Hindustan Unilever&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why just 12? Focus &amp;gt; chaos. These are the most liquid, most traded stocks on NSE—perfect for learning.&lt;/p&gt;

&lt;h3&gt;
  
  
  4️⃣ Real-Time Charts
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# 5-minute interval data over last 5 days
# Plotly automatically crops to tight boundaries
# No flat lines, no empty space
# Updates every 15 seconds
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The charts use tight autoscaling so you actually see the volatility. No boring flat lines that waste screen space.&lt;/p&gt;

&lt;h3&gt;
  
  
  5️⃣ Portfolio Dashboard
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Quantity held&lt;/li&gt;
&lt;li&gt;Average buy price (weighted)&lt;/li&gt;
&lt;li&gt;Current market price&lt;/li&gt;
&lt;li&gt;Current value&lt;/li&gt;
&lt;li&gt;Unrealized P&amp;amp;L (green if profit, red if loss)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At a glance, you know exactly how your portfolio is doing.&lt;/p&gt;

&lt;h3&gt;
  
  
  6️⃣ Live Leaderboard
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Net Worth = Cash + Value of Stock Holdings
# Rankings update in real-time
# Compete with friends / colleagues
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everyone starts with ₹1 Crore. Who can grow it the most? Create a friendly competition!&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started (3 Steps)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Clone &amp;amp; Install
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/kosmoscpp/paper-trading.git
&lt;span class="nb"&gt;cd &lt;/span&gt;paper-trading
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Run Locally
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit &lt;code&gt;http://localhost:8501&lt;/code&gt; and start trading.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Deploy (Optional)
&lt;/h3&gt;

&lt;p&gt;Want to share it with friends? Deploy to Railway in 2 minutes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Push your repo to GitHub&lt;/li&gt;
&lt;li&gt;Connect Railway to your GitHub account&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;Dockerfile&lt;/code&gt; config&lt;/li&gt;
&lt;li&gt;Deploy&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(Or use my live version: &lt;a href="https://paper-trader-kosmos.up.railway.app/" rel="noopener noreferrer"&gt;https://paper-trader-kosmos.up.railway.app/&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Under the Hood: How It Works
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Database Schema
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Users table&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;pin&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;balance&lt;/span&gt; &lt;span class="nb"&gt;REAL&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- Portfolio table&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;portfolio&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;ticker&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="nb"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;avg_price&lt;/span&gt; &lt;span class="nb"&gt;REAL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ticker&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Super simple. Two tables. That's it.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Trading Engine
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# When you BUY:
&lt;/span&gt;&lt;span class="mf"&gt;1.&lt;/span&gt; &lt;span class="n"&gt;Validate&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;have&lt;/span&gt; &lt;span class="n"&gt;enough&lt;/span&gt; &lt;span class="n"&gt;cash&lt;/span&gt;
&lt;span class="mf"&gt;2.&lt;/span&gt; &lt;span class="n"&gt;Deduct&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;
&lt;span class="mf"&gt;3.&lt;/span&gt; &lt;span class="n"&gt;Add&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="nf"&gt;portfolio &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;update&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;already&lt;/span&gt; &lt;span class="n"&gt;own&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mf"&gt;4.&lt;/span&gt; &lt;span class="n"&gt;Recalculate&lt;/span&gt; &lt;span class="n"&gt;weighted&lt;/span&gt; &lt;span class="n"&gt;average&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;

&lt;span class="c1"&gt;# When you SELL:
&lt;/span&gt;&lt;span class="mf"&gt;1.&lt;/span&gt; &lt;span class="n"&gt;Check&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;own&lt;/span&gt; &lt;span class="n"&gt;enough&lt;/span&gt; &lt;span class="n"&gt;shares&lt;/span&gt;
&lt;span class="mf"&gt;2.&lt;/span&gt; &lt;span class="n"&gt;Add&lt;/span&gt; &lt;span class="n"&gt;cash&lt;/span&gt; &lt;span class="n"&gt;back&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;balance&lt;/span&gt;
&lt;span class="mf"&gt;3.&lt;/span&gt; &lt;span class="n"&gt;Reduce&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;portfolio&lt;/span&gt;
&lt;span class="mf"&gt;4.&lt;/span&gt; &lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;L&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;calculated&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;fly&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Background Data Sync
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Every 15 seconds:
&lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;each_stock&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;STOCK_DICT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;fetch_live_price_from_yfinance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;cache_in_session_memory&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This background loop keeps your charts fresh without hammering Yahoo Finance's API.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned Building This
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Streamlit is ridiculously fast for MVPs.&lt;/strong&gt; Went from zero to deployed in a weekend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SQLite scales further than you think.&lt;/strong&gt; For paper trading with 50+ users? Totally fine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Real-time charting matters.&lt;/strong&gt; When charts update live, trading feels &lt;em&gt;real&lt;/em&gt;. Psychological engagement is everything.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cache strategically.&lt;/strong&gt; Don't hit the API every second. Cache + periodic refresh is the sweet spot.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;UX &amp;gt; Features.&lt;/strong&gt; A clean authentication screen and readable tables beat 50 features nobody uses.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Next Steps / Roadmap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;📈 &lt;strong&gt;Advanced charts:&lt;/strong&gt; Candlestick patterns, technical indicators (RSI, MACD)&lt;/li&gt;
&lt;li&gt;🏅 &lt;strong&gt;Achievements:&lt;/strong&gt; Badges for milestones (first 1M profit, etc.)&lt;/li&gt;
&lt;li&gt;💬 &lt;strong&gt;Social features:&lt;/strong&gt; Comment on trades, share portfolio&lt;/li&gt;
&lt;li&gt;📱 &lt;strong&gt;Mobile app:&lt;/strong&gt; React Native wrapper&lt;/li&gt;
&lt;li&gt;🤖 &lt;strong&gt;Strategy backtester:&lt;/strong&gt; Upload your strategy, backtest it historically&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Bigger Picture
&lt;/h2&gt;

&lt;p&gt;This project isn't just about paper trading. It's about &lt;strong&gt;making financial literacy accessible&lt;/strong&gt;. Stock market knowledge shouldn't be behind paywalls or require intimidating setup. &lt;/p&gt;

&lt;p&gt;With an open-source simulator:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Students&lt;/strong&gt; learn how markets actually work&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traders&lt;/strong&gt; practice strategies risk-free&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developers&lt;/strong&gt; see a real full-stack example&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Communities&lt;/strong&gt; (like Indian Dev communities) get a shared learning tool&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Live App:&lt;/strong&gt; &lt;a href="https://paper-trader-kosmos.up.railway.app/" rel="noopener noreferrer"&gt;https://paper-trader-kosmos.up.railway.app/&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/kosmoscpp/paper-trading" rel="noopener noreferrer"&gt;https://github.com/kosmoscpp/paper-trading&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;(Might be down now!)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No signup. No BS. Just pick a username, set a PIN, and start trading with ₹1 Crore.&lt;/p&gt;

&lt;p&gt;Have feedback? Found a bug? &lt;strong&gt;PRs welcome!&lt;/strong&gt; This is open-source—contributions make it better for everyone.&lt;/p&gt;




&lt;h3&gt;
  
  
  Questions?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;How do you build a Streamlit app? Check the &lt;code&gt;app.py&lt;/code&gt;—it's heavily commented&lt;/li&gt;
&lt;li&gt;How does the database work? Two simple tables—look at the schema&lt;/li&gt;
&lt;li&gt;How do you deploy? Docker config is included&lt;/li&gt;
&lt;li&gt;Why this stack? See my "Tech Stack" section above&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drop a comment below or open an issue on GitHub. Let's build this together! 🚀&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy trading, and may your P&amp;amp;L be green!&lt;/strong&gt; 📈&lt;/p&gt;

</description>
      <category>python</category>
      <category>fintech</category>
      <category>opensource</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
