feat: Enhance trading system with new e_min_chg_pct parameter and related logic
Changes: - Introduced the `e_min_chg_pct` parameter to define the minimum price change percentage compared to the previous day's close, enhancing the momentum trading strategy. - Updated various functions and classes to incorporate this new parameter, ensuring it is utilized in both backtesting and live trading scenarios. - Improved documentation and comments to clarify the purpose and usage of the new parameter across the codebase. Impact: - This addition allows for more precise control over trading conditions, potentially increasing the effectiveness of the momentum strategy while maintaining system integrity and performance.
This commit is contained in:
@@ -170,16 +170,28 @@ def main() -> int:
|
||||
hb = threading.Thread(target=_heartbeat, args=(prog_file, stop_hb), daemon=True)
|
||||
hb.start()
|
||||
_write_progress(prog_file, pct=30, phase="engine", message="웹엔진 실행중")
|
||||
data = None
|
||||
http_status = 200
|
||||
try:
|
||||
with bw.app.test_request_context(f"{path}?{qs}"):
|
||||
resp = fn()
|
||||
if isinstance(resp, tuple):
|
||||
# Flask: (jsonify(...), 500) — 본문만 취하면 실패를 성공으로 오인함
|
||||
http_status = int(resp[1]) if len(resp) > 1 else 200
|
||||
resp = resp[0]
|
||||
elif hasattr(resp, "status_code"):
|
||||
try:
|
||||
http_status = int(resp.status_code)
|
||||
except (TypeError, ValueError):
|
||||
http_status = 200
|
||||
data = resp.get_json(silent=True) if hasattr(resp, "get_json") else None
|
||||
if not isinstance(data, dict):
|
||||
raise RuntimeError(f"응답 JSON 아님: {type(resp)}")
|
||||
if data.get("error") and not data.get("summary") and not data.get("ok", True):
|
||||
raise RuntimeError(str(data.get("error")))
|
||||
# 핸들러가 jsonify({"error": ...}, 500) 을 주면 summary 없이 error 만 옴
|
||||
if http_status >= 400 or (
|
||||
data.get("error") and not data.get("summary")
|
||||
):
|
||||
raise RuntimeError(str(data.get("error") or f"HTTP {http_status}"))
|
||||
finally:
|
||||
stop_hb.set()
|
||||
try:
|
||||
@@ -187,10 +199,14 @@ def main() -> int:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if not isinstance(data, dict):
|
||||
raise RuntimeError("백테 응답 없음")
|
||||
|
||||
elapsed = time.time() - t0
|
||||
summary = data.get("summary") or {}
|
||||
trades = data.get("trades") or []
|
||||
out = dict(data)
|
||||
out.pop("error", None)
|
||||
out["ok"] = True
|
||||
out["job_id"] = job_id
|
||||
out["kind"] = "strategy_bt_cli"
|
||||
|
||||
Reference in New Issue
Block a user