feat: implement trading control commands /stop and /resume (issue #65) #66

Merged
jihoson merged 1 commits from feature/issue-65-trading-control into main 2026-02-05 15:17:35 +09:00
Collaborator

Summary

  • Add remote trading control via /stop and /resume Telegram commands
  • Implement pause_trading Event for safe trading suspension
  • Integrate pause logic into both daily and realtime trading loops

Changes

  • src/main.py: Add pause_trading Event, /stop and /resume handlers, integrate pause logic
  • tests/test_telegram_commands.py: Add 4 tests for trading control

Features

  • /stop: Pauses all trading operations with confirmation message
  • /resume: Resumes trading operations with confirmation
  • Idempotent: Gracefully handles repeated stop/resume commands
  • Status Feedback: Informs user if trading is already paused/active
  • Mode Support: Works in both daily and realtime trading modes

Safety

  • Trading loops wait on pause_trading.wait() - no active polling
  • Circuit breakers and risk management remain active during pause
  • Commands verified by TelegramCommandHandler chat_id check
  • Clean integration with existing shutdown mechanism

Test plan

  • All tests pass (22/22 for telegram_commands)
  • /stop command pauses trading (clears Event)
  • /resume command resumes trading (sets Event)
  • Repeated stop/resume handled gracefully
  • Both daily and realtime loops integrate pause logic

Closes #65
Depends on #63

🤖 Generated with Claude Code

## Summary - Add remote trading control via /stop and /resume Telegram commands - Implement pause_trading Event for safe trading suspension - Integrate pause logic into both daily and realtime trading loops ## Changes - `src/main.py`: Add pause_trading Event, /stop and /resume handlers, integrate pause logic - `tests/test_telegram_commands.py`: Add 4 tests for trading control ## Features - **/stop**: Pauses all trading operations with confirmation message - **/resume**: Resumes trading operations with confirmation - **Idempotent**: Gracefully handles repeated stop/resume commands - **Status Feedback**: Informs user if trading is already paused/active - **Mode Support**: Works in both daily and realtime trading modes ## Safety - Trading loops wait on `pause_trading.wait()` - no active polling - Circuit breakers and risk management remain active during pause - Commands verified by TelegramCommandHandler chat_id check - Clean integration with existing shutdown mechanism ## Test plan - [x] All tests pass (22/22 for telegram_commands) - [x] /stop command pauses trading (clears Event) - [x] /resume command resumes trading (sets Event) - [x] Repeated stop/resume handled gracefully - [x] Both daily and realtime loops integrate pause logic ## Related Issues Closes #65 Depends on #63 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agentson added 1 commit 2026-02-05 15:11:58 +09:00
feat: implement trading control commands /stop and /resume (issue #65)
Some checks failed
CI / test (pull_request) Has been cancelled
70701bf73a
Add pause/resume functionality for remote trading control via Telegram.

Changes:
- Add pause_trading Event to main.py
- Implement /stop handler (pause trading)
- Implement /resume handler (resume trading)
- Integrate pause logic into both daily and realtime trading loops
- Add 4 comprehensive tests for trading control

Features:
- /stop: Pauses all trading operations
- /resume: Resumes trading operations
- Idempotent: Handles repeated stop/resume gracefully
- Status feedback: Informs if already paused/active
- Works in both daily and realtime trading modes

Security:
- Commands verified by TelegramCommandHandler chat_id check
- Only authorized users can control trading

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
jihoson merged commit a7696568cc into main 2026-02-05 15:17:35 +09:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#66