refactor: GT·시뮬·운영 3축 정리 및 hybrid 실거래 정합
Phase C/dry-run·미사용 모듈·재생성 HTML을 제거하고, 운영 체결을 sim_causal_hybrid와 동일한 hybrid 로직으로 통합한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -45,7 +45,9 @@ def build_trade_mtf_snapshots(
|
||||
n_trades = len(trades)
|
||||
enriched: dict[int, pd.DataFrame] = {}
|
||||
t0 = time.time()
|
||||
print(f"[03b] Phase A: 8TF enrich (1분봉 제외, 전 기법) — {len(GENERAL_ANALYSIS_INTERVALS)}개 간격")
|
||||
print(
|
||||
f"[03b] MTF enrich (주·월봉 포함) — {len(GENERAL_ANALYSIS_INTERVALS)}개 간격"
|
||||
)
|
||||
sys.stdout.flush()
|
||||
for step, iv in enumerate(GENERAL_ANALYSIS_INTERVALS, start=1):
|
||||
raw = frames.get(iv)
|
||||
@@ -104,46 +106,6 @@ def build_trade_mtf_snapshots(
|
||||
return pd.DataFrame(rows)
|
||||
|
||||
|
||||
def append_missing_gt_snapshots(
|
||||
frames: dict[int, pd.DataFrame],
|
||||
trades_path: Path | str = DEFAULT_TRADES_FILE,
|
||||
output_csv: Path | str = DEFAULT_OUTPUT_CSV,
|
||||
) -> int:
|
||||
"""
|
||||
CSV에 없는 GT 타점만 MTF 스냅샷 추가.
|
||||
|
||||
Args:
|
||||
frames: interval → OHLCV.
|
||||
trades_path: ground_truth JSON.
|
||||
output_csv: 03b CSV.
|
||||
|
||||
Returns:
|
||||
추가된 행 수.
|
||||
"""
|
||||
out = Path(output_csv)
|
||||
if not out.is_file():
|
||||
return 0
|
||||
data = load_ground_truth(Path(trades_path))
|
||||
if not data:
|
||||
return 0
|
||||
trades = data.get("trades") or []
|
||||
existing = pd.read_csv(out)
|
||||
have = set(zip(existing["dt"].astype(str), existing["action"].astype(str)))
|
||||
missing = [
|
||||
t
|
||||
for t in trades
|
||||
if (str(t["dt"]), str(t["action"])) not in have
|
||||
]
|
||||
if not missing:
|
||||
return 0
|
||||
print(f"[03b] 누락 GT 타점 {len(missing)}건 스냅샷 추가")
|
||||
add_df = build_trade_mtf_snapshots(frames, missing)
|
||||
merged = pd.concat([existing, add_df], ignore_index=True)
|
||||
merged.to_csv(out, index=False, encoding="utf-8-sig")
|
||||
print(f"[03b] CSV 갱신: {out} ({len(merged)}행)")
|
||||
return len(missing)
|
||||
|
||||
|
||||
def export_trade_snapshots(
|
||||
frames: dict[int, pd.DataFrame],
|
||||
trades_path: Path | str = DEFAULT_TRADES_FILE,
|
||||
|
||||
Reference in New Issue
Block a user