MCPcopy
hub / github.com/microsoft/qlib / build_index_from_data

Method build_index_from_data

qlib/data/cache.py:842–854  ·  view source on GitHub ↗
(data, start_index=0)

Source from the content-addressed store, hash-verified

840
841 @staticmethod
842 def build_index_from_data(data, start_index=0):
843 if data.empty:
844 return pd.DataFrame()
845 line_data = data.groupby("datetime", group_keys=False).size()
846 line_data.sort_index(inplace=True)
847 index_end = line_data.cumsum()
848 index_start = index_end.shift(1, fill_value=0)
849
850 index_data = pd.DataFrame()
851 index_data["start"] = index_start
852 index_data["end"] = index_end
853 index_data += start_index
854 return index_data
855
856 def gen_dataset_cache(self, cache_path: Union[str, Path], instruments, fields, freq, inst_processors=[]):
857 """gen_dataset_cache

Callers 2

gen_dataset_cacheMethod · 0.95
updateMethod · 0.95

Calls 2

shiftMethod · 0.80
sort_indexMethod · 0.45

Tested by

no test coverage detected