Skip to content

Payshak/stockreplay

Repository files navigation

StockReplay

Pick any stock. Get dropped into a random moment in its history. Trade through it without knowing what's coming.

Live Demo →

StockReplay is a historical trading simulator that tests your instincts against real market data. You get a random window from a stock's past — no dates, no headlines, just price action — and trade through it one day at a time. When the window closes, the reveal shows exactly when you were trading and how you performed against buy-and-hold.


How It Works

  1. Search any of 67 supported tickers (AAPL, TSLA, NVDA, GME, and more)
  2. Choose difficulty — Beginner (12–20 weeks), Intermediate (8–14 weeks), Expert (6–10 weeks)
  3. Read the Market Briefing — a vague sentiment hint with no spoilers
  4. Trade — the chart reveals one day at a time; buy, hold, or sell
  5. The Reveal — find out exactly when you were trading, what you missed, and how you rank

Dates are hidden throughout. You see only price action and candlestick patterns.


Features

  • No API key required — data via yfinance (Yahoo Finance)
  • 67 tickers across Technology, Finance, Healthcare, Energy, Meme stocks, and more
  • Candlestick charts powered by Plotly — dark theme, zoom, pan, keyboard nav
  • Featured scenarios — NVDA's AI run, GME's short squeeze, AAPL's iPhone era, and more
  • Trade by shares or dollar amount — Max Buy and Sell All shortcuts
  • Real-time P&L — cash, unrealized gains, total portfolio value
  • Full reveal screen — buy/sell markers on the actual chart + final rating
  • Local leaderboard (SQLite, no account required to play)
  • Rate limiting and session hardening built in
  • Sound effects via Web Audio API (toggleable)
  • Mobile responsive

Keyboard Shortcuts

Key Action
Space Play / Pause auto-advance
N Next day
B Focus buy input
S Focus sell input

Running Locally

Requirements: Python 3.9+

git clone https://github.com/Payshak/stockreplay.git
cd stockreplay
pip install -r requirements.txt

Create a .env file (or set env vars directly):

# Generate with: python -c "import secrets; print(secrets.token_hex(32))"
FLASK_SECRET=your-secret-key-here

Then run:

python app.py

Open http://localhost:5000.


Deploying

Railway

Set FLASK_SECRET and FLASK_HTTPS=1 in your Railway project environment, then connect the repo. The Procfile and railway.toml are already included.

Anywhere else

Standard Flask app — runs on any Python host. Set FLASK_SECRET and optionally PORT (default 5000) and FLASK_HTTPS=1 for production.


Supported Tickers

67 tickers across 10+ sectors:

Sector Tickers
Technology AAPL, MSFT, GOOGL, META, NVDA, AMD, INTC, QCOM, AVGO, TSM, ASML, CRM, ADBE, ORCL
E-Commerce / Consumer AMZN, SHOP, EBAY, ETSY, COST, WMT, TGT, HD
Finance JPM, BAC, GS, MS, V, MA, PYPL, SQ, BRK-B
Media / Streaming NFLX, DIS, SPOT, SNAP, PINS
EV / Transport TSLA, RIVN, LCID, F, GM, UBER, LYFT, ABNB
Healthcare JNJ, PFE, MRNA, BNTX, UNH
Energy XOM, CVX, OXY
Meme / Notable GME, AMC, BB, NOK
Other BABA, NIO, PLTR, COIN, RBLX, ZM, PTON, HOOD, SPY, QQQ

Project Structure

stockreplay/
├── app.py              # Flask routes and session logic
├── game_engine.py      # Scenario selection, scoring, chart data
├── stock_data.py       # Yahoo Finance fetching + 12h cache
├── requirements.txt
├── Procfile            # Railway / Heroku deployment
├── railway.toml
├── static/
│   ├── style.css
│   └── ui_helpers.js
└── templates/
    ├── base.html
    ├── index.html      # Search + featured scenarios
    ├── setup.html      # Difficulty selection
    ├── briefing.html   # Pre-simulation briefing
    ├── simulation.html # Trading interface
    └── results.html    # Reveal + leaderboard

Contributing

PRs are welcome.

  • New tickers: Add entries to STOCK_META in stock_data.py
  • New featured scenarios: Add entries to FEATURED_SCENARIOS in game_engine.py
  • Bug reports: Open an issue with steps to reproduce and your Python version

License

MIT — see LICENSE

About

Historical stock trading simulator — pick any stock, get dropped into a random moment in its past, trade without knowing what's coming

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors