hybrid DD tier와 Option C 2차(+1000%) 검증을 추가하고 실거래 사이징을 정합한다.

인과 GT leg 엔진·drawdown tier·train 캘리브레이션, Phase 2 Go/No-Go 및 시뮬 리포트를 반영한다.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
xavis
2026-06-01 16:09:18 +09:00
parent 9b00ef34c6
commit d385456867
21 changed files with 3315 additions and 1178 deletions

View File

@@ -75,7 +75,7 @@ def allocate_order_amounts_chronological(
Returns:
(amount_krw 채워진 trades, alloc_stats).
"""
from config import GT_LARGE_LEG_TOP_PCT
from config import GT_BUY_PCT_LARGE_LEG, GT_LARGE_LEG_TOP_PCT
from deepcoin.matching.position_sizing import (
compute_buy_amount_krw,
@@ -109,6 +109,7 @@ def allocate_order_amounts_chronological(
sell_executed = 0
sell_skipped = 0
buy_amounts: list[float] = []
large_tier_buys = 0
completed_leg_ret: dict[int, float] = {}
leg_cost_krw: dict[int, float] = {}
leg_proceeds_krw: dict[int, float] = {}
@@ -128,7 +129,7 @@ def allocate_order_amounts_chronological(
)
scale = leg_asset_pct_scale(leg_id, large_now)
elif asset_pct_scale_fn is not None:
scale = asset_pct_scale_fn(t)
scale = asset_pct_scale_fn(t, completed_leg_ret)
else:
scale = leg_asset_pct_scale(leg_id, large_legs)
amount = compute_buy_amount_krw(
@@ -140,6 +141,7 @@ def allocate_order_amounts_chronological(
asset_pct_scale=scale,
min_order_krw=min_order_krw,
fee_rate=fee_rate,
ignore_weight_split=bool(t.get("conviction_buy")),
)
if amount <= 0:
t["amount_krw"] = 0
@@ -154,6 +156,8 @@ def allocate_order_amounts_chronological(
leg_cost_krw[leg_id] = leg_cost_krw.get(leg_id, 0.0) + amount + fee
buy_executed += 1
buy_amounts.append(amount)
if scale >= float(GT_BUY_PCT_LARGE_LEG) * 0.99:
large_tier_buys += 1
sell_leg = None
elif t["action"] == "sell":
@@ -188,7 +192,7 @@ def allocate_order_amounts_chronological(
if qty < 1e-12:
qty = 0.0
sell_executed += 1
if causal_tier and leg_qty <= 1e-12:
if (causal_tier or asset_pct_scale_fn is not None) and leg_qty <= 1e-12:
cost = leg_cost_krw.pop(leg_id, 0.0)
proceeds = leg_proceeds_krw.pop(leg_id, 0.0)
if cost > 0:
@@ -200,7 +204,8 @@ def allocate_order_amounts_chronological(
"sell_executed": sell_executed,
"sell_skipped": sell_skipped,
"buy_total_krw": round(sum(buy_amounts), 0),
"large_leg_count": len(large_legs),
"large_leg_count": large_tier_buys,
"large_tier_buy_count": large_tier_buys,
}
if buy_amounts:
stats["buy_amount_avg_krw"] = round(sum(buy_amounts) / len(buy_amounts), 0)