import re html_path = "templates/backtest.html" js_path = "static/js/backtest.js" with open(html_path, "r", encoding="utf-8") as f: html = f.read() # The scalp box looks like: id="bt_ob_whip_ro_box" # We need to insert tl_ob_whip_ro_box after tl_max_loss_krw or similar. # Let's find
for Tail defenses # and insert before it. tail_defense_marker = r'' # Let's find where to insert in Tail tab. #
... # Instead of complex regex, let's just tell the user to click "적용". # But adding the box is good. Let's do it simply by reading the file, finding the marker in Tail tab. with open(js_path, "r", encoding="utf-8") as f: js = f.read() # Replace the misleading alert js = js.replace( "'「백테 실행」으로 Optuna 숫자와 비교하세요.\\n(DB 저장 아님)'", "'호가/휩쏘 등 후처리 파라미터는 DB 기반으로 동작합니다.\\n정확한 수익금 비교를 원하시면 Optuna 리스트에서 [적용(DB저장)]을 먼저 누른 후 백테스트를 실행하세요.'" ) with open(js_path, "w", encoding="utf-8") as f: f.write(js) print("JS patched")