feat: 해외주식 미체결 SELL 시 이중 매수 방지 (#195) #200
Reference in New Issue
Block a user
Delete Branch "feature/issue-195-overseas-double-buy-prevention"
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(): DB가 포지션 종료로 기록했더라도 해외 브로커 라이브 잔고(output1)를 추가로 확인해 BUY를 억제run_daily_session(): 동일 패턴의 BUY 중복 방지 로직 신규 추가 (기존엔 없었음)balance_data재사용 → 추가 API 호출 없음Root Cause
KIS VTS SELL 지정가 주문은 접수 즉시
rt_cd=0반환 →log_trade(SELL)기록 → DB 포지션 "종료".다음 사이클에서
get_open_position()= None → BUY 통과 → 이중 매수 발생.Changes
src/main.pytrading_cycle()BUY 게이팅에 브로커 잔고 fallback 추가src/main.pyrun_daily_session()BUY 중복 방지 로직 신규 삽입tests/test_main.pyTestOverseasBrokerIntegration클래스 + 테스트 2개Test plan
test_overseas_buy_suppressed_by_broker_balance_when_db_shows_closed— DB 종료 + 브로커 보유 → BUY 억제test_overseas_buy_proceeds_when_broker_shows_no_holding— DB/브로커 모두 없음 → BUY 진행 (회귀)Closes #195
🤖 Generated with Claude Code