Skip to content

Naut1cal5/stockMarketSimulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Stock Market Simulation

A Bloomberg-style trading terminal that runs an entire artificial financial market in your browser β€” 50+ securities, options, futures, ETFs, AI-driven institutional banks, a procedural news engine, and a quant-grade price model β€” all simulated in real time, entirely in-memory.

No server, no real money, no market data feed. Every price, every order, every headline is generated locally by the simulation engine.

Trading terminal preview


What it is

You're handed a pile of capital (anywhere from $1M to $1T) and dropped into a live, breathing market. Trade equities, options, futures, and ETFs against algorithmic bots and rival AI investment banks β€” or go full market-maker: publish your own news, manipulate sentiment, take out loans, buy insider information (and risk getting caught), and even acquire a rival bank and run its book.

It's part trading simulator, part financial sandbox, part chaos engine.


Features

The market

  • 50+ securities across 8 sectors (Technology, Healthcare, Energy, Financials, Consumer Discretionary, Industrials, Real Estate, Communications), each with its own price, shares outstanding, beta, dividend yield, and P/E.
  • ETFs (sector and broad-market) priced from their underlying constituents.
  • Futures contracts.
  • Full options chain β€” calls & puts across multiple strikes/expiries, priced with a Black-Scholes-style model and live greeks (delta, gamma, theta, vega).
  • Level-2 order book with generated bid/ask depth.

Trading

  • Market, limit, and stop-loss orders.
  • Short selling, margin, and leverage (selectable multipliers).
  • Real-time portfolio: cash, open positions, unrealized & realized P&L, win rate, and an equity curve.
  • Watchlist / favorites and a multi-tab blotter (positions, orders, news).

The world reacts

  • Procedural news engine with 9 event categories β€” earnings, Fed decisions, geopolitical shocks, sector rotations, macro prints, company events, black-swan events, meme runs, and commodity moves β€” each with severity, sentiment, affected tickers, decay duration, and generated analyst quotes.
  • Algorithmic bot traders (momentum, mean-reversion, etc.) whose collective order flow actually moves prices.
  • Rival AI investment banks that trade their own multi-billion-dollar books β€” and which you can lend to, hedge against, or take over.
  • Market halts / circuit breakers when things get violent.

"God mode" powers

  • Publish your own headlines to swing sentiment and move targeted tickers.
  • Buy insider information β€” with a real chance of getting caught.
  • Issue loans to banks (with interest, accrual, and default risk).
  • Three difficulty modes: Realistic (slippage + margin rules), God Mode (no restrictions), and Chaos Mode (god mode + 3Γ— event frequency + 5Γ— volatility).

The simulation engine

This is the heart of the project β€” a genuinely quantitative price model, not random walks slapped on a chart.

Each tick, every security's return is computed from a blend of:

  • Geometric Brownian Motion with jump diffusion β€” per-stock drift and volatility scaled by beta, plus rare large "jump" events.
  • Sector correlation β€” an 8Γ—8 correlation matrix so related sectors move together.
  • Market sentiment β€” a global mood that decays toward neutral over time.
  • Order-flow price impact β€” net buying/selling pressure (from you and the bots) pushes prices, normalized by each stock's liquidity/market cap and clamped to prevent runaway feedback loops.
  • Mean reversion β€” an anchoring pull toward each security's fair value that strengthens the further price strays.

Returns are hard-clamped per tick to keep the market stable over long sessions. From the resulting moves the engine generates realistic OHLC candles and volume, and computes technical indicators on the fly: RSI, SMA, EMA, ATR, and Bollinger Bands.

The clock runs on a configurable main tick plus a 200 ms micro-tick (β‰ˆ5 updates/second) so prices animate smoothly between ticks. Hot market state lives in refs to avoid React re-render thrashing under that update rate.


Getting started

You'll need Node.js 18+ (for npm).

# clone
git clone https://github.com/Naut1cal5/stockMarketSimulation.git
cd stockMarketSimulation

# install dependencies
npm install

# run the dev server (Vite β€” usually http://localhost:5173)
npm run dev

Open the URL Vite prints, pick your starting capital, mode, tick speed, and number of stocks on the setup screen, and start trading.

Other scripts

npm run build     # production build into dist/
npm run preview   # preview the production build
npm run lint      # run ESLint

Project structure

src/
β”œβ”€β”€ App.jsx                 # main orchestrator β€” tick loop, order routing, portfolio, bank AI
β”œβ”€β”€ main.jsx                # React entry point
β”œβ”€β”€ index.css               # global styles
β”œβ”€β”€ data/
β”‚   └── stocks.js           # securities universe, sectors, correlation matrix, bots & banks
β”œβ”€β”€ engine/
β”‚   β”œβ”€β”€ market.js           # price model (GBM + jumps), candles, indicators,
β”‚   β”‚                       #   options pricing, order books, ETF pricing, bot/bank AI
β”‚   └── news.js             # procedural news & event generator
└── components/
    β”œβ”€β”€ SetupScreen.jsx     # capital / mode / tick-speed / stock-count configuration
    β”œβ”€β”€ TradingPanel.jsx    # order entry, quote, options chain
    β”œβ”€β”€ Watchlist.jsx       # securities list + favorites
    β”œβ”€β”€ BottomPanel.jsx     # positions / orders / news / bank & god-mode controls
    └── Charts.jsx          # candlestick chart, sparklines, formatters, toasts

Tech stack

  • React 19 + Vite 8
  • Tailwind CSS 4
  • Recharts & D3 for charting
  • Lodash utilities
  • ~3,600 lines of application code; zero backend β€” the entire market lives in memory.

Disclaimer

This is a simulation for entertainment and educational purposes only. Every company, ticker, price, and news event is fictional and procedurally generated. It is not financial advice, not connected to any real market or data feed, and involves no real money.

πŸ“„ License

MIT

About

πŸ“ˆ A Bloomberg-style stock market simulation β€” 50+ securities, options, futures, AI banks, a procedural news engine, and a quant price model (GBM + jump diffusion), all running in-memory. React 19 + Vite.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages