I developed Quant Lab from my work on Team 166’s coding agent at Agenthon 2026. It is an open-source Python toolkit for financial analysis, portfolio simulation and independent numerical verification. I used it to study how transaction costs, trading frequency and position sizing affect a Bitcoin momentum strategy.
The four studies reuse previously examined Bitstamp BTC/USD data from 2020 to 2024. Each simulation uses the opening price of the first eligible minute with recorded trading volume as a proxy for an execution price. Fees and adverse slippage apply to each fill.
Momentum and benchmark performance
I compared two portfolios, each starting with $10,000. Daily momentum held BTC when the closing price exceeded its level 20 sessions earlier and held cash otherwise. The passive benchmark set its BTC weight annually to the proportion of past signals that were positive, then allowed the weight to drift.
50 basis points in fees and 10 in adverse slippage per fill. One basis point is 0.01%.
Base costs. Daily momentum underperformed the passive benchmark after transaction costs. Terminal wealth was $39,414 for momentum and $70,715 for passive BTC/cash.
| Measure | Momentum | Passive BTC/cash |
|---|---|---|
| Terminal wealth | $39,414 | $70,715 |
| Maximum drawdown | 71.82% | 53.52% |
| Fills | 188 | 5 |
Maximum drawdown is the largest percentage decline from a previous daily closing peak. The full comparison includes buy-and-hold BTC, FFT-filtered momentum and cash.
Compare other portfolios and drawdowns
Performance metrics for all five portfolios
All five portfolios
Scroll horizontally to see all measures. Use the arrow keys when the table has focus.
| Portfolio | Terminal wealth | Net return | Net Sharpe ratio | Maximum drawdown | Average BTC weight | Fills | Trading costs |
|---|---|---|---|---|---|---|---|
| Momentum | $39,414 | 294.14% | 0.825 | 71.82% | 57.69% | 188 | $33,621 |
| Passive BTC/cash | $70,715 | 607.15% | 1.166 | 53.52% | 62.52% | 5 | $177 |
| Buy and hold BTC | $129,705 | 1197.05% | 1.118 | 76.66% | 100.00% | 1 | $60 |
| FFT-filtered momentum | $14,183 | 41.83% | 0.373 | 70.28% | 34.26% | 150 | $16,222 |
| Cash | $10,000 | 0.00% | Undefined | 0.00% | 0.00% | 0 | $0 |
Average BTC weight is the mean share of portfolio value held in BTC at each daily close. Trading costs include fees and adverse slippage. The cash portfolio earned zero interest and had zero volatility, so its Sharpe ratio is undefined.
Month-end values for the selected portfolios (60 observations)
| UTC month end | Momentum | Passive BTC/cash |
|---|---|---|
| $12,644 1.81% drawdown | $11,649 1.13% drawdown | |
| $12,582 10.44% drawdown | $11,029 11.43% drawdown | |
| $12,582 10.44% drawdown | $9,397 24.53% drawdown | |
| $14,560 1.85% drawdown | $11,106 10.81% drawdown | |
| $14,254 15.54% drawdown | $11,741 5.71% drawdown | |
| $13,423 20.46% drawdown | $11,498 7.66% drawdown | |
| $15,979 5.32% drawdown | $13,221 0.00% drawdown | |
| $15,411 10.94% drawdown | $13,452 3.57% drawdown | |
| $15,584 9.94% drawdown | $12,772 8.44% drawdown | |
| $18,083 0.00% drawdown | $15,126 0.00% drawdown | |
| $25,784 0.00% drawdown | $19,684 0.00% drawdown | |
| $36,265 0.00% drawdown | $26,884 0.00% drawdown | |
| $39,016 23.30% drawdown | $29,127 12.42% drawdown | |
| $47,345 21.31% drawdown | $35,765 15.82% drawdown | |
| $55,055 8.50% drawdown | $43,195 2.94% drawdown | |
| $49,435 17.84% drawdown | $42,642 6.93% drawdown | |
| $37,542 37.60% drawdown | $31,431 31.40% drawdown | |
| $37,906 37.00% drawdown | $30,167 34.16% drawdown | |
| $40,866 32.08% drawdown | $33,707 26.43% drawdown | |
| $46,446 22.80% drawdown | $36,816 19.65% drawdown | |
| $39,687 34.04% drawdown | $34,994 23.63% drawdown | |
| $50,236 16.51% drawdown | $44,608 5.39% drawdown | |
| $48,802 18.89% drawdown | $42,202 12.10% drawdown | |
| $43,869 27.09% drawdown | $36,299 24.39% drawdown | |
| $42,385 29.55% drawdown | $32,740 31.80% drawdown | |
| $36,454 39.41% drawdown | $34,890 27.33% drawdown | |
| $32,335 46.26% drawdown | $35,963 25.09% drawdown | |
| $28,023 53.42% drawdown | $32,349 32.62% drawdown | |
| $27,838 53.73% drawdown | $29,654 38.23% drawdown | |
| $24,598 59.12% drawdown | $24,224 49.54% drawdown | |
| $25,769 57.17% drawdown | $25,782 46.30% drawdown | |
| $24,416 59.42% drawdown | $24,285 49.42% drawdown | |
| $21,299 64.60% drawdown | $23,995 50.02% drawdown | |
| $19,272 67.97% drawdown | $24,487 49.00% drawdown | |
| $17,878 70.29% drawdown | $22,960 52.18% drawdown | |
| $17,332 71.19% drawdown | $22,666 52.79% drawdown | |
| $23,685 60.63% drawdown | $27,625 42.46% drawdown | |
| $20,775 65.47% drawdown | $27,632 42.45% drawdown | |
| $22,707 62.26% drawdown | $31,668 34.04% drawdown | |
| $22,452 62.68% drawdown | $32,242 32.84% drawdown | |
| $21,503 64.26% drawdown | $30,718 36.02% drawdown | |
| $22,772 62.15% drawdown | $33,175 30.90% drawdown | |
| $22,522 62.57% drawdown | $32,239 32.85% drawdown | |
| $22,184 63.13% drawdown | $29,745 38.04% drawdown | |
| $21,599 64.10% drawdown | $30,527 36.42% drawdown | |
| $27,763 53.86% drawdown | $36,343 24.30% drawdown | |
| $30,213 49.78% drawdown | $38,655 19.49% drawdown | |
| $33,648 44.08% drawdown | $42,085 12.34% drawdown | |
| $30,734 48.92% drawdown | $42,227 12.04% drawdown | |
| $42,427 29.48% drawdown | $52,655 1.42% drawdown | |
| $42,294 29.70% drawdown | $58,330 1.73% drawdown | |
| $37,454 37.75% drawdown | $52,358 11.79% drawdown | |
| $35,730 40.62% drawdown | $56,195 5.33% drawdown | |
| $35,493 41.01% drawdown | $53,504 9.86% drawdown | |
| $37,450 37.76% drawdown | $54,589 8.04% drawdown | |
| $31,816 47.12% drawdown | $51,425 13.37% drawdown | |
| $30,515 49.28% drawdown | $53,855 9.27% drawdown | |
| $30,647 49.06% drawdown | $57,739 2.73% drawdown | |
| $42,085 30.05% drawdown | $72,430 1.95% drawdown | |
| $39,414 34.49% drawdown | $70,715 9.22% drawdown |
Execution timing and delayed-fill sensitivity
The baseline uses the first minute with recorded volume at or after 00:05 UTC following the signal. Bid–ask spreads, executable size and latency are unobserved.
The timing sensitivity uses the first eligible minute at or after 00:30 UTC, with the base fee of 50 basis points and slippage of 10 basis points. Terminal wealth was $41,120 for momentum and $70,676 for passive BTC/cash.
Daily study · Reproduce these results
Zielak (mczielinski), Bitcoin Historical Data, Kaggle v706, normalized by ff137. Adapted to UTC sessions, simulated portfolios and sampled month-end marks. Chart, tables and saved data under CC BY-SA 4.0.
I tested both the difference in subsequent BTC returns after positive versus nonpositive signals and the difference in net Sharpe ratio between the two portfolios. Both paired 95% intervals included zero. Evidence of a repeatable timing advantage was inconclusive. Paired estimates
Transaction-cost sensitivity
I increased fees and slippage in proportion to estimate how much trading cost daily momentum could absorb. Relative to passive BTC/cash, its advantage in net Sharpe ratio (return per unit of volatility after costs) disappeared at approximately 0.31× base costs. Its terminal wealth advantage persisted to 0.48×. These thresholds depend on the simulated cost assumptions. Cost study
Cost curves and numerical bounds
The base assumption is 50 basis points in fees and 10 in adverse slippage per fill. At the Sharpe crossover (0.3071×), the corresponding fee and slippage are 15.35 and 3.07 basis points. At the wealth crossover (0.4781×), they are 23.90 and 4.78 basis points.
| Momentum compared with | Numerical bounds | Estimate |
|---|---|---|
| Passive BTC/cash Net Sharpe ratio | 0.3070313× to 0.3071289× | 0.3070801× |
| Passive BTC/cash Terminal wealth | 0.4780273× to 0.4781250× | 0.4780762× |
| Buy-and-hold BTC Net Sharpe ratio | 0.4065430× to 0.4066406× | 0.4065918× |
| Buy-and-hold BTC Terminal wealth | No crossing detected | |
Buy-and-hold BTC had higher terminal wealth than momentum at every sampled cost. Their net Sharpe ratios crossed near 0.4066× base costs. Additional simulations narrowed the numerical bounds around each crossing. Crossings between sampled costs remain possible, and the study provides no statistical confidence interval for the thresholds. Frozen protocol · Replay checks
Zielak (mczielinski), Bitcoin Historical Data, Kaggle v706, normalized by ff137. Adapted to UTC sessions, simulated spot portfolios and a fee/slippage sensitivity analysis. Saved comparisons · CC BY-SA 4.0
Trading frequency
I compared daily and weekly decisions using the same momentum signal. At base costs, weekly execution reduced fills from 188 to 80 and increased terminal wealth relative to daily execution. The passive BTC/cash benchmark finished ahead of both momentum portfolios. Both paired 95% intervals for differences in net Sharpe ratio included zero, so neither comparison established a risk-adjusted advantage. Weekly study
Turnover, drawdowns and paired intervals
The weekly rule evaluated Sunday’s close and used the first eligible minute at or after 00:05 UTC on Monday for execution. One-way turnover fell from 187.44× to 79.76×. The two strategies held different positions at 292 daily closes, so trading frequency also changed their exposure to BTC.
| Weekly minus | Difference | Paired 95% interval |
|---|---|---|
| Passive BTC/cash | -0.261 | -0.828 to +0.259 |
| Daily momentum | +0.081 | -0.293 to +0.505 |
Weekly maximum drawdown was 73.34%, compared with 71.82% for daily momentum. Frozen protocol · Reference run · Package checks
Zielak (mczielinski), Bitcoin Historical Data, Kaggle v706, normalized by ff137. Adapted to UTC daily sessions, simulated spot portfolios and a weekly decision schedule. Source dataset · Saved weekly comparisons · CC BY-SA 4.0
Portfolio allocation
I compared a weekly 50% BTC target with a benchmark that invested half its initial capital in weekly momentum and kept the rest in cash. Restoring the target on positive-signal Mondays reduced maximum drawdown from 64.45% to 45.02% and terminal wealth from $29,343 to $25,335. The paired 95% interval for the drawdown reduction was +0.66 to +23.82 percentage points, conditional on the observed return paths. Allocation study
Drawdown, exposure and rebalancing costs
Both accounts began with $10,000. The target portfolio held cash after a nonpositive Monday signal and allowed its BTC weight to drift between decisions. The benchmark retained its initial cash reserve throughout.
| Measure | Monday target | Half-funded weekly |
|---|---|---|
| Maximum drawdown | 45.02% | 64.45% |
| Ending wealth | $25,334.67 | $29,342.96 |
| Average BTC weight | 29.65% | 44.09% |
| Fills | 194 | 80 |
| Fees and slippage | $4,897.88 | $8,347.87 |
The target portfolio rebalanced on 114 Mondays when the signal remained positive and the benchmark held its BTC position. The target traded more often but held less BTC on average and paid less in total fees and slippage.
The estimated drawdown reduction was 19.43 percentage points. The paired bootstrap resampled returns for full-size weekly momentum and the target portfolio on the same dates, then reconstructed the half-funded benchmark with its cash reserve intact. Frozen protocol · Accounting checks
Zielak (mczielinski), Bitcoin Historical Data, Kaggle v706, normalized by ff137. Adapted to UTC daily sessions, simulated spot accounts and weekly allocation comparisons. Source dataset · Saved allocation comparisons · CC BY-SA 4.0
Frequency-domain filtering
I used a fast Fourier transform (FFT) to estimate spectral entropy, a measure of how widely the variation in past returns was distributed across frequencies. The strategy took a positive momentum signal only when entropy was low. At base costs, the filter reduced both BTC exposure and net return relative to plain momentum. Original report · Compare all five portfolios
Spectral entropy and the training threshold
I calculated normalised spectral entropy over the previous 64 daily log returns. The threshold was the median across eligible windows in 2017–2019 and remained fixed throughout evaluation. At base costs, $10,000 ended at $14,183 with the filter and $39,414 without it. The implemented filter governs only the trading rule. Using spectral features to guide a coding agent remains an untested proposal.
The research catalogue documents 5 completed comparisons across 4 historical studies. Extension to other assets remains a proposal.
From Agenthon to Quant Lab
With Team 166, I investigated how reliably a code-generating agent could solve financial tasks. The agent ran Python in isolation and used execution feedback to make bounded repair attempts. In one trial, a repair produced all five required files, but the grader still found 13 failures in 35 numerical checks. Repair trial
In Quant Lab, I fixed the inputs and trading rules, recorded every simulated fill and independently reconstructed cash balances and holdings. This checks financial correctness separately from program execution. The Agenthon archive distinguishes a scripted test of output delivery from model trials, including a full 86-task evaluation and a ten-task evaluation. Architecture and attribution · Financial replay
Use the toolkit
Quant Lab provides a Python command-line interface for reproducing financial studies, pricing European options and analysing historical portfolios. The charts above show saved results from the four bundled Bitcoin studies. All four run offline after installation.
Install the package in an active Python 3.12+ virtual environment. Use a writable working directory and an internet connection for installation.
Set up a Python environment
With Python 3.12 installed, open a terminal in your working directory. Run the two commands for your shell.
macOS or Linux
python3.12 -m venv .venvsource .venv/bin/activateWindows PowerShell
py -3.12 -m venv .venv.\.venv\Scripts\Activate.ps1python -m pip install agenthon-quant-lab==0.5.0quant-lab doctorA ready status confirms that the required libraries and bundled data are available.
quant-lab btc-study --out runs/momentumThe study writes its results to runs/momentum. Open report.md for the findings or dashboard.html for the interactive comparison. Each run requires a fresh output directory, specified with --out. Package on PyPI · User guide
Reproduce the three follow-up studies
Trading costs
Estimate the costs at which momentum and passive BTC/cash have equal net Sharpe ratios or terminal wealth.
quant-lab btc-cost-break-even --out runs/costsOpen runs/costs/README.md.
Trading frequency
Compare turnover, drawdown and terminal wealth under daily and weekly decisions.
quant-lab btc-weekly-cadence --out runs/weeklyOpen runs/weekly/README.md.
Position sizing
Compare rebalancing to 50% BTC on positive Mondays with holding half the initial capital in a fixed cash reserve.
quant-lab btc-weekly-allocation --out runs/allocationOpen runs/allocation/README.md. Release and reproduction record
Use the optional Codex skill
The optional skill uses a separate source checkout to run studies and interpret reports in Codex. With Git and Python 3.12 installed, run these commands from the parent directory for the checkout.
git clone --branch v0.5.0 --single-branch https://github.com/hnt119/agenthon-quant-lab.gitcd agenthon-quant-labpython3.12 scripts/setup.py --install-skill.venv/bin/quant-lab doctorKeep the checkout in place. In a new Codex chat, ask “Use $quant-research to reproduce the daily Bitcoin study and explain how momentum compared with passive BTC/cash after costs.” Skill guide
Prospective research
The registered study compares the two allocation rules on new market observations over 52 weeks. Both simulated portfolios start with $10,000. One restores a 50% BTC target on positive-signal Mondays, while the other maintains a fixed $5,000 cash reserve. Each paper fill uses a subsequent Coin Metrics multi-market reference price. No real trades are executed.
Registered as of .
0 of 52 weekly cycles completed · 0 missed. No observations recorded. Prospective performance is unmeasured.
Public observation record · Current figures · Frozen protocol
Registration, schedule and endpoint
The observation period covers 30 Nov 2026 through 28 Nov 2027 (UTC sessions). After a missed cycle, both accounts retain their previous positions. The registration receipt was recorded . The first eligible signal cutoff is 30 Nov 2026 at 00:00 UTC (08:00 Singapore). The final Sunday session closes on 29 Nov 2027 at 00:00 UTC (08:00 Singapore).
Analysis is scheduled for 1 Dec 2027 at 03:00 UTC (11:00 Singapore). The primary endpoint is the difference in maximum drawdown measured from daily closing values. A missing daily close prevents reporting that endpoint. Interim account values are descriptive.
Reference prices from Coin Metrics Community Data, licensed under CC BY-NC 4.0. Agenthon Quant Lab records the paper accounts.
Other tools and records
The option explorer uses synthetic inputs. The toolkit guide also covers portfolio analysis with local historical prices and a separate example using synthetic trading data.
European option explorer
The Black–Scholes model prices European calls and puts with constant volatility, a continuously compounded risk-free rate and zero dividends. Prices are per unit of the underlying. Time to expiry is in years and volatility is annualised.
Call 10.4506 · Put 5.5735
Volatility scenarios
Prices at the base volatility and at ten percentage points above and below it, with all other inputs fixed.
| Volatility | Call | Put |
|---|---|---|
| 10.00% (-10 pp) | 6.8050 | 1.9279 |
| 20.00% (base) | 10.4506 | 5.5735 |
| 30.00% (+10 pp) | 14.2312 | 9.3542 |
Paper catalogue and experiment archive
Browse papers and experiments, or search by topic, result or record ID. Each entry links to its source.
Agentless — Staged software repair
Agentless separates fault localisation, patch generation and validation. Its design informed the separation of financial calculations from independent checks in Quant Lab. The project did not reproduce the paper’s repair agent.
AlphaCodium — Test-guided code generation
AlphaCodium combines structured problem analysis with repeated generation and execution of code against tests. This informed Quant Lab’s use of explicit specifications and recorded failures. Its financial studies use maintained implementations.
CRITIC — Revision through external feedback
CRITIC uses external tools to evaluate a model’s answer and guide revision. The Agenthon repair trials explored the narrower use of exception messages as feedback. They did not evaluate CRITIC itself.
LDB — Debugging with intermediate values
LDB compares intermediate program state with the task specification. In financial code, this could expose the first incorrect cash balance or discount factor. Such tracing remains proposed, beyond the exception diagnostics used in the repair trials.
ReAct — Reasoning, actions and observations
ReAct alternates reasoning with tool use and observation. An Agenthon submission used a bounded variant, but its aggregate score could not isolate the effect of that design. Quant Lab’s financial studies use deterministic calculations.
Reflexion — Feedback across trials
Reflexion records textual reflections on task feedback for use in later trials. It inspired the manual curation of verified failures and lessons in this archive. Automated reflective learning remains untested here.
RepoCoder — Iterative code retrieval
RepoCoder retrieves related repository code as a model generates a completion. It suggested retrieving relevant interfaces and utilities for a financial task. The project has not evaluated the paper’s retrieval method.
RepoGraph — Navigating code dependencies
RepoGraph represents relationships among code elements as a graph. This could help trace callers and dependencies in a larger financial library. Quant Lab uses explicit file references and has deferred graph construction.
Repoformer — Selective code retrieval
Repoformer trains a model to decide when additional repository context would help. That principle informed the research skill’s selective use of references. The skill uses a hand-curated index, and the learned policy remains untested.
CodeT — Ranking programs with generated tests
CodeT ranks candidate programs by agreement with generated tests. A program and its tests can share the same financial error, which motivates independently derived checks in Quant Lab. Candidate selection with generated tests remains deferred.
FITS — Frequency-domain forecasting
FITS learns a compact model for forecasting time series in the frequency domain. It inspired the use of spectral diagnostics in the Bitcoin study. That study evaluated a fixed entropy filter. The trained FITS forecaster remains untested here.
FAN — Frequency-adaptive forecasting
FAN models changing frequency components separately from the residual time series. It motivated examining trend and seasonality before using spectral features in a financial strategy. The project has not trained or evaluated FAN on market data.
Early direct-repair baseline
An archived competition score provided a baseline for the early direct-repair agent. The aggregate alone cannot identify which tasks passed or which design choices affected the score.
Designated competition baseline
The project owner reported an official aggregate of 0.2674 for this submission. A separate local evaluation measured how often the same candidate completed individual tasks.
Bounded reasoning and action in competition
An agent with a bounded reasoning-and-action loop passed preliminary synthetic checks but received a low reported competition score. The submission did not isolate the contribution of the loop.
Delivering outputs to a root-owned directory
A scripted control generated the correct answer in two writable directories with different owners. Copying file metadata failed in the root-owned directory. The failure isolated a delivery problem after calculation.
Truncation recovery pilot
In a pilot of recovery from truncated model output, the agent completed two of three selected tasks. None triggered the recovery step, leaving its effect unmeasured.
Diagnostic repair interrupted by a provider error
The trial tested whether a Python exception message could guide a repair. The model provider returned an error during the repair request. No output reached the grader.
Execution repair and trade accounting
The agent used an exception message to attempt a repair. The revised program produced all five required files, but 13 of 35 numerical checks failed. Independent checks on trade accounting exposed errors that successful execution had left undetected.
Full evaluation on the public task set
One fixed candidate passed 22 of 86 public tasks in a local evaluation using NVIDIA’s model service. Testing the full set with one candidate established a baseline for subsequent local evaluations.
Momentum ranking with implicit direction
The agent received instructions for ranking momentum signals on one selected task. It produced no accepted output, so the numerical checks never ran. The next trial stated the ranking direction explicitly.
Momentum ranking with explicit direction
With explicit ranking instructions, the agent passed all checks on the selected momentum task. Each trial used fresh model responses, so the difference cannot be attributed to the revised instructions alone.
Extreme-value input guidance
The trial clarified the inputs to an extreme-value estimator. The agent still produced no accepted output on the selected task, leaving the numerical method untested.
Complete extreme-value workflow
The next trial supplied a complete sequence of callable steps for the same extreme-value task. The agent passed all 55 checks. The evaluation covered that task alone.
Interface errors in tail-index estimation
This trial tested instructions for calling a tail-index estimator. The generated code raised type errors before its financial outputs could be evaluated, directing attention to the helper’s input contract.
Scalar inputs for tail-index estimation
The trial specified how the calling code should handle scalar inputs to the tail-index estimator. The revised candidate passed 33 checks on the selected task. Its performance across the full task set remains unmeasured.
Incomplete full-roster evaluation
A full-set evaluation tested several repairs in a single candidate. One response contained a nonfinite value and a second request timed out. The run stopped before an overall score could be measured.
Targeted evaluation of ten workflows
The trial evaluated concise task guidance on ten preselected workflows. The agent completed all ten. This establishes performance on the selected workflows only.
Proposed spectral inputs for a coding agent
The proposal would compare frequency-domain features with conventional time-series statistics as inputs to a coding agent. Whether these features provide useful additional information remains untested.
Daily momentum against a passive benchmark
This study tested the predictive value of 20-session BTC momentum and the cost of trading the signal. At base costs, momentum underperformed passive BTC/cash. Both paired intervals included zero, leaving the evidence for a timing advantage inconclusive.