和顺 / 衡律 返回所属 Agent
10.4

有限算子集与调用签名

原能力

实现规定的有限算子及调用签名,逐项核对参数、维度和失败语义。(合同附件 R7 10.4)

首选项目

Qlib(MIT)。 Qlib

匹配范围

已定位 ops.py 的算子与参数实现,可逐算子对照。

源码

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 Ref(

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

源码片段
class Ref(Rolling):
    """Feature Reference

    Parameters
    ----------
    feature : Expression
        feature instance
    N : int
        N = 0, retrieve the first data; N > 0, retrieve data of N periods ago; N < 0, future data

    Returns
    ----------
    Expression
        a feature instance with target reference
  • # Copyright (c) Microsoft Corporation.

实现与验收要点

R7 允许签名、类型、窗口、拒绝和错误语义。