QuantCode Model: Specializing Language Models for Executable Algorithmic Trading Code
cs.CL, cs.LG, q-fin.TR
Submitted: 2026-09-30
Updated: 2026-09-30
Comments: 16 pages, 2 figures, 6 tables
License: http://creativecommons.org/licenses/by/4.0/
The gist: Large language models are strong general-purpose code generators, but executable algorithmic trading remains a demanding specialization target: a model must translate a natural-language strategy
Terminology
Abstract
Large language models are strong general-purpose code generators, but executable algorithmic trading remains a demanding specialization target: a model must translate a natural-language strategy specification into correct program logic for a specialized trading framework, execute on historical data, produce trades, and remain semantically faithful to the request. We study two complementary mechanisms for specializing language models for this setting: continued pretraining on algorithmic-trading framework code and supervised fine-tuning (SFT) on agent-validated request-to-code pairs. Evaluation is centered on QuantCode-Bench, our 400-task benchmark for Backtrader strategy generation, together with a repository-level SWE-bench-like track. Continued pretraining improves single-turn Judge Pass from 41.5% to 47.5% for Qwen3.5-397B-A17B and from 27.8% to 33.0% for Qwen3.6-35B-A3B. SFT applied after continued pretraining yields a larger gain for Qwen3.6-35B-A3B, reaching 58.2% Judge Pass and 83.5% successful backtests; in agentic evaluation it raises first-turn success from 22.3% to 58.3% and final success after up to 10 turns from 47.5% to 79.5%. Continued pretraining alone improves first-turn agentic success but lowers final success after repair from 47.5% to 32.5%, consistent with degraded instruction following, whereas SFT improves both. We also identify a capability-retention failure: domain specialization degrades parser-conformant structured tool calling, and targeted recovery SFT restores tool-call formatting but not the base checkpoint's repository-level agent performance. The results show that framework-oriented pretraining, validated SFT, and explicit capability-retention evaluation address distinct failure modes in domain-specific executable code generation.
Sources
- QuantCode-Bench: A Benchmark for Evaluating the Ability of Large Language Models to Generate Executable Algorithmic Trading Strategies
- FINESSE-Bench: A Hierarchical Benchmark Suite for Financial Domain Knowledge and Technical Analysis in Large Language Models
- Qwen3 Technical Report
- GLM-5: from Vibe Coding to Agentic Engineering
- Don't Stop Pretraining: Adapt Language Models to Domains and Tasks
- Code Llama: Open Foundation Models for Code
- StarCoder 2 and The Stack v2: The Next Generation
- DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligence
- SWE-bench: Can Language Models Resolve Real-World GitHub Issues?
- An Empirical Study of Catastrophic Forgetting in Large Language Models During Continual Fine-tuning
- Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time
- Editing Models with Task Arithmetic
- Language Models are Super Mario: Absorbing Abilities from Homologous Models as a Free Lunch
- Arcee's MergeKit: A Toolkit for Merging Large Language Models
- OpenHands: An Open Platform for AI Software Developers as Generalist Agents
- Gorilla: Large Language Model Connected with Massive APIs
- Training Software Engineering Agents and Verifiers with SWE-Gym
Related papers
- Exploring Solution Divergence and Its Effect on Large Language Model Problem Solving
- Ishigaki-IDS-Bench: A Benchmark for Generating Information Delivery Specification from BIM Information Requirements
- Subliminal Steering: Stronger Encoding of Hidden Signals
- MedStruct-S: A Benchmark for Key Discovery, Key-Conditioned QA and Semi-Structured Extraction from OCR Clinical Reports
- The End of Transformers? On Challenging Attention and the Rise of Sub-Quadratic Architectures
- Untangling the Mechanisms of Misleading Context in Medical Question Answering