🎯 Try it now → https://naklitechie.github.io/PredictionMarket/
A browser-native educational simulator demonstrating how prediction markets work. Control 4 simulated players to explore two market mechanisms: Parimutuel and LMSR (Logarithmic Market Scoring Rule).
- All players place bets into a shared pool
- Winning bets split the entire pool proportionally
- Payout formula:
stake × (total_pool / total_on_winning_side) - Simple one-off betting market
- Continuous market with dynamic prices
- Each trade immediately affects the odds
- Cost function:
C(q) = b × ln(exp(q_yes/b) + exp(q_no/b)) - Price formula:
p_yes = exp(q_yes/b) / (exp(q_yes/b) + exp(q_no/b)) - Configurable liquidity parameter
b
- 4 simulated players (A, B, C, D) controlled by one operator
- Binary yes/no markets with optional labeled outcomes
- Real-time updates of odds, prices, and balances
- Clear resolution and payout calculation
- Trade/bet history tracking
# Clone or download this repo
# Option 1: Python
python3 -m http.server 8000
# Option 2: Node.js
npx serve .
# Option 3: Just open index.html directly in your browserThen visit http://localhost:8000
Works on any static host:
- GitHub Pages
- Netlify
- Vercel
python3 -m http.server
No build step, no dependencies, no API keys.
| Player | Outcome | Stake |
|---|---|---|
| A | YES | $100 |
| B | YES | $200 |
| C | NO | $150 |
- Total Pool: $450
- YES Total: $300, NO Total: $150
- If YES wins: YES bettors split $450 → each $1 gets $1.50 back
- Player A: $100 × 1.5 = $150 returned (+$50 profit)
- Player B: $200 × 1.5 = $300 returned (+$100 profit)
- Player C: $0 returned (-$150 loss)
Starting state: q_yes = 0, q_no = 0, b = 100
-
Player A buys 10 YES shares
- Cost: ~$5.12 (calculated via LMSR cost function)
- New state:
q_yes = 10,q_no = 0 - New P(YES): ~0.525
-
Player B buys 20 NO shares
- Cost: ~$10.95
- New state:
q_yes = 10,q_no = 20 - New P(YES): ~0.422
-
Resolution: If YES wins, each YES share redeems for $1
- Player A: 10 shares × $1 = $10 (bought for $5.12 → +$4.88 profit)
- Player B: 0 shares redeem (bought NO shares) → -$10.95 loss
Edit these values in the code or UI:
// Number of players (hardcoded to 4 in v1)
// To change: modify lmsrState.players object
// Initial cash per player (LMSR mode)
initialCash: 1000 // Line ~600
// LMSR liquidity parameter
b: 100 // Lower = more volatile prices, Higher = more stable
// Default stake/share amounts
// Adjust in the HTML input defaults| Concern | Solution |
|---|---|
| Framework | None (vanilla JS) |
| Styling | Inline CSS (dark theme) |
| State Management | In-memory JavaScript objects |
| Build Step | None |
| Dependencies | Zero |
Coloured with bauhaus-10 · 1933 CLOSED — the closing of the Dessau Bauhaus on 11 April 1933 and the diaspora that followed (Chicago, Tel Aviv, Harvard, Black Mountain). Pure black, signal-yellow ink, primary-red NO vs primary-blue YES. Manifesto severity, fitting for a market where every position is a declaration.
Palette pulled from Rangrez, the global colour-palette library that backs all NakliTechie projects.
browser-prediction/
├── index.html # Single-file app (markup + styles + logic)
├── README.md # This file
├── ideas.md # Series vision document
└── LICENSE
- Economics classes: Demonstrate market mechanics without real money
- Workshops: Show how prediction markets aggregate information
- Product demos: Explain Polymetier, Augur, or similar platforms
- Personal learning: Experiment with different trading strategies
- ❌ No real money or wallets
- ❌ No authentication or multi-user networking
- ❌ No advanced order types (limit orders, shorts)
- ❌ No fees or regulatory compliance
- ❌ Not production-ready for real betting
This is purely an educational simulator.
MIT — See LICENSE file.
| Tool | What it does |
|---|---|
| BabelLocal | Offline translation — 200 languages, NLLB model |
| StripLocal | EXIF metadata stripper — nothing leaves the browser |
| GambitLocal | Chess vs Stockfish — correspondence mode via URL |
| VoiceVault | Audio transcription — Whisper, offline-first |
| KingMe | English draughts — custom minimax AI, zero deps |
| SnipLocal | Background remover — RMBG-1.4, passport mode |
| Clacker | Split-flap display — browser-native, offline |
| Strait Command | Mine-clearing game in strategic waterways |
| Chokepoint | Maritime tower defense — hold the strait |
| PredictionMarket | Prediction market simulator — Parimutuel & LMSR |
| PDFLOcal | PDF editor — merge, split, rotate, annotate |
| RangeLocal | Missile range simulator — interactive globe & map |
| 3D Tic-Tac-Toe | 3D tic-tac-toe — 3×3×3 to 5×5×5, minimax AI |
Built by Chirag Patnaik