fix: current_price=0일 때 stop-loss/take-profit 오발동 방지 #251

Closed
opened 2026-02-25 02:26:19 +09:00 by agentson · 0 comments
Collaborator

문제

trading_cycle()의 stop-loss/take-profit 가드가 if entry_price > 0만 체크한다.
현재가 API가 0.0을 반환할 경우 loss_pct = (0 - entry_price) / entry_price = -100%가 계산되어 stop-loss가 오발동된다.

재현 케이스

  • LLY(NASDAQ) 현재가 API 0.0 반환 → loss_pct=-100.00% → SELL 주문 → ORD_DVSN='01'(시장가) → '주문구분 입력오류'

원인

src/main.py line ~733:

if entry_price > 0:
    loss_pct = (current_price - entry_price) / entry_price * 100

current_price=0 미체크

해결

if entry_price > 0 and current_price > 0:로 변경

## 문제 `trading_cycle()`의 stop-loss/take-profit 가드가 `if entry_price > 0`만 체크한다. 현재가 API가 0.0을 반환할 경우 `loss_pct = (0 - entry_price) / entry_price = -100%`가 계산되어 stop-loss가 오발동된다. ## 재현 케이스 - LLY(NASDAQ) 현재가 API 0.0 반환 → loss_pct=-100.00% → SELL 주문 → ORD_DVSN='01'(시장가) → '주문구분 입력오류' ## 원인 `src/main.py` line ~733: ```python if entry_price > 0: loss_pct = (current_price - entry_price) / entry_price * 100 ``` current_price=0 미체크 ## 해결 `if entry_price > 0 and current_price > 0:`로 변경
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#251