refactor: enhance Optuna backtesting framework, optimize orderbook filtering, and update database management utilities.

This commit is contained in:
Your Name
2026-08-12 10:19:19 +09:00
parent cb7e5037a0
commit c6bd62a25f
218 changed files with 31613 additions and 759 deletions

28
scratch/refactor_html.py Normal file
View File

@@ -0,0 +1,28 @@
import re
html_path = 'templates/backtest.html'
with open(html_path, 'r', encoding='utf-8') as f:
html = f.read()
# Pattern for EOD block
# 1. <div class="col-auto d-flex align-items-end"> ... id="PREFIX_eod_enabled" ... </div>
# 2. <div class="..."> ... id="PREFIX_eod_hm" ... </div>
regex = re.compile(
r'(\s*<div class="col-auto d-flex align-items-end">\s*<div class="form-check mb-2">\s*<input class="form-check-input" type="checkbox" id="([a-z]+)_eod_enabled"[^>]*>\s*<label[^>]*for="\2_eod_enabled"[^>]*>EOD청산</label>\s*</div>\s*</div>\s*<div class="[^"]*">\s*<label class="form-label param-row"[^>]*>EOD시각.*?</label>\s*<input type="text" class="form-control" id="\2_eod_hm"[^>]*>\s*</div>)',
re.DOTALL
)
def replacer(match):
original_text = match.group(1)
prefix = match.group(2)
# We will remove it from its original place and append it after the row closes, but wait, the regex matches it exactly.
# It's better to just return empty string, and insert the new block after the end of the current .row.
# But wait, how do we insert it after the row?
return f"<!-- EOD_BLOCK_{prefix} -->" + original_text
html = regex.sub(replacer, html)
with open(html_path, 'w', encoding='utf-8') as f:
f.write(html)
print("done")