fix: BUY 결정 전 기존 포지션 체크 추가 — 중복 매수 방지 (#191) #192
Reference in New Issue
Block a user
Delete Branch "feature/issue-191-duplicate-buy-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
trading_cycle()의 BUY 결정 직후get_open_position()체크 추가Root Cause
어제(2026-02-20) 거래 로그에서 NP 7번, KNRX 5번 중복 매수 발생.
get_open_position()호출이HOLD브랜치에만 존재하여, BUY 시그널이반복되면 동일 종목이 계속 매수되는 버그.
Changes
src/main.py(+14 lines): BUY 중복 포지션 체크 블록tests/test_main.py(+158 lines): 테스트 2개test_buy_suppressed_when_open_position_exists: 보유 중 재진입 차단 확인test_buy_proceeds_when_no_open_position: 포지션 없을 때 정상 매수 확인Test plan
pytest tests/test_main.py -v -k "buy_suppressed or buy_proceeds"→ 2 passedpytest -v --cov=src→ 733 passed (기존 회귀 없음)Closes #191
🤖 Generated with Claude Code