{"record":{"id":"a599f04ec99c825a","repo":"microsoft/qlib","slug":"the-rolling-window-size-of-kurtosis-operation-shou","errorCode":null,"errorMessage":"The rolling window size of Kurtosis operation should >= 5","messagePattern":"The rolling window size of Kurtosis operation should >= 5","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/data/ops.py","lineNumber":947,"sourceCode":"class Kurt(Rolling):\n    \"\"\"Rolling Kurtosis\n\n    Parameters\n    ----------\n    feature : Expression\n        feature instance\n    N : int\n        rolling window size\n\n    Returns\n    ----------\n    Expression\n        a feature instance with rolling kurtosis\n    \"\"\"\n\n    def __init__(self, feature, N):\n        if N != 0 and N < 4:\n            raise ValueError(\"The rolling window size of Kurtosis operation should >= 5\")\n        super(Kurt, self).__init__(feature, N, \"kurt\")\n\n\nclass Max(Rolling):\n    \"\"\"Rolling Max\n\n    Parameters\n    ----------\n    feature : Expression\n        feature instance\n    N : int\n        rolling window size\n\n    Returns\n    ----------\n    Expression\n        a feature instance with rolling max\n    \"\"\"","sourceCodeStart":929,"sourceCodeEnd":965,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/ops.py#L929-L965","documentation":"Raised by the Kurt rolling operator (qlib/data/ops.py) when its window size N is nonzero and N < 4 — the code condition is 'N != 0 and N < 4' while the message says '>= 5'. The strict statistical minimum for kurtosis is 4 points, so N=4 passes the code check despite the message text; the message is slightly inaccurate upstream. N=0 (expanding window) is allowed.","triggerScenarios":"Building expressions like Kurt($close, 3), Kurt($close, 2), or Kurt($close, 1). Raised at expression construction time, before data loading.","commonSituations":"Window-size sweeps starting too low; copying the Skew minimum (3) when using Kurt, which needs at least 4; confusion caused by the error message demanding '>= 5' while the check actually allows N=4.","solutions":["Use N >= 4 (the message suggests 5; N=4 passes the check but 5+ is a safer convention for meaningful kurtosis).","Use N=0 for an expanding all-history window.","Exclude N in {1,2,3} from generated window candidates."],"exampleFix":"# before\nexpr = \"Kurt($close, 3)\"\n\n# after\nexpr = \"Kurt($close, 5)\"  # N >= 4 required by code; message recommends >= 5","handlingStrategy":"validation","validationCode":"if N != 0 and N < 4:\n    raise ValueError(\"Kurt window must be 0 (expanding) or >= 4 (5+ recommended)\")","typeGuard":"def is_valid_kurt_window(n: int) -> bool:\n    return n == 0 or n >= 4","tryCatchPattern":null,"preventionTips":["Use per-operator minimum window maps when generating expression sweeps.","Remember N=0 means expanding window in qlib, not 'no window'."],"tags":["qlib","expression","rolling","validation"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}