Evan SunLet's connect
Selected Work

Simulation-first investing application

Idiot Finance

Explore portfolio choices with virtual money, explicit calculations, and clear recovery paths when prices or saved state are incomplete.

Simulation application · Case-study demonstration
TypeScriptReact / Next.jsFinancial calculationsState management
Illustrative Idiot Finance investing simulation with synthetic portfolio and market data

Illustrative demo · Synthetic data

The problem

Idiot Finance lets a learner explore preset and custom ETF portfolios with virtual money. The application makes allocation, review, transaction state, and historical research understandable while keeping calculations and failure handling explicit.

An investing simulation loses credibility if duplicate clicks change the balance twice, edited weights rewrite an existing position, or missing prices quietly become a convincing chart. The interface and financial state need to agree.

Preset and custom portfolios share a simulation engine. A browser-local practice account and a read-only historical research path have different purposes and calculation rules.

How it works

  1. 01

    Preset / custom definition

  2. 02

    Review + state revisions

  3. 03

    Read-only market / synthetic adapter

  4. 04

    Precise simulation engine

  5. 05

    Versioned browser state + recovery

From input to output

  1. 01Define a preset or a valid custom allocation, with weights and versions made explicit.
  2. 02Capture a reviewable virtual transaction before fetching eligible market observations.
  3. 03Recheck account and definition revisions, calculate the complete basket, and persist one account update.
  4. 04Keep historical price simulations read-only, expose missing coverage, and validate backups before replacing saved state.

Data sources

  • Deterministic synthetic prices in the isolated offline demonstration
  • Read-only Alpaca market bars and calendar endpoints in the configured market-data path
  • Versioned portfolio definitions and browser-local simulation records

Technical approach

  • Integer cents, scaled prices and units, BigInt arithmetic, and explicit rounding for virtual transactions
  • Immutable definition snapshots and request IDs for reproducible account actions
  • Web Locks and revision checks for browser-local coordination
  • Separate historical price-only calculations with explicit source coverage
  • Validated migration and backup restore with a fresh storage generation

What you can inspect

  • Preset and custom portfolio simulation
  • Review screens and virtual transaction receipts
  • Holdings and allocation views tied to saved definitions
  • Historical price-only comparison with visible data gaps
  • Local backup and restore workflow
  • An existing position keeps the definition used when it was created; editing a draft creates a separate version.
  • An accepted duplicate command returns its prior receipt rather than creating a second virtual transaction.
  • Incomplete historical coverage withholds unsupported full-period metrics, and research does not spend practice cash.

The deliverable is an investing simulation whose account changes and chart limitations can be inspected. The engineering evidence is in the arithmetic, state transitions, and rejected operations.

Idiot Finance virtual-order review shown with synthetic account and price data
Illustrative demo · Synthetic data. A review step precedes a virtual account update.

Where this is useful

  • Shows how financial domain rules become precise application behavior.
  • The same state and validation patterns are relevant to internal tools that must preserve a consistent record through retries and recovery.

Checks & engineering decisions

Verification evidence

  • Reviewed unit-test sources exercise allocation rounding, no-money-creation rules, command identity, definition snapshots, and backup validation.
  • Existing release artifacts separately record unit/API checks, browser scenarios, synthetic fixtures, and limited provider observations. Historical results are not represented as newly executed portfolio tests.
  • The displayed account and prices are synthetic. They demonstrate UI and state behavior, not investment performance.

Key decisions

  • Keep virtual execution arithmetic separate from read-only historical research calculations.
  • Commit the whole virtual basket or reject it; a partial account update is not a completed transaction.
  • Pin a position's definition so later draft edits cannot rewrite its history.
  • Keep stale and missing market coverage visible, and withhold metrics that lack sufficient data.
  • Validate saved state before restore and use a new storage generation to reject stale in-flight actions.

A transaction carries its state boundary

typescript
type Command = {
  requestId: string;
  roundId: string;
  expectedRevision: number;
  portfolioId: string;
  type: "buy" | "sell";
  amountCents: number;
  definitionVersion: number;
  positionId: string | null;
  draftId?: string;
  draftRevision?: number;
};

The implemented command includes an identity, account revision, and definition version so confirmation can be checked against the state that was reviewed.

Role & status

Personal product and application development with AI coding assistance. The scope shown here includes the simulation experience, portfolio calculations, versioned account state, data-gap handling, and review of unit and browser evidence.

AI coding tools assisted development. The case presents implementation and verification artifacts, not a claim that all code was written independently or that simulated gains are a personal investment track record.

Simulation application · Case-study demonstration Source review: 2026-10-14.

Limitations

  • This is a virtual-investing application; it does not place real securities orders or provide personalized investment advice.
  • Guest account state is local to the browser and is not secure custody or a multi-user account service.
  • Historical research is price-only; corporate-action support is bounded and does not establish complete total-return modeling.
  • The portfolio uses an illustrative synthetic-data view. No public product endpoint or public source repository is linked.

Explore the evidence

Source review: portfolio engine and store, architecture, research backtest, backup policy, and release verification artifacts. Existing release evidence is historical; no market-data calls or project tests were run for the portfolio source review.