FinScientist
AI Scientist for Empirical Finance
- MSc dissertation · University of Edinburgh
- Python
- SQLite
- Docker
- OpenAI API
Overview
On low signal-to-noise financial data, a contaminated AI-Scientist pipeline runs as smoothly as a correct one, so it is easy to mistake provenance (every number traces to code that ran) for validity (the number is econometrically true).
FinScientist enforces provenance by construction: the paper writer never sees a result value, and code injects every number from an append-only ledger. It tests validity separately, with four gates and three negative controls around a network-isolated sandbox.
How it works
The stages of a run
The orchestrator runs the stages in this order, and each one is generative (LLM), deterministic (CODE) or both (HYB).
01 Literature + ideas
- 01literatureHYB
- 02claimsLLM
- 03gapsLLM
- 07lit auditruns before 04LLM
- 04ideasLLM
- 05selectionloops with 04, max 3LLM
- 06noveltyHYB
- 07bnovelty gateHYB
02 Design + feasibility
- 08designLLM
- 09feasibility · Gate 0loops with 08, max 5 · freezes the designHYB
03 Code + execution
- 10plannerLLM
- 11codewriter + evaluator models, static checks, sandboxed testsHYB
- 12apre-gatesCODE
- 13stagingthe only networked stageCODE
- 14executionsandboxCODE
- 12bpost-gates · Gate 1+ negative controlsCODE
04 Adjudication
- 15adjudicatorHYB
- 15beconomic · Gate 2CODE
05 Writing + package
- 16writerplaceholders onlyLLM
- 17reviewthree reviewersLLM
- 18revisionloops with 17, up to 3 roundsLLM
- 19injection · Gate 3CODE
- 19breview panelfour referees + meta-reviewerHYB
- 20packageHYB
- LLM · generative · dashed
- CODE · deterministic · solid
- HYB · both
- LLM · generative · dashed
- CODE · deterministic · solid
- HYB · both
- loop back
01 Literature + ideas
Read papers, mine gaps, pick an idea. 04 and 05 loop at most three times.02 Design + feasibility
Gate 0 runs in 09 and freezes the design by SHA-256. 08 and 09 loop at most five times.03 Code + execution
A writer model and an evaluator model produce the code; 12a scans it for leakage. 13 is the only networked stage. 14 runs the sandbox; 12b checks what it wrote.04 Adjudication
Statistics in code, narrative by an LLM. 15b is Gate 2 (economics).05 Writing + package
Placeholders, up to three review rounds, then 19 injects the numbers (Gate 3). Four referees read the injected paper; 20 packages the run.
How numbers reach the paper
The model that writes the paper never handles a result: code puts every number in, and a number with no ledger row cannot reach the PDF.
- LLM · generative · dashed
- CODE · deterministic · solid
- HYB · both
01 Execution appends
Each run writes a manifest of content hashes, then its results. A result with no manifest is refused.02 Append-only
Triggers abort every UPDATE and DELETE. A correction is a new row that supersedes the old one.03 Placeholders
The writer gets no result values. Where a number belongs it writes\RESULT{run_id.metric}.04 Digit scan
A numeral in the abstract or a result section rejects the draft; the writer gets three attempts.05 Injection
19 fills each placeholder from the ledger. One with no ledger row fails the build and returns to 16.
Gates and negative controls
Four gates sit at the seams around a sandbox with no network, and three negative controls should find nothing when the harness is clean. On a live run the stale-shift control fired (DM statistic 2.688, p = 0.0036) and the run was marked invalid.
- LLM · generative · dashed
- CODE · deterministic · solid
- HYB · both
01 Gate 0 · design
Inside 09, before the design is frozen: can this design answer its question with the data it names?02 Before the sandbox
12a scans the code for leakage and checks the embargo and encoder cutoffs. 13 is the only networked stage.03 The sandbox
No network, read-only code and data, one writable folder, images pinned by digest. The three controls run here too.04 After the sandbox
Gate 1 checks the numbers are real before the controls are tested (one-sided DM, α = 0.01). Gate 2 checks economics, Gate 3 the paper.05 On failure, by default
A failing gate goes back to the coder, up to five times. Then it stands down: the run continues and the failure becomes a required limitation.
The poisoned pipeline
The controls were tested against a leak planted on purpose; switch the synthetic control off to see what the rest of the pipeline let through.
A look-ahead leak planted by hand: the realised target blended 50/50 into every forecast, inside the accepted code. The checks below run in pipeline order.
Synthetic control on: the control fires and the run is marked invalid before drafting.
01 · 12a
Static scan
30 files clean
Evaded02 · 12b
As-of audit
160 records clean
Clean03 · 12b
Shuffled control
p = 1.0
Blind04 · 12b
Stale-shift control
p = 1.0
Blind- Fired
05 · 12b
Synthetic control
p ≈ 0
Run
Invalid · aborted before draftingThe control fires and the run stops at 12b. Nothing downstream runs, and no paper is written.DM statistic · dm_baseline_01
−21.52Clean run: a loss. With the control on, the poisoned run never reaches this test.15 · Adjudicator
Not reached16 · Writer
Not reached19 · Injection
Not reached
What this doesn't cover
- Gates do not block by default. A failing gate goes back to the coder up to five times, then the run carries on and the failure is written into the paper as a limitation. Hard blocking needs a flag.
- The ledger is append-only and hashes each row, but the rows are not chained, so an edit made to the database file directly would go unnoticed.
- The writer never sees a result value, but it does see design numbers such as dates and seeds, and plain outcomes such as win, loss or tie against each baseline.
- The poisoned-pipeline experiment is one planted leak on one topic, and its numbers come from my revision notes rather than saved runs.