{"record":{"id":"9fff54b131307e17","repo":"microsoft/qlib","slug":"time-obj-is-not-the-opening-time-of-the-region","errorCode":null,"errorMessage":"{time_obj} is not the opening time of the {region} stock market","messagePattern":"(.+?) is not the opening time of the (.+?) stock market","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/utils/time.py","lineNumber":268,"sourceCode":"                continue\n            if min_freq is None:\n                min_freq = (_min_delta, str(_freq))\n                continue\n            min_freq = min_freq if min_freq[0] <= _min_delta else (_min_delta, _freq)\n        return min_freq[1] if min_freq else None\n\n\ndef time_to_day_index(time_obj: Union[str, datetime], region: str = REG_CN):\n    if isinstance(time_obj, str):\n        time_obj = datetime.strptime(time_obj, \"%H:%M\")\n\n    if region == REG_CN:\n        if CN_TIME[0] <= time_obj < CN_TIME[1]:\n            return int((time_obj - CN_TIME[0]).total_seconds() / 60)\n        elif CN_TIME[2] <= time_obj < CN_TIME[3]:\n            return int((time_obj - CN_TIME[2]).total_seconds() / 60) + 120\n        else:\n            raise ValueError(f\"{time_obj} is not the opening time of the {region} stock market\")\n    elif region == REG_US:\n        if US_TIME[0] <= time_obj < US_TIME[1]:\n            return int((time_obj - US_TIME[0]).total_seconds() / 60)\n        else:\n            raise ValueError(f\"{time_obj} is not the opening time of the {region} stock market\")\n    elif region == REG_TW:\n        if TW_TIME[0] <= time_obj < TW_TIME[1]:\n            return int((time_obj - TW_TIME[0]).total_seconds() / 60)\n        else:\n            raise ValueError(f\"{time_obj} is not the opening time of the {region} stock market\")\n    else:\n        raise ValueError(f\"{region} is not supported\")\n\n\ndef get_day_min_idx_range(start: str, end: str, freq: str, region: str) -> Tuple[int, int]:\n    \"\"\"\n    get the min-bar index in a day for a time range (both left and right is closed) given a fixed frequency\n    Parameters","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/utils/time.py#L250-L286","documentation":"Error \"{time_obj} is not the opening time of the {region} stock market\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/utils/time.py:268 when the guard condition fails: \"not the opening time of the stock market\". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.","commonSituations":"See trigger scenarios.","solutions":["Pass a time that is within the opening hours of the specified region's stock market.","Adjust the time to the market session, or check the region setting if it is wrong."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}