fix: SELL order quantity hardcoded to 1, ignores actual held position size #164

Closed
opened 2026-02-20 02:58:45 +09:00 by agentson · 0 comments
Collaborator

문제

_determine_order_quantity() 함수가 SELL 주문 시 항상 1을 반환한다.

# main.py:118-119
if action != 'BUY':
    return 1  # ← 실제 보유 수량 무시

영향

  • 10주를 보유 중이어도 1주만 매도
  • 실질적으로 전량 청산이 불가능
  • P&L 계산도 부정확해짐

개선

SELL 시 DB에서 실제 보유 수량 조회 후 사용:

if action == 'SELL':
    open_pos = get_open_position(db_conn, stock_code, market_code)
    return open_pos['quantity'] if open_pos else 0

_determine_order_quantity에 db_conn, stock_code, market_code 파라미터 추가 필요.

테스트

  • SELL 시 보유 수량 전량 반환 검증
  • 보유 포지션 없을 때 0 반환 검증
  • BUY 로직 기존 동작 유지 검증
## 문제 _determine_order_quantity() 함수가 SELL 주문 시 항상 1을 반환한다. ```python # main.py:118-119 if action != 'BUY': return 1 # ← 실제 보유 수량 무시 ``` ## 영향 - 10주를 보유 중이어도 1주만 매도 - 실질적으로 전량 청산이 불가능 - P&L 계산도 부정확해짐 ## 개선 SELL 시 DB에서 실제 보유 수량 조회 후 사용: ```python if action == 'SELL': open_pos = get_open_position(db_conn, stock_code, market_code) return open_pos['quantity'] if open_pos else 0 ``` _determine_order_quantity에 db_conn, stock_code, market_code 파라미터 추가 필요. ## 테스트 - SELL 시 보유 수량 전량 반환 검증 - 보유 포지션 없을 때 0 반환 검증 - BUY 로직 기존 동작 유지 검증
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#164