Purpose: Manual test cases to validate the unified interactive CLI with real user interactions
Based on: Issue #334 manual testing + new unified CLI features
Test Environment: Paper trading mode (Alpaca)
Architecture: LLM-based intelligent routing (see docs/architecture/llm_routing_architecture.md)
The CLI uses LLM-based classification instead of hardcoded keyword patterns:
-
LLM Parser determines
request_type:"trade"→ Buy/sell/analyze specific ticker"status_query"→ Account/orders/positions queries
-
Benefits:
- No special cases for ambiguous tickers (ANY, ALL, WHAT, etc.)
- Natural language understanding via context
- Scalable without code changes
-
Fast Keyword Routing for system features:
- Scheduler queries → direct routing (no LLM)
- Alert queries → direct routing (no LLM)
- Trade Execution - Buy/sell orders
- Position Monitoring - Alerts and status checks
- Scheduler Management - Daily automation
- Portfolio Queries - Account information
- Error Handling - Invalid inputs and edge cases
- Natural Language - Various phrasings
- LLM Routing - Ambiguous ticker names (NEW)
Input:
> buy 10 AAPL
Expected Behavior:
- ✅ Routes to trade handler (not alerts/scheduler/portfolio)
- ✅ Fetches current AAPL price
- ✅ Calculates entry/stop/target
- ✅ Shows position sizing (10 shares)
- ✅ Asks for confirmation
- ✅ Places bracket order if confirmed
Known Issues from #334:
⚠️ Off-hours: Shows "could not fetch current market price" → OK (expected)⚠️ Bracket order validation:take_profit.limit_price must be >= base_price + 0.01- Fix needed: Ensure target price is at least $0.01 above entry
Success Criteria:
- Order places successfully during market hours
- Appropriate error message during off-hours
- Bracket order meets Alpaca validation rules
Input:
> is apple at market price a good entry?
Expected Behavior:
- ✅ Interprets "apple" as AAPL
- ✅ Fetches current market price
- ✅ Runs the VotingSignal analysis (MACD+RSI)
- ✅ Presents BUY/SELL/HOLD decision with reasoning
- ✅ Shows entry plan with stop/target
Known Issues from #334:
⚠️ Bracket order validation error (same as 1.1)
Success Criteria:
- Correctly parses "apple" → AAPL
- VotingSignal provides decision
- Order validation passes
Input:
> what about spy at market
Expected Behavior:
⚠️ IMPORTANT: System currently rejects SELL signals (no shorting)- ✅ Should check if SPY position exists
- ✅ If position exists → allow sell
- ✅ If no position → reject with clear message
Known Issues from #334:
- ❌ System tries to short sell instead of checking existing positions
- ❌ Error: "Short selling not supported" even when shares owned
Fix Needed:
# In _handle_trade_request() or execution layer
if signal == "SELL":
positions = self.account_monitor.get_positions()
position = next((p for p in positions if p['symbol'] == ticker), None)
if not position:
print("⚠️ Cannot SELL - no position found")
print(" This system does not support short selling")
return
# Proceed with sell of existing positionSuccess Criteria:
- Checks for existing position before SELL
- Allows sell if position exists
- Rejects sell with clear message if no position
Input (assuming SPY position exists):
> sell all spy
> close my spy position
Expected Behavior:
- ✅ Detects sell intent
- ✅ Checks for existing SPY position
- ✅ Shows current P/L
- ✅ Confirms quantity to sell
- ✅ Places market sell order
Success Criteria:
- Natural language "sell all" parsed correctly
- Position check works
- Sell order places successfully
Input:
> check my alerts
> show alerts
> any position alerts?
Expected Behavior:
- ✅ Routes to
_handle_alerts_request()(not trade handler) - ✅ Fetches current broker state
- ✅ Runs
position_tracker.check_alerts() - ✅ Shows active alerts with severity
- ✅ Shows alert history (last 5)
Output Example:
📊 Checking Position Alerts...
✅ No active alerts
3 position(s) monitored
📜 Alert History (3 total):
• TQQQ - approaching_take_profit at 14:30:00
• SPY - stop_adjusted at 09:25:00
Success Criteria:
- Keyword "alerts" routes correctly
- Alert check executes without errors
- Alert history persists across restarts
Input:
> any positions open
> what positions do I have?
> show my positions
Expected Behavior:
⚠️ KNOWN BUG from #334: Fails with "Invalid ticker format"- ✅ Should route to portfolio handler (not trade handler)
- ✅ Shows list of open positions with P/L
Known Issues from #334:
ValueError: Invalid request: TradeRequest(ticker='', action='review', ...)
- Root cause: Parser tries to extract ticker, fails, creates invalid TradeRequest
- Fix needed: Add "status" routing keyword to bypass trade parser
Fix Needed:
# In _process_request()
if any(word in input_lower for word in ["positions", "position status", "what positions"]):
await self._handle_portfolio_request(user_input)
return # Don't send to trade orchestratorSuccess Criteria:
- "any positions open" routes to portfolio (not trade)
- Shows position list correctly
- No parser errors
Input:
> is there a price target on spy
> what's the target for my aapl position?
Expected Behavior:
- ✅ Checks existing positions
- ✅ Shows take-profit price for that position
- ✅ Shows stop-loss price
- ✅ Shows distance to targets
Known Issues from #334:
- ❌ Parser interprets as new trade request (SELL signal)
- ❌ Tries to short sell instead of checking position details
Fix Needed:
- Route "price target" queries to portfolio handler
- Check position details, don't create new trade
Success Criteria:
- Detects query about existing position
- Shows target/stop prices
- No unwanted trade suggestions
Input:
> show scheduler status
> what's the scheduler doing?
> when is the next routine?
Expected Behavior:
- ✅ Routes to
_handle_scheduler_request() - ✅ Shows configuration (enabled, times)
- ✅ Shows recent execution history
- ✅ Shows next scheduled tasks
Output Example:
🤖 Daily Scheduler Status...
Configuration:
Enabled: True
Morning routine: 09:20:00 ET
Evening routine: 15:50:00 ET
Max retries: 3
📋 Recent Executions (today):
✅ morning_routine - completed
Completed: 2025-01-10T09:20:15
⏰ Scheduled Tasks:
• morning_routine: 09:20 ET
• evening_routine: 15:50 ET
Success Criteria:
- Keyword "scheduler" routes correctly
- Configuration displayed
- Execution history shown
Input:
> show execution history
> what did the scheduler do today?
Expected Behavior:
- ✅ Shows today's executions
- ✅ Status for each (completed/failed/pending)
- ✅ Timestamps and error messages if any
Success Criteria:
- History retrieval works
- Displays last 7 days by default
Input:
> show portfolio
> what's my account balance?
> show account status
Expected Behavior:
- ✅ Routes to
_handle_portfolio_request() - ✅ Shows equity, cash, buying power
- ✅ Shows PDT status
- ✅ Lists all positions with P/L
Output Example:
💼 Portfolio Status...
💰 Account:
Equity: $102,450.00
Cash: $50,225.00
Buying Power: $52,000.00
Pattern Day Trader: False
📊 Positions (3):
🟢 AAPL: 10 shares @ $185.50
Value: $1,855.00
P/L: +$85.00 (+4.58%)
🔴 TQQQ: 100 shares @ $52.00
Value: $5,200.00
P/L: -$200.00 (-3.85%)
Success Criteria:
- Account data fetches correctly
- Position list with P/L shown
- Emojis display correctly (🟢/🔴)
Input:
> how much buying power do I have?
> what's my available cash?
Expected Behavior:
- ✅ Routes to portfolio handler
- ✅ Shows buying power prominently
- ✅ Explains PDT restrictions if applicable
Known Issues from #334:
⚠️ Fallback values shown: "Using fallback buying power: $50,000"- Fix: Ensure Alpaca API credentials valid
Success Criteria:
- Real buying power from Alpaca (no fallback)
- Clear display
Input:
> buy 10 INVALIDTICKER
Expected Behavior:
- ✅ Attempts to fetch data
- ✅ Detects invalid ticker
- ✅ Shows helpful error message
Current Behavior from #334:
❌ Invalid ticker symbol
The ticker you entered was not recognized by the market.
Please check the spelling and try again.
Example: AAPL (not APPL), TSLA, SPY, MSFT
Success Criteria:
- Helpful error message shown
- Suggests valid alternatives
- Doesn't crash
Input:
> what's the weather today?
> tell me a joke
Expected Behavior:
⚠️ Currently: Tries to parse as trade request → fails- ✅ Should: Detect out-of-scope, show help message
Fix Needed:
- Add fallback handler for unrecognized intents
- Show available command categories
Success Criteria:
- Graceful handling of non-trading requests
- Suggests valid commands
Input:
> spy
> aapl?
Expected Behavior:
- ✅ Detects insufficient context
- ✅ Asks clarifying question: "Did you mean buy, sell, or check status for SPY?"
Success Criteria:
- Doesn't assume action
- Prompts for clarification
Inputs to test:
> buy 10 shares of apple
> purchase aapl
> long spy
> get into tqqq
> open a position in msft
Expected Behavior:
- ✅ All interpreted as BUY intent
- ✅ Ticker extracted correctly
- ✅ Same trade flow triggered
Success Criteria:
- 5/5 phrasings work correctly
Inputs to test:
> check my positions
> show me what I own
> any open trades?
> position status
> what do I have?
Expected Behavior:
- ✅ All route to portfolio handler
- ✅ Show position list
Success Criteria:
- 5/5 phrasings route correctly
- No parser errors
Inputs to test:
> check alerts
> show position alerts
> any approaching targets?
> alert status
> what alerts do I have?
Expected Behavior:
- ✅ All route to alerts handler
- ✅ Check alerts successfully
Success Criteria:
- 5/5 phrasings route correctly
Run tests in market hours:
- Test 1.1 - Simple buy ✅
- Test 2.1 - Check alerts ✅
- Test 3.1 - Scheduler status ✅
- Test 4.1 - Portfolio status ✅
Goal: Verify all 4 main features work
Fix known issues from #334:
- Test 1.3 - Sell signal handling (fix position check)
- Test 2.2 - Position status query (fix routing)
- Test 2.3 - Price target query (fix routing)
Goal: Address all #334 failures
- Test 5.1 - Invalid ticker
- Test 5.2 - Out of scope
- Test 5.3 - Ambiguous requests
Goal: Graceful error handling
- Test 6.1 - Buy variations (5 phrases)
- Test 6.2 - Status variations (5 phrases)
- Test 6.3 - Alert variations (5 phrases)
Goal: Verify LLM routing robustness
Use this format to document results:
### Test X.Y: [Test Name]
**Date:** 2025-01-10
**Tester:** [Name]
**Environment:** Paper trading
**Input:**
> [exact user input]
**Expected:**
[what should happen]
**Actual:**
[what actually happened]
**Status:** ✅ PASS / ❌ FAIL / ⚠️ PARTIAL
**Notes:**
[any observations, errors, improvements needed]
**Screenshots/Logs:**
[paste relevant output]For rapid testing, use this sequence:
python main.py
# Test all 4 features quickly
> check my alerts # Alerts handler
> show scheduler status # Scheduler handler
> show portfolio # Portfolio handler
> buy 1 spy # Trade handler (cancel before confirming)
# Test known bugs
> any positions open # Should show portfolio (not error)
> is there a target on spy # Should show position details (not sell)
# Exit
> /exitExpected: All 6 commands work without errors
Error: take_profit.limit_price must be >= base_price + 0.01
Location: src/execution/alpaca_execution_manager.py:189
Fix: Ensure target price ≥ entry + $0.01 in risk manager
Error: Rejects SELL even when position exists
Location: CLI session or execution manager
Fix: Check positions before rejecting SELL signals
Error: Invalid request: TradeRequest(ticker='', ...)
Location: Input parser trying to extract ticker from status query
Fix: Add routing keywords for status queries
Error: "Using fallback portfolio value: $100,000" repeats
Location: Unknown - needs investigation
Fix: Check logging configuration
Purpose: Test LLM's ability to distinguish between status queries and ticker names
Architecture: LLM parser classifies request_type before extracting ticker
Input:
> any open orders?
> any positions?
> any alerts?
Expected Behavior:
- ✅ LLM classifies as
request_type = "status_query" - ✅ Routes to appropriate status handler (orders/positions/alerts)
- ✅ Does NOT attempt to analyze ticker "ANY"
- ✅ No "could not fetch data for ANY" errors
LLM Classification:
- Context: Question word "any" + status keywords
- No trading intent (buy/sell/analyze)
- Result: status_query
Success Criteria:
- All 3 variations route to status handlers
- No ticker parsing errors
- Shows correct status information
Input:
> buy ANY
> is ANY a good buy?
> analyze ticker ANY
Expected Behavior:
- ✅ LLM classifies as
request_type = "trade" - ✅ Extracts ticker = "ANY"
- ✅ Routes to trade handler
- ✅ Fetches market data for ticker ANY (if exists)
LLM Classification:
- Context: Trading action verbs (buy/analyze)
- Specific ticker mentioned in trading context
- Result: trade request with ticker=ANY
Success Criteria:
- All 3 variations route to trade handler
- Ticker extracted as "ANY"
- Attempts to analyze/execute trade
Tickers to Test:
- WHAT, WHO, WHEN, WHERE, WHY, HOW
- ALL, SOME, EVERY
- CHECK, SHOW, LIST
Status Query Inputs:
> what positions do I have?
> what's my portfolio?
> show me my orders
Expected: Routes to status handlers (not ticker lookup)
Trade Request Inputs:
> buy WHAT at market
> is WHO a good investment?
> analyze ticker SHOW
Expected: Routes to trade handler with ticker extracted
Success Criteria:
- Status queries: 0% ticker misinterpretation
- Trade requests: 100% correct ticker extraction
- LLM uses context, not just word matching
Input:
> show me my SPY position
> what's the price target on AAPL?
> any open orders for TQQQ?
Expected Behavior:
- ✅ LLM classifies as
request_type = "status_query" - ✅ Extracts specific ticker: SPY, AAPL, TQQQ
- ✅ Routes to portfolio handler
- ✅ Shows position details for that ticker
LLM Classification:
- Context: Asking about existing position/orders
- No intent to create new trade
- Result: status_query with ticker specified
Success Criteria:
- Routes to status handler (not trade)
- Ticker extracted correctly
- Shows specific ticker's status
Input 1: "any"
> any
Expected:
- LLM classifies as ambiguous/insufficient
- Asks for clarification OR defaults to status query
Input 2: "buy anything"
> buy anything
Expected:
- LLM interprets "anything" as unclear ticker
- Should error with "please specify ticker"
Input 3: "is there anything I should know?"
> is there anything I should know?
Expected:
- LLM classifies as general status query
- Routes to portfolio/alerts summary
Success Criteria:
- Graceful handling of ambiguous inputs
- Clear error messages when ticker unclear
- No false positives on ticker extraction
Purpose: Verify LLM is using context, not just keywords
Test Pairs: Same word, different contexts
Pair 1: "check"
> check my alerts → status_query (system feature)
> check ticker CHECK → trade (ticker lookup)
Pair 2: "what"
> what positions? → status_query
> buy WHAT → trade (ticker=WHAT)
Pair 3: "show"
> show portfolio → status_query
> show me analysis of SHOW → trade (ticker=SHOW)
Success Criteria:
- 100% accuracy on paired tests
- Context determines routing, not keyword alone
- LLM logs show correct reasoning
Total Test Cases: 25+ routing scenarios
Categories Covered:
- Ambiguous ticker words (ANY, WHAT, etc.)
- Status queries vs trade requests
- Compound queries (ticker + status)
- Edge cases and clarifications
- Context-based disambiguation
Success Metrics:
- Status query accuracy: ≥ 95%
- Trade request accuracy: ≥ 95%
- Zero ticker misinterpretations for common words
- Fast keyword routing still works (scheduler/alerts)
Regression Testing:
- All previous tests (Categories 1-6) must still pass
- No performance degradation
- LLM calls only when needed (not for scheduler/alerts)
Test Suite Completion:
- 15+ core test cases executed
- All Priority 1 tests passing
- Known bugs from #334 fixed
- Natural language variations working
User Experience:
- No confusing errors
- Clear routing to correct handlers
- Helpful error messages
- Intuitive command flow
Documentation:
- Test results documented
- Known issues tracked
- Fix recommendations provided