- sync_positions_from_broker() 함수 추가
- 시스템 시작 시 브로커 잔고를 조회해 DB에 없는 포지션을 BUY 레코드로 삽입
- 국내: get_balance(), 해외: get_overseas_balance(exchange_code) 순회
- ConnectionError는 경고 로그만 남기고 계속 진행 (non-fatal)
- 동일 exchange_code 중복 조회 방지 (seen_exchange_codes 집합)
- run() 초기화 후 최초 한 번 자동 호출
- 국내주식 BUY 이중 방지 로직 확장
- trading_cycle 및 run_daily_session에서 기존에 해외 전용(not market.is_domestic)
으로만 적용하던 broker balance 체크를 국내/해외 공통으로 변경
- _extract_held_qty_from_balance(is_domestic=market.is_domestic)
- 테스트 (827 passed)
- TestSyncPositionsFromBroker (6개): 국내/해외 동기화, 중복 skip, 공란, ConnectionError, dedup
- TestDomesticBuyDoublePreventionTradingCycle (1개): 국내 보유 주식 BUY 억제
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>