(
self, instruments, fields, start_time=None, end_time=None, freq="day", disk_cache=1, inst_processors=[]
)
| 1082 | ) |
| 1083 | |
| 1084 | def _dataset( |
| 1085 | self, instruments, fields, start_time=None, end_time=None, freq="day", disk_cache=1, inst_processors=[] |
| 1086 | ): |
| 1087 | if disk_cache == 0: |
| 1088 | # In this case, data_set cache is configured but will not be used. |
| 1089 | return self.provider.dataset(instruments, fields, start_time, end_time, freq) |
| 1090 | self.local_cache_path.mkdir(exist_ok=True, parents=True) |
| 1091 | cache_file = self.local_cache_path.joinpath( |
| 1092 | self._uri( |
| 1093 | instruments, fields, start_time, end_time, freq, disk_cache=disk_cache, inst_processors=inst_processors |
| 1094 | ) |
| 1095 | ) |
| 1096 | gen_flag = False |
| 1097 | |
| 1098 | if cache_file.exists(): |
| 1099 | if disk_cache == 1: |
| 1100 | # use cache |
| 1101 | df = pd.read_pickle(cache_file) |
| 1102 | return self.cache_to_origin_data(df, fields) |
| 1103 | elif disk_cache == 2: |
| 1104 | # replace cache |
| 1105 | gen_flag = True |
| 1106 | else: |
| 1107 | gen_flag = True |
| 1108 | |
| 1109 | if gen_flag: |
| 1110 | data = self.provider.dataset( |
| 1111 | instruments, normalize_cache_fields(fields), start_time, end_time, freq, inst_processors=inst_processors |
| 1112 | ) |
| 1113 | data.to_pickle(cache_file) |
| 1114 | return self.cache_to_origin_data(data, fields) |
| 1115 | |
| 1116 | |
| 1117 | class DatasetURICache(DatasetCache): |
nothing calls this directly
no test coverage detected