{"record":{"id":"a5f0c6468f6f9302","repo":"microsoft/qlib","slug":"expected-pd-timestamp-for-cur-time-got-cur-ti","errorCode":null,"errorMessage":"Expected pd.Timestamp for `cur_time`, got '{cur_time}'. Advices: you can't query PIT data directly(e.g. '$$roewa_q'), you must use `P` operator to convert data to each day (e.g. 'P($$roewa_q)')","messagePattern":"Expected pd\\.Timestamp for `cur_time`, got '(.+?)'\\. Advices: you can't query PIT data directly\\(e\\.g\\. '\\$\\$roewa_q'\\), you must use `P` operator to convert data to each day \\(e\\.g\\. 'P\\(\\$\\$roewa_q\\)'\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/data/data.py","lineNumber":750,"sourceCode":"    def __init__(self, remote=False, backend={}):\n        super().__init__()\n        self.remote = remote\n        self.backend = backend\n\n    def feature(self, instrument, field, start_index, end_index, freq):\n        # validate\n        field = str(field)[1:]\n        instrument = code_to_fname(instrument)\n        return self.backend_obj(instrument=instrument, field=field, freq=freq)[start_index : end_index + 1]\n\n\nclass LocalPITProvider(PITProvider):\n    # TODO: Add PIT backend file storage\n    # NOTE: This class is not multi-threading-safe!!!!\n\n    def period_feature(self, instrument, field, start_index, end_index, cur_time, period=None):\n        if not isinstance(cur_time, pd.Timestamp):\n            raise ValueError(\n                f\"Expected pd.Timestamp for `cur_time`, got '{cur_time}'. Advices: you can't query PIT data directly(e.g. '$$roewa_q'), you must use `P` operator to convert data to each day (e.g. 'P($$roewa_q)')\"\n            )\n\n        assert end_index <= 0  # PIT don't support querying future data\n\n        DATA_RECORDS = [\n            (\"date\", C.pit_record_type[\"date\"]),\n            (\"period\", C.pit_record_type[\"period\"]),\n            (\"value\", C.pit_record_type[\"value\"]),\n            (\"_next\", C.pit_record_type[\"index\"]),\n        ]\n        VALUE_DTYPE = C.pit_record_type[\"value\"]\n\n        field = str(field).lower()[2:]\n        instrument = code_to_fname(instrument)\n\n        # {For acceleration\n        # start_index, end_index, cur_index = kwargs[\"info\"]","sourceCodeStart":732,"sourceCodeEnd":768,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/data.py#L732-L768","documentation":"`LocalPITProvider.period_feature` requires `cur_time` to be a `pd.Timestamp`. Point-in-time financial data (fields starting with `$$`, e.g. `$$roewa_q`) is only meaningful 'as of' a query date; qlib supplies that date through the `P(...)` operator, which walks the calendar and passes a Timestamp per day. Calling the PIT provider with a raw index, string, or None (i.e. bypassing P) raises this ValueError.","triggerScenarios":"Using a PIT field directly in `D.features`: `D.features(insts, ['$$roewa_q'])`, or `$$field` inside another expression without wrapping it in `P(...)`.","commonSituations":"Users exploring quarterly/annual financial data who assume `$$` fields behave like `$` price fields. The error message itself is the documented fix: wrap in P.","solutions":["Wrap the PIT field: `D.features(insts, ['P($$roewa_q)'])`.","For multiple fields, wrap each: `['P($$roewa_q)', 'P($$assets_a)']`."],"exampleFix":"# before\ndf = D.features(insts, ['$$roewa_q'], start_time='2020-01-01', end_time='2020-12-31')\n\n# after\ndf = D.features(insts, ['P($$roewa_q)'], start_time='2020-01-01', end_time='2020-12-31')","handlingStrategy":"validation","validationCode":"PIT_FIELDS = {'$$roewa_q', '$$assets_a'}  # example\n\ndef fields_are_pit_safe(fields):\n    # every $$ (PIT) field must be wrapped in P(...)\n    return all(not f.startswith('$$') for f in map(str.strip, fields))","typeGuard":"def is_pit_field(f: str) -> bool:\n    return str(f).startswith('$$') and not str(f).startswith('P(')","tryCatchPattern":null,"preventionTips":["Treat $$ fields as non-queryable primitives; always use P($$field).","Lint user-supplied expression lists for unwrapped $$ tokens."],"tags":["pit-data","financial","expression","api-usage"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}