40만 원 기준 시뮬·dry-run 정합 및 hybrid 체결 엔진 통합.
초기 자금 GT_INITIAL_CASH_KRW=400000과 원화 한도 비율(알림·LIVE_ORDER·일한도·손실한도)을 맞추고, dry-run/live 체결을 sim_causal_hybrid(replay)와 동일 경로로 통합한다. 시뮬 리포트 갱신, Phase C 슈퍼바이저·매수매도 리허설 스크립트를 추가한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -47,16 +47,21 @@ def _holding_qty(balances: dict[str, dict[str, float]], symbol: str) -> float:
|
||||
def build_rule_alert_message(
|
||||
hit: dict[str, Any],
|
||||
balances: dict[str, dict[str, float]] | None = None,
|
||||
*,
|
||||
trade_krw: float | None = None,
|
||||
trade_qty: float | None = None,
|
||||
) -> str:
|
||||
"""
|
||||
규칙 발화 알림 본문을 만듭니다.
|
||||
|
||||
매수: MONITOR_ALERT_KRW_AMOUNT 기준 수량·금액.
|
||||
매도: 보유 수량(잔고 조회 가능 시) × 가격 = 금액, 없으면 참고 금액 기준.
|
||||
trade_krw·trade_qty가 있으면 실제(모의) 체결 규모를 표시합니다.
|
||||
없으면 매수는 MONITOR_ALERT_KRW_AMOUNT, 매도는 보유×가격(또는 참고 금액).
|
||||
|
||||
Args:
|
||||
hit: evaluate_live_rules 항목 (side, rule_id, dt, close).
|
||||
balances: 빗썸 잔고 dict. None이면 매도도 참고 금액 기준.
|
||||
balances: 잔고 dict (모의·실거래).
|
||||
trade_krw: 체결 원화(모의·실거래 planned/executed).
|
||||
trade_qty: 체결 수량(매도 시).
|
||||
|
||||
Returns:
|
||||
텔레그램 메시지 문자열.
|
||||
@@ -67,14 +72,25 @@ def build_rule_alert_message(
|
||||
dt = hit.get("dt", "")
|
||||
|
||||
qty_basis = ""
|
||||
if side == "SELL" and balances is not None:
|
||||
if trade_krw is not None and trade_krw > 0:
|
||||
amount = float(trade_krw)
|
||||
if trade_qty is not None and trade_qty > 0:
|
||||
qty = float(trade_qty)
|
||||
qty_basis = "체결 기준"
|
||||
elif close > 0:
|
||||
qty = amount / close
|
||||
qty_basis = "체결 기준(원화→수량)"
|
||||
else:
|
||||
qty = 0.0
|
||||
qty_basis = "체결 기준"
|
||||
elif side == "SELL" and balances is not None:
|
||||
qty = _holding_qty(balances, SYMBOL)
|
||||
amount = qty * close
|
||||
qty_basis = "보유 기준"
|
||||
qty_basis = "보유 기준(체결 전)"
|
||||
elif side == "BUY":
|
||||
amount = float(MONITOR_ALERT_KRW_AMOUNT)
|
||||
qty = amount / close if close > 0 else 0.0
|
||||
qty_basis = "참고 매수 규모"
|
||||
qty_basis = "참고 매수 규모(알림용)"
|
||||
else:
|
||||
amount = float(MONITOR_ALERT_KRW_AMOUNT)
|
||||
qty = amount / close if close > 0 else 0.0
|
||||
|
||||
Reference in New Issue
Block a user