MCPcopy Create free account
hub / github.com/DVampire/FinAgent / main

Function main

tools/main_strategy.py:62–147  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60 return args
61
62def main():
63 args = parse_args()
64
65 cfg = Config.fromfile(args.config)
66
67 if args.cfg_options is None:
68 args.cfg_options = dict()
69 if args.root is not None:
70 args.cfg_options["root"] = args.root
71
72 args.cfg_options["checkpoint_start_date"] = args.checkpoint_start_date
73 args.cfg_options["if_load_memory"] = args.if_load_memory
74 args.cfg_options["memory_path"] = args.memory_path
75 args.cfg_options["if_load_trading_record"] = args.if_load_trading_record
76 args.cfg_options["trading_record_path"] = args.trading_record_path
77
78 if args.if_train is not None:
79 args.cfg_options["if_train"] = args.if_train
80 if args.if_valid is not None:
81 args.cfg_options["if_valid"] = args.if_valid
82 cfg.merge_from_dict(args.cfg_options)
83
84 update_data_root(cfg, root=args.root)
85
86 exp_path = os.path.join(cfg.root, cfg.workdir, cfg.tag)
87 if args.if_remove is None:
88 args.if_remove = bool(input(f"| Arguments PRESS 'y' to REMOVE: {exp_path}? ") == 'y')
89 if args.if_remove:
90 import shutil
91 shutil.rmtree(exp_path, ignore_errors=True)
92 print(f"| Arguments Remove work_dir: {exp_path}")
93 else:
94 print(f"| Arguments Keep work_dir: {exp_path}")
95 os.makedirs(exp_path, exist_ok=True)
96
97 cfg.dump(os.path.join(exp_path, 'config.py'))
98
99 provider = PROVIDER.build(cfg.provider)
100
101 dataset = DATASET.build(cfg.dataset)
102 cfg.train_environment["dataset"] = dataset
103 train_env = ENVIRONMENT.build(cfg.train_environment)
104 cfg.valid_environment["dataset"] = dataset
105 valid_env = ENVIRONMENT.build(cfg.valid_environment)
106
107 plots = PLOTS.build(cfg.plots)
108
109 cfg.memory["symbols"] = dataset.assets
110 cfg.memory["embedding_dim"] = provider.get_embedding_dim()
111 memory = MEMORY.build(cfg.memory)
112
113 diverse_query = DiverseQuery(memory, provider, top_k=cfg.top_k)
114 strategy_agents = StrategyAgents()
115
116 if cfg.if_load_memory and cfg.memory_path is not None:
117 print("load local memory...")
118 memory_path = os.path.join(cfg.root, cfg.memory_path)
119 memory.load_local(memory_path=memory_path)

Callers 1

main_strategy.pyFile · 0.70

Calls 9

update_data_rootFunction · 0.90
DiverseQueryClass · 0.90
StrategyAgentsClass · 0.90
save_jsonFunction · 0.90
parse_argsFunction · 0.70
runFunction · 0.70
get_embedding_dimMethod · 0.45
load_localMethod · 0.45
save_localMethod · 0.45

Tested by

no test coverage detected