Stock Market Rookie Village is a native macOS trading simulation game that combines deterministic market generation, A-share-style rules, event-driven prices, and challenge scoring into a replayable local experience.
The project separates presentation, market generation, and trade settlement. The native SwiftUI app provides the multi-window terminal, while the Fastify backend owns authoritative quotes, positions, fees, events, challenges, and saves. SQLite persists the complete state of each game.
Players can advance the market freely in sandbox mode or enter fixed-day challenges that balance asset targets, maximum drawdown, and trade count. Every stock, price, news item, and event is fictional.
Each save stores its own market seed, regime, and difficulty snapshot. Price generation combines market sentiment, capital style, volume heat, sector rotation, stock volatility, event impact, and event-chain persistence, while applying 10% or 20% price-limit boundaries by board.
The K-line chart is drawn with SwiftUI Canvas and supports 1, 5, 15, 30, and 60-minute periods plus daily, weekly, and monthly views. Candles, MA5 / MA10 / MA20, volume, volume averages, price and time axes, the latest-price line, and crosshair readings are rendered together.
One-minute data only exposes bars reached by the simulation clock. Other intraday periods aggregate visible minute bars, while weekly and monthly views aggregate daily bars. Players can switch among 30, 45, and 60-bar ranges with pan, zoom, and playback controls.
The trading engine enforces 100-share lots, T+1, cash and sellable-position checks, commissions, stamp duty, and price-limit direction rules. SQLite transactions update accounts, positions, and trades together before recalculating market value, total assets, returns, and maximum drawdown.
Every order carries an idempotency key, so retries return the existing trade. Writes also verify expectedStateVersion, preventing stale windows from overwriting newer game state. The main terminal and separate position, order, and chart windows therefore share one authoritative state.
The game includes 20-day warm-up, 60-day beginner, and 120-day steady-growth challenges. Settlement combines asset targets, maximum drawdown, and minimum trade count into a score and S, A, B, or C rating. Difficulty adjusts challenge targets, while sandbox mode has no forced ending.
Multiple saves can be created, loaded, renamed, and deleted. The same content pack generates different market paths under different seeds, regimes, and difficulties while keeping each save reproducible for continued play and verification.
The native app's ObservableObject Store connects to the Fastify API. The backend domain layer owns market, order, portfolio, event, challenge, and save logic before persisting to local SQLite. The older React frontend remains a debugging surface rather than the default product.
Industries, stocks, market regimes, difficulties, and event templates live in CSV content packs. Startup validation checks headers, unique IDs, industry references, enum values, and minimum counts so content can expand without changing core trading code.