QuantCode 模型:专用于可执行算法交易代码的语言模型

·

研究论文 · 2026/10/06

大型语言模型是强大的通用代码生成器,但可执行的算法交易仍是一个要求严苛的专业化目标:模型必须将自然语言策略规范转化为专用交易框架的正确程序逻辑,在历史数据上执行,产生交易,并保持对请求的语义忠实。我们研究了两种互补的机制来使语言模型专业化于此设置:在算法交易框架代码上进行持续预训练,以及在代理验证的请求到代码对上监督微调(SFT)。评估以QuantCode-Bench为中心,这是我们用于Backtrader策略生成的400任务基准,以及一个类似SWE-bench的仓库级轨道。持续预训练将Qwen3.5-397B-A17B的单轮Judge Pass从41.5%提高到47.5%,将Qwen3.6-35B-A3B的从27.8%提高到33.0%。在持续预训练后应用SFT对Qwen3.6-35B-A3B产生更大增益,达到58.2%的Judge Pass和83.5%的成功回测;在代理评估中,它将首轮成功率从22.3%提高到58.3%,并将最多10轮后的最终成功率从47.5%提高到79.5%。仅持续预训练提高了首轮代理成功率,但将修复后的最终成功率从47.5%降低到32.5%,这与指令遵循能力下降一致,而SFT则同时改善两者。我们还发现了一个能力保留失败:领域专业化降低了符合解析器的结构化工具调用,针对性的恢复SFT恢复了工具调用格式,但未恢复基础检查点的仓库级代理性能。结果表明,面向框架的预训练、验证的SFT和明确的能力保留评估解决了领域特定可执行代码生成中的不同失败模式。

该研究针对可执行算法交易代码生成这一专业领域,系统比较了持续预训练和SFT的效果,并揭示了能力保留问题,对领域特定代码生成模型的开发具有重要指导意义。

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.

阅读原文

参与讨论