from tqz_extern.json_operator import TQZJsonOperator
def reset_trading_time_json(cls, source_trading_time_json: str, target_trading_time_json: str):
assert os.path.exists(path=source_trading_time_json), f'Bad path: {source_trading_time_json} not exist.'
content = TQZJsonOperator.tqz_load_jsonfile(jsonfile=source_trading_time_json)
target_content: {str, dict} = {}
for instrument, data in content.items():
target_content[instrument] = {cls.DAY: [], cls.NIGHT: []}
for session in data[cls.DAY]:
[session_item.append(int(f'{session_time.split(":")[0]}{session_time.split(":")[1]}')) for session_time
target_content[instrument][cls.DAY].append(session_item)
for session in data[cls.NIGHT]:
[session_item.append(int(f'{session_time.split(":")[0]}{session_time.split(":")[1]}')) for session_time
target_content[instrument][cls.NIGHT].append(session_item)
TQZJsonOperator.tqz_write_jsonfile(content=target_content, target_jsonfile=target_trading_time_json)
if __name__ == '__main__':
MakeConfig.reset_trading_time_json(source_trading_time_json='source_trading_time.json', target_trading_time_json='trading_time.json')