{"record":{"id":"4d539c5b6d1b63ac","repo":"OpenBB-finance/OpenBB","slug":"error-lower-q-and-upper-q-must-be-between-0-and-1","errorCode":null,"errorMessage":"Error: lower_q and upper_q must be between 0 and 1","messagePattern":"Error: lower_q and upper_q must be between 0 and 1","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/technical/openbb_technical/helpers.py","lineNumber":419,"sourceCode":"        \"parkinson\",\n        \"garman_klass\",\n        \"hodges_tompkins\",\n        \"rogers_satchell\",\n        \"yang_zhang\",\n    ],\n    trading_periods: int | None = None,\n) -> \"DataFrame\":\n    \"\"\"Calculate Cones.\"\"\"\n    # pylint: disable=import-outside-toplevel\n    from pandas import DataFrame\n\n    estimator = DataFrame()\n\n    if lower_q > upper_q:\n        lower_q, upper_q = upper_q, lower_q\n\n    if (lower_q >= 1) or (upper_q >= 1):\n        raise ValueError(\"Error: lower_q and upper_q must be between 0 and 1\")\n\n    lower_q_label = str(int(lower_q * 100))\n    upper_q_label = str(int(upper_q * 100))\n    quantiles = [lower_q, upper_q]\n    windows = [3, 10, 30, 60, 90, 120, 150, 180, 210, 240, 300, 360]\n    min_ = []\n    max_ = []\n    median = []\n    top_q = []\n    bottom_q = []\n    realized = []\n    allowed_windows = []\n    data = data.sort_index(ascending=True)\n\n    model_functions = {\n        \"std\": standard_deviation,\n        \"parkinson\": parkinson,\n        \"garman_klass\": garman_klass,","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/technical/openbb_technical/helpers.py#L401-L437","documentation":"In the cones helper (openbb_technical/helpers.py), after normalizing lower_q/upper_q so lower <= upper, a hard check rejects quantile values >= 1. Quantiles must be strictly within [0, 1) as fractions, not percentages.","triggerScenarios":"Calling cones(data, lower_q=0.25, upper_q=95) style code where one bound is passed as a percentage (>= 1) instead of a fraction; also lower_q=1 or upper_q=1 exactly.","commonSituations":"Translating percentile integers (e.g. '95th percentile') directly into the parameter; copying configs from libraries that accept 0-100 quantiles; mixing conventions between lower_q and upper_q.","solutions":["Express quantiles as fractions: lower_q=0.10, upper_q=0.90.","Divide percentage-style values by 100 before the call.","Note bounds are auto-swapped if reversed, so only the 0-1 range matters.","Validate inputs at the config layer of your app so users cannot enter percent integers."],"exampleFix":"# before\ncones(data, lower_q=10, upper_q=90)  # interpreted as >= 1\n\n# after\ncones(data, lower_q=0.10, upper_q=0.90)","handlingStrategy":"validation","validationCode":"assert 0 <= lower_q < 1 and 0 <= upper_q < 1, \"quantiles must be fractions in [0, 1)\"\nlower_q, upper_q = sorted([lower_q, upper_q])","typeGuard":"def valid_quantile(q) -> bool:\n    return isinstance(q, (int, float)) and 0 <= q < 1","tryCatchPattern":"try:\n    out = cones(data, lower_q=lower_q, upper_q=upper_q)\nexcept ValueError as e:\n    if \"must be between 0 and 1\" in str(e):\n        out = cones(data, lower_q=lower_q/100, upper_q=upper_q/100)\n    else:\n        raise","preventionTips":["Use fractions (0.90), never percent integers (90)","Bounds are auto-swapped; only range matters","Centralize quantile config in one validated place"],"tags":["technical","quantiles","cones","validation"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}