Leo’s Build Log
PostsProjectsAbout한국어

FINCH

A personal AI investing assistant built on your portfolio

Screens

Overview

Period
Aug – Sep 2026 (6 weeks)
Team
5 people
Role
AI lead

The problem

Prices, news and filings in stock apps are the same for everyone, so you have to work out what they mean for your own portfolio. The goal: personalized information based on your holdings and trades, without the LLM making up numbers or giving investment advice.

The approach

  1. 01
    Numbers come from a calculation engineReturns, weights and P&L are computed by an engine. The AI writes sentences with markers where those values go.
  2. 02
    Answers are checked before they go outTen checks cover numbers, sources and buy/sell advice. A failed answer is regenerated, and dropped if it fails again.
  3. 03
    The AI only reads account dataOnly the backend changes account data. The AI uses a read-only internal API.
  4. 04
    Answers show their sourcesNews and filings are collected daily, and the ones used in an answer are attached as footnotes.

Architecture

ArchitectureClientIngressServicesDataExternaluses the web UIstaticAPIrelays AI requestsreads ledger via internal APIPrice feed
React webVite · TanStack Query
Capacitor shelliOS · Android
Traefik IngressProd cluster · Kubernetes
Frontendnginx · static pages
BackendKotlin · Spring Boot · ledger, prices
AIFastAPI · explain, brief, risk
PostgreSQLLedger · stocks
RedisLive prices
AI DBPrice history · pgvector
KIS OpenAPI
KRX · DART · NAVER
LLM
  1. 01
    Separation of dutiesNumbers and risk calls = Kotlin engine; explanation = LLM
  2. 02
    Single ledgerBalances and P&L are computed only from deposit and trade records
  3. 03
    Data collectionCalls focused on held, watched and recently viewed stocks

User scenario

User scenarioUserSystemEvidence pathyes · engine resultsno
User
Sign up₩1M virtual cash
Explore stocksSearch · daily · live prices
Paper buy · sellOrders at real prices
Check portfolioTotal assets · P&L
Ask the AIBriefing · risk check
Price feedKIS · Redis
Ledger entryDeposits · fills (PostgreSQL)
Calc engineReturns · concentration · risk
LLM explanationWith sources
Numeric question?
Look up filings · newsKRX · DART · NAVER
  1. 01
    User flowSign up → explore → paper trading → portfolio → ask the AI
  2. 02
    System flowPrice collection → ledger → calculation engine → LLM explanation
  3. 03
    Separation of dutiesThe engine decides numbers and risk, the LLM explains — the AI never changes the ledger

My work

  1. 01
    Number substitutionThe LLM writes only allowed keys and the server fills in engine values, so no uncomputed number can reach an answer.The LLM writes allowed keys like {{return_005930}}; the server substitutes engine values (+2.48%) · responses split into text/number segments
  2. 02
    Ten output checksNumbers, sources and banned phrases are checked; a failing answer is regenerated with the reason attached and blocked if it fails again.Raw numbers · engine mismatch · citation integrity · banned phrases · schema, and more
  3. 03
    Tool-using chat agentPicks the lookup tools a question needs (account, returns, prices, news, filings) and answers only from what they return.Tool selection → narration · 7 tools in parallel, max 3 turns / 12 calls · job queue (Postgres SKIP LOCKED)
  4. 04
    News and filing collection and searchScheduled collection of news, filings and prices, searched as evidence for answers and the daily briefing.Naver News · DART filings → chunking · embeddings (text-embedding-3-small) → pgvector + lexical search, RRF fusion
  5. 05
    Test-driven developmentChecks, number substitution and tool calls were defined as tests first, then implemented. Golden tests on a fixed portfolio catch calculation regressions.pytest · golden tests · 708 tests

Why these tools

numpy · pandasErrors in financial figures generated by the LLMReturns and risk calls fixed by deterministic computation
LLM APICost of resending the full prompt on every requestCached fixed prefix; only the explanation is generated
FastAPIExposing the AI server would break the auth boundaryInternal calls only, behind the backend
PostgreSQLPrice and stock data depended on the backendLoaded directly into a DB owned by the AI part
pydantic-settingsDevelopment blocked until the backend ledger API was readyOne setting switches between seed data and the backend ledger

Improvements

  1. 01
    Answers that only said "could not be confirmed"Found and fixed the root cause: depending on how the account was read, numbers never reached the AI.
  2. 02
    Slow chat answersSwitched models, turned off reasoning in the tool-picking step and had tools called together to cut the wait.
  3. 03
    Guards blocking good answersCounted why answers were blocked in production and fixed the top cause: sentences split wrongly around footnotes.
  4. 04
    A polluted experimentFailed responses left in the cache were hiding the A/B comparison; experiments now bypass the cache.

Related posts