from tqz_extern.json_operator import TQZJsonOperator
import os
class MakeConfig:
DAY: str = 'day'
NIGHT: str = 'night'
@classmethod
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 = []
[session_item.append(int(f'{session_time.split(":")[0]}{session_time.split(":")[1]}')) for session_time
in session]
target_content[instrument][cls.DAY].append(session_item)
for session in data[cls.NIGHT]:
session_item = []
[session_item.append(int(f'{session_time.split(":")[0]}{session_time.split(":")[1]}')) for session_time
in session]
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')
量化交易之One Piece篇 - onepiece_rsh - reset trading_time.json
于 2023-09-15 23:07:52 首次发布