{"record":{"id":"cd7e74714c62f63b","repo":"microsoft/qlib","slug":"account-must-be-in-int-float-dict","errorCode":null,"errorMessage":"account must be in (int, float, dict)","messagePattern":"account must be in \\(int, float, dict\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"qlib/backtest/__init__.py","lineNumber":159,"sourceCode":"                ]\n        information for describing how to creating the account\n        For `float`:\n            Using Account with only initial cash\n        For `dict`:\n            key \"cash\" means initial cash.\n            key \"stock1\" means the information of first stock with amount and price(optional).\n            ...\n    pos_type: str\n        Postion type.\n    \"\"\"\n    if isinstance(account, (int, float)):\n        init_cash = account\n        position_dict = {}\n    elif isinstance(account, dict):\n        init_cash = account.pop(\"cash\")\n        position_dict = account\n    else:\n        raise ValueError(\"account must be in (int, float, dict)\")\n\n    return Account(\n        init_cash=init_cash,\n        position_dict=position_dict,\n        pos_type=pos_type,\n        benchmark_config=(\n            {}\n            if benchmark is None\n            else {\n                \"benchmark\": benchmark,\n                \"start_time\": start_time,\n                \"end_time\": end_time,\n            }\n        ),\n    )\n\n\ndef get_strategy_executor(","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/backtest/__init__.py#L141-L177","documentation":"DatasetCache._dataset_uri (qlib/data/cache.py:444) is the abstract method that returns the URI of the dataset cache file, with special semantics: disk_cache=1 returns the cache-file URI for the client to load; disk_cache=0 means the server checks/generates expression caches and the client loads data itself. The base class raises NotImplementedError because URI generation depends entirely on the cache mechanism.","triggerScenarios":"Client/server mode: calling D.features(..., disk_cache=1) or the DatasetProvider.dataset path that needs a downloadable cache URI while the configured DatasetCache subclass does not implement _dataset_uri; also hit in DatasetURICache-style flows where the URI itself is the product.","commonSituations":"Custom dataset caches implementing _dataset/_uri but missing _dataset_uri; using the abstract DatasetCache directly; client/server qlib deployments where the client requests dataset URIs.","solutions":["Use DiskDatasetCache, which implements _dataset_uri for the standard hash-based file layout","Override _dataset_uri(self, instruments, fields, start_time=None, end_time=None, freq='day', disk_cache=1, inst_processors=[]) in your subclass honoring the disk_cache=0/1 semantics documented in the docstring","If you never need URI serving (pure local use), call D.features with disk_cache=0 to bypass dataset-cache URI resolution"],"exampleFix":"# before\nD.features(instruments, fields, start, end, disk_cache=1)  # cache lacks _dataset_uri\n\n# after\nD.features(instruments, fields, start, end, disk_cache=0)  # bypass dataset cache URI\n# or: qlib.init(dataset_cache=DiskDatasetCache)","handlingStrategy":"validation","validationCode":"from qlib.data.cache import DatasetCache\n\nassert MyDSCache._dataset_uri is not DatasetCache._dataset_uri, \\\n    \"dataset URI serving requires _dataset_uri\"\n# or simply avoid the path:\n# D.features(..., disk_cache=0)","typeGuard":null,"tryCatchPattern":"try:\n    uri = cache._dataset_uri(insts, fields, start, end, disk_cache=1)\nexcept NotImplementedError:\n    uri = cache._dataset_uri(insts, fields, start, end, disk_cache=0)  # client-side load path","preventionTips":["In client/server mode, verify the server's cache class implements _dataset_uri before enabling disk_cache=1","Prefer disk_cache=0 when per-request processing is needed","Keep client and server cache implementations in lockstep"],"tags":["qlib","cache","custom-backend","client-server","not-implemented"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}