和顺 / 衡律 返回所属 Agent
10.8

数值内核与精确复算

原能力

提供可精确复算的数值执行,固定代码、参数、输入和计算精度。(合同附件 R7 10.8)

首选项目

Qlib(MIT)。 Qlib

匹配范围

可比较数值算子和测试夹具。

源码

Qlib · class Rolling(

qlib/data/ops.py · 713–726 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
class Rolling(ExpressionOps):
    """Rolling Operator
    The meaning of rolling and expanding is the same in pandas.
    When the window is set to 0, the behaviour of the operator should follow `expanding`
    Otherwise, it follows `rolling`

    Parameters
    ----------
    feature : Expression
        feature instance
    N : int
        rolling window size
    func : str
        rolling method
  • # Copyright (c) Microsoft Corporation.

Qlib · class LocalExpressionProvider(

qlib/data/data.py · 835–848 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
class LocalExpressionProvider(ExpressionProvider):
    """Local expression data provider class

    Provide expression data from local data source.
    """

    def __init__(self, time2idx=True):
        super().__init__()
        self.time2idx = time2idx

    def expression(self, instrument, field, start_time=None, end_time=None, freq="day"):
        expression = self.get_expression_instance(field)
        start_time = time_to_slc_point(start_time)
        end_time = time_to_slc_point(end_time)
  • # Copyright (c) Microsoft Corporation.

实现与验收要点

规定计算序、精度和独立逐项参考,精确复算证明。