Skip to content

Commit 86b0b63

Browse files
committed
Update table generator
1 parent 99adc51 commit 86b0b63

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/run_all_model.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def get_all_folders(models, exclude) -> dict:
137137
# function to get all the files under the model folder
138138
def get_all_files(folder_path, dataset) -> (str, str):
139139
yaml_path = str(Path(f"{folder_path}") / f"*{dataset}*.yaml")
140-
req_path = str(Path(f"{folder_path}") / f"*{dataset}*.txt")
140+
req_path = str(Path(f"{folder_path}") / f"*.txt")
141141
return glob.glob(yaml_path)[0], glob.glob(req_path)[0]
142142

143143

@@ -172,17 +172,17 @@ def get_all_results(folders) -> dict:
172172

173173
# function to generate and save markdown table
174174
def gen_and_save_md_table(metrics, dataset):
175-
table = "| Model Name | Dataset | Annualized Return | Information Ratio | Max Drawdown | IC | ICIR | Rank IC | Rank ICIR |\n"
175+
table = "| Model Name | Dataset | IC | ICIR | Rank IC | Rank ICIR | Annualized Return | Information Ratio | Max Drawdown |\n"
176176
table += "|---|---|---|---|---|---|---|---|---|\n"
177177
for fn in metrics:
178-
ar = metrics[fn]["annualized_return_with_cost"]
179-
ir = metrics[fn]["information_ratio_with_cost"]
180-
md = metrics[fn]["max_drawdown_with_cost"]
181178
ic = metrics[fn]["ic"]
182179
icir = metrics[fn]["icir"]
183180
ric = metrics[fn]["rank_ic"]
184181
ricir = metrics[fn]["rank_icir"]
185-
table += f"| {fn} | {dataset} | {ar[0]:5.4f}±{ar[1]:2.2f} | {ir[0]:5.4f}±{ir[1]:2.2f}| {md[0]:5.4f}±{md[1]:2.2f} | {ic[0]:5.4f}±{ic[1]:2.2f} | {icir[0]:5.4f}±{icir[1]:2.2f}| {ric[0]:5.4f}±{ric[1]:2.2f} | {ricir[0]:5.4f}±{ricir[1]:2.2f} |\n"
182+
ar = metrics[fn]["annualized_return_with_cost"]
183+
ir = metrics[fn]["information_ratio_with_cost"]
184+
md = metrics[fn]["max_drawdown_with_cost"]
185+
table += f"| {fn} | {dataset} | {ic[0]:5.4f}±{ic[1]:2.2f} | {icir[0]:5.4f}±{icir[1]:2.2f}| {ric[0]:5.4f}±{ric[1]:2.2f} | {ricir[0]:5.4f}±{ricir[1]:2.2f} | {ar[0]:5.4f}±{ar[1]:2.2f} | {ir[0]:5.4f}±{ir[1]:2.2f}| {md[0]:5.4f}±{md[1]:2.2f} |\n"
186186
pprint(table)
187187
with open("table.md", "w") as f:
188188
f.write(table)

0 commit comments

Comments
 (0)