feat: implement status query commands /status and /positions (issue #67) #68

Merged
jihoson merged 1 commits from feature/issue-67-status-commands into main 2026-02-05 15:34:16 +09:00
Collaborator

Summary

  • Add /status command for real-time trading status monitoring
  • Add /positions command for portfolio viewing
  • Integrate with Broker API and RiskManager for live data

Changes

  • src/main.py: Implement /status and /positions handlers with API integration
  • tests/test_telegram_commands.py: Add 5 tests for status commands

Features

/status

  • Trading mode (PAPER/LIVE)
  • Enabled markets list
  • Trading state (Active/Paused)
  • Current P&L percentage
  • Circuit breaker threshold

/positions

  • Holdings grouped by market (Korea 🇰🇷, Overseas 🇺🇸)
  • Stock code, quantity, and average price
  • Total cash balance
  • Empty state handling (no positions message)

Error Handling

  • Graceful degradation on API failures
  • User-friendly error messages
  • Logging for debugging
  • P&L calculation fallback (shows N/A on error)

Test plan

  • All tests pass (27/27 for telegram_commands)
  • /status shows trading information
  • /positions displays holdings with market grouping
  • Empty portfolio handled gracefully
  • Error states handled with appropriate messages

Closes #67
Depends on #65

🤖 Generated with Claude Code

## Summary - Add /status command for real-time trading status monitoring - Add /positions command for portfolio viewing - Integrate with Broker API and RiskManager for live data ## Changes - `src/main.py`: Implement /status and /positions handlers with API integration - `tests/test_telegram_commands.py`: Add 5 tests for status commands ## Features ### /status - Trading mode (PAPER/LIVE) - Enabled markets list - Trading state (Active/Paused) - Current P&L percentage - Circuit breaker threshold ### /positions - Holdings grouped by market (Korea 🇰🇷, Overseas 🇺🇸) - Stock code, quantity, and average price - Total cash balance - Empty state handling (no positions message) ## Error Handling - Graceful degradation on API failures - User-friendly error messages - Logging for debugging - P&L calculation fallback (shows N/A on error) ## Test plan - [x] All tests pass (27/27 for telegram_commands) - [x] /status shows trading information - [x] /positions displays holdings with market grouping - [x] Empty portfolio handled gracefully - [x] Error states handled with appropriate messages ## Related Issues Closes #67 Depends on #65 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agentson added 1 commit 2026-02-05 15:33:39 +09:00
feat: implement status query commands /status and /positions (issue #67)
Some checks failed
CI / test (pull_request) Has been cancelled
57a45a24cb
Add real-time status and portfolio monitoring via Telegram.

Changes:
- Implement /status handler (mode, markets, P&L, trading state)
- Implement /positions handler (holdings with grouping by market)
- Integrate with Broker API and RiskManager
- Add 5 comprehensive tests for status commands

Features:
- /status: Shows trading mode, enabled markets, pause state, P&L, circuit breaker
- /positions: Lists holdings grouped by market (domestic/overseas)
- Error handling: Graceful degradation on API failures
- Empty state: Handles portfolios with no positions

Integration:
- Uses broker.get_balance() for account data
- Uses risk.calculate_pnl() for P&L calculation
- Accesses pause_trading.is_set() for trading state
- Groups positions by market for better readability

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
jihoson merged commit 462f8763ab into main 2026-02-05 15:34:16 +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#68