{"record":{"id":"aa38a107f6508c64","repo":"HKUDS/Vibe-Trading","slug":"embargo-fraction-must-be-in-0-1-got-embargo-f","errorCode":null,"errorMessage":"embargo_fraction must be in [0, 1), got {embargo_fraction}","messagePattern":"embargo_fraction must be in \\[0, 1\\), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/crossvalidation.py","lineNumber":247,"sourceCode":"            label is assumed to resolve within its own bar, so purging removes\n            only the boundary and the embargo does the remaining work.\n        n_folds: Number of folds, at least :data:`MIN_FOLDS`.\n        embargo_fraction: Fraction of the sample embargoed after each test block.\n\n    Yields:\n        One :class:`Split` per fold, in chronological order of the test block.\n\n    Raises:\n        ValueError: If ``n_folds`` is below :data:`MIN_FOLDS`, exceeds the\n            sample size, if ``embargo_fraction`` is negative or at least 1, or\n            if ``label_end_times`` does not match the sample.\n    \"\"\"\n    if n_folds < MIN_FOLDS:\n        raise ValueError(f\"n_folds must be at least {MIN_FOLDS}, got {n_folds}\")\n    if n_samples < n_folds:\n        raise ValueError(f\"{n_samples} samples cannot make {n_folds} folds\")\n    if not 0.0 <= embargo_fraction < 1.0:\n        raise ValueError(\n            f\"embargo_fraction must be in [0, 1), got {embargo_fraction}\"\n        )\n\n    if label_end_times is None:\n        label_ends = np.arange(n_samples)\n    else:\n        label_ends = _as_label_spans(label_end_times, n_samples)\n\n    embargo_size = int(round(n_samples * embargo_fraction))\n    boundaries = np.linspace(0, n_samples, n_folds + 1).astype(int)\n\n    for fold in range(n_folds):\n        start, stop = int(boundaries[fold]), int(boundaries[fold + 1])\n        if stop <= start:\n            continue\n        test_mask = np.zeros(n_samples, dtype=bool)\n        test_mask[start:stop] = True\n","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/crossvalidation.py#L229-L265","documentation":"embargo_fraction must lie in [0, 1); it is the fraction of the sample embargoed after each test block. Values below 0 or >= 1 (including 1.0) are rejected because the embargo size is computed as a fraction of n_samples and 1.0 would drop the entire training set.","triggerScenarios":"Calling purged_kfold_splits (or the group variant) with embargo_fraction=1.0, a negative value, or a percentage like 5 instead of 0.05.","commonSituations":"Config expressed in percent (5 meaning 5%) passed directly, copying embargo in bars instead of fraction, or floating-point drift reaching exactly 1.0.","solutions":["Convert percent to fraction: divide by 100","If you need an embargo of N bars, pass N / n_samples (and verify it stays < 1)","Validate config: assert 0.0 <= embargo_fraction < 1.0 at load time"],"exampleFix":"// before\nsplits = list(purged_kfold_splits(X, n_folds=5, embargo_fraction=5, label_end_times=le))\n// after\nsplits = list(purged_kfold_splits(X, n_folds=5, embargo_fraction=5/100, label_end_times=le))","handlingStrategy":"validation","validationCode":"assert 0.0 <= embargo_fraction < 1.0, 'embargo_fraction must be a fraction in [0,1)'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store embargo as a fraction, never percent, in configs","Convert bar counts: embargo_fraction = n_bars / n_samples"],"tags":["crossvalidation","argument-validation","embargo","quantlib"],"backgroundTag":"fraction-out-of-range","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}