用高效算法加速高频金融数据的最近邻搜索,提升实时交易系统性能。
Fast Exact Nearest-Neighbor Learning for High-Frequency Financial Time Series

- 基于Mojo语言优化的SIMD k-d树,支持向量化计算与连续存储。
- 在8个数据集上比scikit-learn快17.5至43.5倍,且结果精确无偏差。
- 适合需低延迟、高吞吐的金融场景,如衍生品定价与风险控制。
随着股票、ETF、外汇、期权及高频交易流中市场数据量激增,金融AI系统的效率变得至关重要。本文以高频金融时间序列的精确最近邻学习为案例,展示基于Mojo的金融AI如何应对这一挑战。提出一种基于方差分割的Mojo SIMD k-d树,结合连续平铺缓冲存储与编译时向量化距离计算。在标准剪枝与实现成本假设下,该方法在固定标的、大样本量、中等维度场景中,渐近优于Mojo SIMD暴力法和scikit-learn的k-d树。实验表明,在x86和ARM64架构的8个金融数据集(最多277K训练样本)上,该方法相较scikit-learn k-d树在x86上提速17.5–21.6倍,相较暴力法在ARM64上提速28.1–43.5倍,同时保证输出完全准确。此外,利用Mojo的编译执行能力,基于额外决策树的隐含波动率定价模型可训练10倍更多期权数据,使看跌期权隐含波动率均方误差降低8.0%。这些结果确立了Mojo作为可扩展、生产就绪的金融AI栈,并为其他数据密集型领域提供高效AI基础。
原文摘要 · Abstract (English)
AI efficiency at scale is becoming critical in finance as market data volumes surge across equities, ETFs, FX, options, and high-frequency trading streams. This growth creates a core challenge for mature financial AI systems: models must learn from larger historical corpora while still meeting real-time latency constraints in trading, risk management, and derivative pricing. We use exact nearest-neighbor learning for high-frequency financial time series as a concrete case study to show that Mojo-based financial AI can address this challenge. We introduce a Mojo SIMD k-d tree with variance-based splitting, contiguous flat-buffer storage, and compile-time vectorized distance computation. We also provide a runtime result showing that, under standard pruning and implementation-cost assumptions, the Mojo SIMD k-d tree asymptotically dominates Mojo SIMD brute force and scikit-learn's k-d tree in the fixed-stock, large-$n$, moderate-dimensional regime. Empirically, across eight financial datasets on x86 and ARM64 with up to 277K training samples, the method achieves 17.5--21.6$\times$ speedup over scikit-learn's k-d tree on x86 and 28.1--43.5$\times$ over scikit-learn brute force on ARM64 equity/ETF datasets, while preserving exact outputs. Beyond nearest-neighbor inference, Mojo's compiled execution enables an Extra Trees-based implied-volatility pricing model to train on $10\times$ more options data, reducing put-IV RMSE by 8.0\%. These results position Mojo as a scalable, production-ready stack for financial AI and a promising foundation for efficient AI in other data-intensive fields. \keywords{Financial AI \and AI Efficiency \and Mojo \and SIMD \and K-D Trees \and KNN \and High-Frequency Trading \and Financial Time Series \and Scaling}
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。