← projects

[Divergent Signal]

Quant + AI Research Terminal

A web terminal where the optimizer says how much to hold, the agents say why — and the rows that matter are where they disagree.

● EvolvingQuant & ResearchPersonalPythonPostgresSupabaseReactTypeScriptTanStack
01 /context

Every day my optimizer produces weights for Brazilian, US and crypto assets, and the agent pipeline writes a rating for each one. Both were files on disk; nobody could read them side by side.

02 /my role

Solo: data contracts, the runner that connects both systems, the Postgres schema and the React front end (started in an AI app builder, then developed locally).

03 /problem

Optimizers give weights with no narrative; agents give narrative with no sizing. Worse, an early version of the site showed things the system never produced — seeded debates, hard-coded rates — fatal for a product aimed at regulated advisors.

04 /how it works
  1. 01 · Runs as the core entity

    Each execution is a run: summary, optimizer result and one decision per asset. A run switcher in the top bar scopes every page, and the run id lives in the URL.

  2. 02 · Divergence as the hero signal

    An asset is flagged when the optimizer gives it at least 10% weight but the agents rate it Underweight or Sell. A conviction matrix (weight × rating) puts every asset in one of four quadrants.

  3. 03 · Binding contracts

    TypeScript types mirror the Python JSON field by field, so a backend change breaks the front-end build instead of rendering blanks.

  4. 04 · File-first, database as mirror

    Results are files per run, synced to Postgres behind read-only RLS. Reruns never overwrite history.

  5. 05 · Honesty gates

    A written list of what is real and what was fabricated. Seeded ratings, synthetic news and invented debates were removed from code and database; where there's no AI output yet, the page says “AI pending”.

05 /architecture
01
Optimizer → JSON
02
Batch runner (agents)
03
Decision files per run
04
Postgres mirror (read-only RLS)
05
Terminal + run switcher
06 /results
Real runs for three markets, each with a 2,000-point efficient frontier.
56 automated tests, lint, build and a 375 px mobile smoke test gate every change.
The fiction left the database with a backup and a rollback script kept outside the repo.
07 /what broke and what I changed
  • ! brokeThe app downloaded only the first 1,000 frontier points, so the chart was thinner than the run.

    → changedPaginated the query and checked the plotted count against the run's.

  • ! brokeThe hero card printed a Sharpe ratio under a “return %” label.

    → changedOne <Metric> component that carries the unit together with the value.

  • ! brokeSeed data looked like real AI output on public pages.

    → changedHonesty gates, deletion from code and database, and explicit empty states.

08 /related