QuantCode Model: Specializing Language Models for Executable Algorithmic Trading Code

📄 arXiv: 2609.39420v1 📥 PDF

作者: Alexey Chernysh, Orkhan Ekhtibarov, Dmitry Zmitrovich

分类: cs.CL, cs.LG, q-fin.TR

发布日期: 2026-09-30

备注: 16 pages, 2 figures, 6 tables


💡 一句话要点

提出QuantCode模型以解决可执行算法交易代码生成问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 算法交易 代码生成 语言模型 监督微调 继续预训练 金融科技 模型评估

📋 核心要点

  1. 现有的大型语言模型在生成可执行算法交易代码时面临挑战,尤其是在将自然语言策略转化为正确的程序逻辑方面。
  2. 本文提出通过在算法交易框架代码上进行继续预训练和在代理验证的请求到代码对上进行监督微调来专门化语言模型。
  3. 实验结果表明,继续预训练和SFT显著提高了Judge Pass率和成功回测率,尤其是SFT在多轮交互中表现出色。

📝 摘要(中文)

大型语言模型在代码生成方面表现出色,但可执行算法交易的需求使得这一领域成为一个复杂的专业化目标。本文研究了两种互补机制来专门化语言模型:在算法交易框架代码上的继续预训练和在经过代理验证的请求到代码对上的监督微调(SFT)。通过QuantCode-Bench基准评估,继续预训练显著提高了Judge Pass率,而SFT在继续预训练后进一步提升了成功率,显示出框架导向的预训练和验证的SFT能够有效解决领域特定代码生成中的不同失败模式。

🔬 方法详解

问题定义:本文旨在解决大型语言模型在生成可执行算法交易代码时的准确性和有效性问题。现有方法在将自然语言策略转化为程序逻辑时存在语义不一致和执行失败的风险。

核心思路:通过在特定的算法交易框架代码上进行继续预训练,结合经过验证的请求到代码对的监督微调,来提升模型在特定领域的生成能力和准确性。

技术框架:整体流程包括两个主要阶段:首先是继续预训练,使用大量的算法交易框架代码;其次是监督微调,利用代理验证的请求到代码对进行训练,以提高模型的生成质量和语义一致性。

关键创新:最重要的技术创新在于结合继续预训练和监督微调的双重机制,解决了领域特定代码生成中的能力保持失败问题,确保了工具调用格式的恢复。

关键设计:在继续预训练阶段,采用了特定的损失函数来优化模型在算法交易代码生成中的表现;在SFT阶段,设计了针对性的训练数据集,以提高模型在多轮交互中的成功率。实验中还注意到,继续预训练虽然提升了初始成功率,但可能导致最终成功率下降,因此SFT的设计尤为重要。

🖼️ 关键图片

img_0
img_1
img_2

📊 实验亮点

实验结果显示,继续预训练使得Qwen3.5-397B-A17B的Judge Pass率从41.5%提升至47.5%,而Qwen3.6-35B-A3B的Judge Pass率从27.8%提升至33.0%。在继续预训练后应用SFT,Qwen3.6-35B-A3B的Judge Pass率达到58.2%,成功回测率达到83.5%。多轮交互中,首次成功率从22.3%提升至58.3%,最终成功率从47.5%提升至79.5%。

🎯 应用场景

该研究的潜在应用领域包括金融科技、自动化交易系统和智能投资顾问等。通过提高算法交易代码生成的准确性和效率,QuantCode模型能够帮助金融机构更好地实现策略自动化,降低人工干预的需求,提升交易决策的速度和准确性。未来,该模型的技术可以扩展到其他领域的代码生成任务,具有广泛的应用前景。

📄 摘要(原文)

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.