Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions qlib/data/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,21 +1031,20 @@ def update(self, cache_uri, freq: str = "day"):
else:
return 0 # No data to update cache

store = pd.HDFStore(cp_cache_uri)
# FIXME:
# Because the feature cache are stored as .bin file.
# So the series read from features are all float32.
# However, the first dataset cache is calculated based on the
# raw data. So the data type may be float64.
# Different data type will result in failure of appending data
if "/{}".format(DatasetCache.HDF_KEY) in store.keys():
schema = store.select(DatasetCache.HDF_KEY, start=0, stop=0)
for col, dtype in schema.dtypes.items():
data[col] = data[col].astype(dtype)
if rm_lines > 0:
store.remove(key=im.KEY, start=-rm_lines)
store.append(DatasetCache.HDF_KEY, data)
store.close()
with pd.HDFStore(cp_cache_uri) as store:
if "/{}".format(DatasetCache.HDF_KEY) in store.keys():
schema = store.select(DatasetCache.HDF_KEY, start=0, stop=0)
for col, dtype in schema.dtypes.items():
data[col] = data[col].astype(dtype)
if rm_lines > 0:
store.remove(key=im.KEY, start=-rm_lines)
store.append(DatasetCache.HDF_KEY, data)

# update index file
new_index_data = im.build_index_from_data(
Expand Down