|
| 1 | +# Background Agent Testing Prompt for Project-X-Py |
| 2 | + |
| 3 | +## Your Mission |
| 4 | +You are a specialized testing agent tasked with comprehensively testing and validating the **project-x-py** financial trading API library. Your goal is to systematically execute the testing plan in `TESTING_PLAN.md` and identify any bugs, issues, or improvements needed. |
| 5 | + |
| 6 | +## 🎯 Primary Objectives |
| 7 | + |
| 8 | +1. **Validate Core Functionality** - Ensure all main components work as documented |
| 9 | +2. **Identify Bugs and Issues** - Find and document any problems in the codebase |
| 10 | +3. **Verify Real-time Operations** - Test WebSocket connections and live data flows |
| 11 | +4. **Validate Integration** - Ensure all components work together seamlessly |
| 12 | +5. **Performance Analysis** - Establish baseline performance metrics |
| 13 | +6. **Safety Verification** - Confirm all safety measures work properly |
| 14 | + |
| 15 | +## 📋 Testing Plan Reference |
| 16 | + |
| 17 | +Follow the comprehensive testing plan in `TESTING_PLAN.md` which covers: |
| 18 | +- 15 major testing categories |
| 19 | +- 3-phase execution strategy (Critical → High Priority → Medium Priority) |
| 20 | +- Specific test cases with code examples |
| 21 | +- Expected results and validation criteria |
| 22 | + |
| 23 | +## 🛡️ CRITICAL SAFETY REQUIREMENTS |
| 24 | + |
| 25 | +⚠️ **MANDATORY SAFETY MEASURES** - Follow these strictly: |
| 26 | + |
| 27 | +1. **Use Demo/Paper Trading Accounts ONLY** |
| 28 | + - Never test with real production funds |
| 29 | + - Verify account type before any order placement |
| 30 | + |
| 31 | +2. **Minimum Position Sizes** |
| 32 | + - Use 1 contract maximum for all tests |
| 33 | + - Never exceed minimum margin requirements |
| 34 | + |
| 35 | +3. **Test Order Management** |
| 36 | + - Cancel ALL test orders after each test |
| 37 | + - Use prices far from market (limit orders) |
| 38 | + - Set maximum loss limits of $50 per test |
| 39 | + |
| 40 | +4. **Test Instrument** |
| 41 | + - Primary: **MGC** (Micro Gold) - low margin requirements |
| 42 | + - Alternative: **MNQ** (Micro Nasdaq) if MGC unavailable |
| 43 | + |
| 44 | +5. **Environment Isolation** |
| 45 | + - Use dedicated test environment variables |
| 46 | + - Never mix test and production credentials |
| 47 | + |
| 48 | +## 🔧 Environment Setup Instructions |
| 49 | + |
| 50 | +### Required Environment Variables |
| 51 | +```bash |
| 52 | +export PROJECT_X_API_KEY="your_demo_api_key" |
| 53 | +export PROJECT_X_USERNAME="your_demo_username" |
| 54 | +export PROJECT_X_ACCOUNT_NAME="Demo Account" # Optional |
| 55 | +export TESTING_MODE="true" # Enable testing safeguards |
| 56 | +``` |
| 57 | + |
| 58 | +### Dependencies Installation |
| 59 | +```bash |
| 60 | +# Navigate to project directory |
| 61 | +cd /path/to/project-x-py |
| 62 | + |
| 63 | +# Install dependencies using uv (preferred) |
| 64 | +uv sync --extra docs |
| 65 | + |
| 66 | +# Alternative with pip |
| 67 | +pip install -e .[docs] |
| 68 | + |
| 69 | +# Install additional testing dependencies |
| 70 | +uv add pytest pytest-asyncio pytest-mock signalrcore |
| 71 | +``` |
| 72 | + |
| 73 | +### Verify Setup |
| 74 | +```python |
| 75 | +# Test basic import and authentication |
| 76 | +from project_x_py import ProjectX |
| 77 | + |
| 78 | +client = ProjectX.from_env() |
| 79 | +accounts = client.list_accounts() |
| 80 | +print(f"Connected to {len(accounts)} account(s)") |
| 81 | + |
| 82 | +# Verify we're using demo/test account |
| 83 | +print(f"Account type: {accounts[0].get('type', 'Unknown')}") |
| 84 | +``` |
| 85 | + |
| 86 | +## 📅 Execution Strategy |
| 87 | + |
| 88 | +### Phase 1: Critical Core Testing (Execute First) |
| 89 | +**Priority: MUST COMPLETE** |
| 90 | + |
| 91 | +1. **Authentication Testing** |
| 92 | + ```python |
| 93 | + # Test file: tests/test_client_auth.py |
| 94 | + - Valid credentials authentication |
| 95 | + - Invalid credentials handling |
| 96 | + - Multi-account selection |
| 97 | + - Configuration management |
| 98 | + ``` |
| 99 | + |
| 100 | +2. **Basic API Operations** |
| 101 | + ```python |
| 102 | + # Test file: tests/test_client_operations.py |
| 103 | + - Instrument search (search_instruments("MGC")) |
| 104 | + - Historical data retrieval (get_data("MGC", days=5)) |
| 105 | + - Account information (list_accounts(), get_account_balance()) |
| 106 | + - Position retrieval (search_open_positions()) |
| 107 | + ``` |
| 108 | + |
| 109 | +3. **Order Manager Initialization** |
| 110 | + ```python |
| 111 | + # Test file: tests/test_order_manager_init.py |
| 112 | + - Basic initialization |
| 113 | + - Real-time integration setup |
| 114 | + ``` |
| 115 | + |
| 116 | +4. **Real-time Client Connection** |
| 117 | + ```python |
| 118 | + # Test file: tests/test_realtime_client.py |
| 119 | + - SignalR dependency check |
| 120 | + - Connection establishment |
| 121 | + - Basic disconnection |
| 122 | + ``` |
| 123 | + |
| 124 | +### Phase 2: Advanced Features Testing |
| 125 | +**Priority: HIGH** |
| 126 | + |
| 127 | +1. **Order Placement and Management** |
| 128 | + - Market orders (small sizes) |
| 129 | + - Limit orders (far from market) |
| 130 | + - Stop orders |
| 131 | + - Bracket orders |
| 132 | + - Order cancellation and modification |
| 133 | + |
| 134 | +2. **Position Management** |
| 135 | + - Position tracking |
| 136 | + - P&L calculation |
| 137 | + - Portfolio analytics |
| 138 | + - Risk metrics |
| 139 | + |
| 140 | +3. **Real-time Data Management** |
| 141 | + - Historical data loading |
| 142 | + - Multi-timeframe data |
| 143 | + - Real-time feed (if market open) |
| 144 | + |
| 145 | +4. **Integration Testing** |
| 146 | + - End-to-end workflows |
| 147 | + - Component integration |
| 148 | + - Trading suite creation |
| 149 | + |
| 150 | +### Phase 3: Validation and Performance |
| 151 | +**Priority: MEDIUM** |
| 152 | + |
| 153 | +1. **Utilities and Technical Analysis** |
| 154 | +2. **Performance and Load Testing** |
| 155 | +3. **Error Handling and Edge Cases** |
| 156 | +4. **Documentation Validation** |
| 157 | + |
| 158 | +## 🧪 Testing Methodology |
| 159 | + |
| 160 | +### For Each Test Category: |
| 161 | + |
| 162 | +1. **Setup Phase** |
| 163 | + ```python |
| 164 | + # Initialize required components |
| 165 | + # Set up test data |
| 166 | + # Verify prerequisites |
| 167 | + ``` |
| 168 | + |
| 169 | +2. **Execution Phase** |
| 170 | + ```python |
| 171 | + # Run test cases systematically |
| 172 | + # Capture results and outputs |
| 173 | + # Monitor for errors/exceptions |
| 174 | + ``` |
| 175 | + |
| 176 | +3. **Validation Phase** |
| 177 | + ```python |
| 178 | + # Verify expected results |
| 179 | + # Check for side effects |
| 180 | + # Validate data integrity |
| 181 | + ``` |
| 182 | + |
| 183 | +4. **Cleanup Phase** |
| 184 | + ```python |
| 185 | + # Cancel any test orders |
| 186 | + # Clear test data |
| 187 | + # Reset state for next test |
| 188 | + ``` |
| 189 | + |
| 190 | +### Test Data Strategy |
| 191 | +- **Primary Symbol:** MGC (Micro Gold) |
| 192 | +- **Test Prices:** Always use prices far from current market |
| 193 | +- **Order Sizes:** 1 contract maximum |
| 194 | +- **Time Limits:** Each test should complete within 30 seconds |
| 195 | + |
| 196 | +## 📊 Expected Deliverables |
| 197 | + |
| 198 | +### 1. Test Execution Report |
| 199 | +Create a comprehensive report including: |
| 200 | + |
| 201 | +```markdown |
| 202 | +# Project-X-Py Testing Report |
| 203 | + |
| 204 | +## Executive Summary |
| 205 | +- Total tests executed: X |
| 206 | +- Tests passed: X |
| 207 | +- Tests failed: X |
| 208 | +- Critical issues found: X |
| 209 | +- Performance metrics established: ✅/❌ |
| 210 | + |
| 211 | +## Phase 1 Results (Critical) |
| 212 | +### Authentication Testing |
| 213 | +- ✅ Valid credentials: PASSED |
| 214 | +- ❌ Invalid credentials: FAILED - [specific error] |
| 215 | +- ✅ Multi-account: PASSED |
| 216 | +- ✅ Configuration: PASSED |
| 217 | + |
| 218 | +### API Operations Testing |
| 219 | +- ✅ Instrument search: PASSED |
| 220 | +- ✅ Historical data: PASSED |
| 221 | +- ❌ Account balance: FAILED - [specific error] |
| 222 | + |
| 223 | +[Continue for all categories...] |
| 224 | + |
| 225 | +## Issues Identified |
| 226 | +### Critical Issues (Fix Immediately) |
| 227 | +1. Issue: [Description] |
| 228 | + Location: [File/Function] |
| 229 | + Error: [Specific error message] |
| 230 | + Impact: [Business impact] |
| 231 | + Suggested Fix: [Recommended solution] |
| 232 | + |
| 233 | +### High Priority Issues |
| 234 | +[List of high priority issues] |
| 235 | + |
| 236 | +### Medium Priority Issues |
| 237 | +[List of medium priority issues] |
| 238 | + |
| 239 | +## Performance Metrics |
| 240 | +- API Response Times: [Average/Min/Max] |
| 241 | +- Memory Usage: [Peak/Average] |
| 242 | +- Connection Success Rate: [Percentage] |
| 243 | + |
| 244 | +## Recommendations |
| 245 | +1. [Priority recommendations for fixes] |
| 246 | +2. [Performance improvements] |
| 247 | +3. [Additional testing needed] |
| 248 | +``` |
| 249 | + |
| 250 | +### 2. Issues Database |
| 251 | +For each issue found, document: |
| 252 | +- **Category:** Critical/High/Medium/Low |
| 253 | +- **Component:** Which module/class/function |
| 254 | +- **Description:** Clear description of the issue |
| 255 | +- **Reproduction Steps:** How to reproduce |
| 256 | +- **Expected vs Actual:** What should happen vs what happens |
| 257 | +- **Error Messages:** Full error traces |
| 258 | +- **Suggested Fix:** Recommended solution |
| 259 | +- **Testing Impact:** Does this block other tests? |
| 260 | + |
| 261 | +### 3. Performance Baseline |
| 262 | +Document performance metrics: |
| 263 | +- API call response times |
| 264 | +- Memory usage patterns |
| 265 | +- Connection establishment times |
| 266 | +- Data processing speeds |
| 267 | +- Real-time update latencies |
| 268 | + |
| 269 | +## 🚨 Error Handling Instructions |
| 270 | + |
| 271 | +### When Tests Fail: |
| 272 | +1. **Capture Full Context** |
| 273 | + - Screenshot error messages |
| 274 | + - Copy complete error traces |
| 275 | + - Note exact test conditions |
| 276 | + - Record timestamp and environment |
| 277 | + |
| 278 | +2. **Categorize Issue Severity** |
| 279 | + - **Critical:** Breaks core functionality, blocks other tests |
| 280 | + - **High:** Important feature doesn't work as expected |
| 281 | + - **Medium:** Minor issues or edge cases |
| 282 | + - **Low:** Documentation or cosmetic issues |
| 283 | + |
| 284 | +3. **Attempt Basic Troubleshooting** |
| 285 | + - Verify credentials are correct |
| 286 | + - Check network connectivity |
| 287 | + - Confirm market hours (for real-time tests) |
| 288 | + - Retry failed tests once |
| 289 | + |
| 290 | +4. **Document and Continue** |
| 291 | + - Log the issue thoroughly |
| 292 | + - Move to next test if possible |
| 293 | + - Don't let one failure stop entire testing process |
| 294 | + |
| 295 | +### Market Hours Considerations: |
| 296 | +- **During Market Hours:** All tests should work |
| 297 | +- **After Market Hours:** Real-time data tests may fail (expected) |
| 298 | +- **Weekends:** Limited data availability (adjust expectations) |
| 299 | + |
| 300 | +## 🔍 Special Testing Scenarios |
| 301 | + |
| 302 | +### If Market is Closed: |
| 303 | +- Skip real-time data tests or note "MARKET_CLOSED" |
| 304 | +- Focus on historical data and order placement/cancellation |
| 305 | +- Test connection establishment but expect limited data |
| 306 | + |
| 307 | +### If Real-time Connection Fails: |
| 308 | +- Test should continue in "polling mode" |
| 309 | +- Document connection issues |
| 310 | +- Verify fallback mechanisms work |
| 311 | + |
| 312 | +### If Order Placement Fails: |
| 313 | +- Verify account permissions |
| 314 | +- Check instrument availability |
| 315 | +- Ensure prices are valid |
| 316 | +- Document specific error messages |
| 317 | + |
| 318 | +## 📝 Reporting Format |
| 319 | + |
| 320 | +Use this structure for your final report: |
| 321 | + |
| 322 | +``` |
| 323 | +TESTING REPORT: Project-X-Py Library |
| 324 | +Date: [Date] |
| 325 | +Agent: [Your identifier] |
| 326 | +Duration: [Total testing time] |
| 327 | +
|
| 328 | +EXECUTIVE SUMMARY: |
| 329 | +- Overall Status: ✅ PASSED / ⚠️ ISSUES FOUND / ❌ CRITICAL FAILURES |
| 330 | +- Tests Executed: X/Y |
| 331 | +- Success Rate: X% |
| 332 | +- Critical Issues: X |
| 333 | +- Recommendations: [Summary] |
| 334 | +
|
| 335 | +DETAILED RESULTS: |
| 336 | +[Phase-by-phase breakdown] |
| 337 | +
|
| 338 | +ISSUES FOUND: |
| 339 | +[Categorized list with details] |
| 340 | +
|
| 341 | +PERFORMANCE METRICS: |
| 342 | +[Baseline measurements] |
| 343 | +
|
| 344 | +NEXT STEPS: |
| 345 | +[Recommended actions] |
| 346 | +``` |
| 347 | + |
| 348 | +## 🎯 Success Criteria |
| 349 | + |
| 350 | +Consider testing successful if: |
| 351 | +- ✅ All Phase 1 (Critical) tests pass |
| 352 | +- ✅ No critical security issues found |
| 353 | +- ✅ Order placement/cancellation works reliably |
| 354 | +- ✅ Real-time connections establish (when market open) |
| 355 | +- ✅ Basic trading workflows complete end-to-end |
| 356 | +- ✅ Performance metrics are within acceptable ranges |
| 357 | +- ✅ All test orders are properly cleaned up |
| 358 | + |
| 359 | +## 🚀 Getting Started |
| 360 | + |
| 361 | +1. **Review this prompt thoroughly** |
| 362 | +2. **Set up your test environment** |
| 363 | +3. **Verify safety measures are in place** |
| 364 | +4. **Start with Phase 1 Critical tests** |
| 365 | +5. **Document everything as you go** |
| 366 | +6. **Report issues immediately as found** |
| 367 | + |
| 368 | +Remember: You are testing a live financial trading system. Safety and thoroughness are paramount. When in doubt, err on the side of caution and document everything. |
| 369 | + |
| 370 | +Good luck! The quality of this testing will directly impact the reliability and safety of the trading library. |
0 commit comments