Implement trading control commands (/stop, /resume) #65

Closed
opened 2026-02-05 14:38:32 +09:00 by agentson · 0 comments
Collaborator

목표

거래 제어 명령어 /stop과 /resume 구현

세부사항

  • /stop: 거래를 일시 중지
  • /resume: 거래를 재개
  • main.py에 pause_trading Event 추가
  • 거래 루프에 pause 상태 확인 로직 통합

구현 내용

1. pause_trading Event

pause_trading = asyncio.Event()
pause_trading.set()  # 기본: 거래 활성

2. /stop 핸들러

  • pause_trading.clear() 호출
  • "⏸️ 거래가 일시 중지되었습니다" 응답

3. /resume 핸들러

  • pause_trading.set() 호출
  • "▶️ 거래가 재개되었습니다" 응답

4. 거래 루프 통합

while not shutdown.is_set():
    await pause_trading.wait()  # pause 해제될 때까지 대기
    # ... 기존 거래 로직

보안 고려사항

  • 이미 TelegramCommandHandler가 chat_id 검증 수행
  • 권한 있는 사용자만 거래 제어 가능

체크리스트

  • pause_trading Event 추가
  • /stop 핸들러 구현
  • /resume 핸들러 구현
  • 거래 루프에 pause 로직 통합 (daily 모드 포함)
  • 테스트 추가
  • 커버리지 80% 이상 유지

의존성

  • Depends on #63 (basic commands)

관련 이슈

Part of Telegram bidirectional command feature implementation

## 목표 거래 제어 명령어 /stop과 /resume 구현 ## 세부사항 - /stop: 거래를 일시 중지 - /resume: 거래를 재개 - main.py에 pause_trading Event 추가 - 거래 루프에 pause 상태 확인 로직 통합 ## 구현 내용 ### 1. pause_trading Event ```python pause_trading = asyncio.Event() pause_trading.set() # 기본: 거래 활성 ``` ### 2. /stop 핸들러 - pause_trading.clear() 호출 - "⏸️ 거래가 일시 중지되었습니다" 응답 ### 3. /resume 핸들러 - pause_trading.set() 호출 - "▶️ 거래가 재개되었습니다" 응답 ### 4. 거래 루프 통합 ```python while not shutdown.is_set(): await pause_trading.wait() # pause 해제될 때까지 대기 # ... 기존 거래 로직 ``` ## 보안 고려사항 - 이미 TelegramCommandHandler가 chat_id 검증 수행 - 권한 있는 사용자만 거래 제어 가능 ## 체크리스트 - [ ] pause_trading Event 추가 - [ ] /stop 핸들러 구현 - [ ] /resume 핸들러 구현 - [ ] 거래 루프에 pause 로직 통합 (daily 모드 포함) - [ ] 테스트 추가 - [ ] 커버리지 80% 이상 유지 ## 의존성 - Depends on #63 (basic commands) ## 관련 이슈 Part of Telegram bidirectional command feature implementation
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#65