和顺 / 衡律 返回所属 Agent
9.4

区间位置和价格偏离

原能力

实现区间位置和价格偏离计算,不通过隐藏填充制造有效结果。(合同附件 R7 9.4)

首选项目

Qlib(MIT)。 Qlib

匹配范围

滚动 Max、Min、Ref 可表达位置和价格偏离。

源码

Qlib · class Max(

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

源码片段
class Max(Rolling):
    """Rolling Max

    Parameters
    ----------
    feature : Expression
        feature instance
    N : int
        rolling window size

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

Qlib · class Min(

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

源码片段
class Min(Rolling):
    """Rolling Min

    Parameters
    ----------
    feature : Expression
        feature instance
    N : int
        rolling window size

    Returns
    ----------
    Expression
        a feature instance with rolling min
  • # 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.

实现与验收要点

区间位置原公式、跳空缺失、实际可得时间与初值。