{"record":{"id":"a9eafe6d76ce3662","repo":"OpenBB-finance/OpenBB","slug":"data-length-is-less-than-required-by-parameters","errorCode":null,"errorMessage":"Data length is less than required by parameters: {max(length)}","messagePattern":"Data length is less than required by parameters: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/technical/openbb_technical/helpers.py","lineNumber":18,"sourceCode":"\"\"\"Technical Analysis Helpers.\"\"\"\n\n# pylint: disable=too-many-arguments,too-many-locals,too-many-positional-arguments\n\nfrom typing import TYPE_CHECKING, Any, Literal\nfrom warnings import warn\n\nif TYPE_CHECKING:\n    from pandas import DataFrame, Series, Timestamp\n\n\ndef validate_data(data: list, length: int | list[int]) -> None:\n    \"\"\"Validate data.\"\"\"\n    if isinstance(length, int):\n        length = [length]\n    for item in length:\n        if item > len(data):\n            raise ValueError(\n                f\"Data length is less than required by parameters: {max(length)}\"\n            )\n\n\ndef parkinson(\n    data: \"DataFrame\",\n    window: int = 30,\n    trading_periods: int | None = None,\n    is_crypto: bool = False,\n    clean=True,\n) -> \"DataFrame\":\n    \"\"\"Parkinson volatility.\n\n    Uses the high and low price of the day rather than just close to close prices.\n    It is useful for capturing large price movements during the day.\n\n    Parameters\n    ----------","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/technical/openbb_technical/helpers.py#L1-L36","documentation":"validate_data in openbb_technical/helpers.py raises when any required lookback length exceeds the number of data points supplied. Indicator calculations (volatility estimators, cones, etc.) declare minimum bar counts; this guard rejects inputs too short for them.","triggerScenarios":"Calling technical indicator helpers with data shorter than the indicator's lookback, e.g. parkinson/garman-klass volatility with window=30 on 20 rows, or cones with fewer rows than the largest window (360).","commonSituations":"Small limit values in history fetches; recent IPOs with little history; weekly/monthly series where the developer assumed daily bar counts; reusing parameters across studies with different minimums.","solutions":["Fetch more history: increase limit or widen the date range so len(data) >= max required length.","Lower the indicator window below the data length.","Choose window = min(window, len(data) - 1) for exploratory runs.","Pre-check with openbb_technical.helpers.validate_data before computing."],"exampleFix":"# before\ndata = obb.equity.price.historical(symbol, limit=50).to_df()\ncones(data, window=120)  # raises\n\n# after\ndata = obb.equity.price.historical(symbol, limit=500).to_df()\ncones(data, window=120)","handlingStrategy":"validation","validationCode":"from openbb_technical.helpers import validate_data\nvalidate_data(data, length=[window])  # e.g. cones: [3,10,30,60,90,120,150,180,210,240,300,360]","typeGuard":"def has_enough_bars(data: list, lengths: list[int]) -> bool:\n    return all(n <= len(data) for n in lengths)","tryCatchPattern":"try:\n    out = cones(data, lower_q=0.1, upper_q=0.9)\nexcept ValueError as e:\n    if \"Data length is less than required\" in str(e):\n        data = fetch_more_history(limit=500)\n        out = cones(data, lower_q=0.1, upper_q=0.9)\n    else:\n        raise","preventionTips":["Fetch >= 360 daily bars when using cones","Scale windows to available history","Pre-validate with validate_data in pipelines"],"tags":["technical","window","validation","insufficient-data"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}