Skip to content

Latest commit

Β 

History

History
260 lines (182 loc) Β· 7.08 KB

File metadata and controls

260 lines (182 loc) Β· 7.08 KB

Strategy Management System

Overview

The Strategy Management System provides a comprehensive interface for managing, editing, and monitoring trading strategies with integrated queue management for execution.

Features

🎯 Strategy Detail Page

  • URL Pattern: /strategy/{strategyId}
  • Comprehensive Strategy View: Full strategy details, performance metrics, and execution history
  • Live Editing: Edit strategy configuration in real-time
  • Queue-Aware Updates: Intelligent handling of active strategies in the execution queue

βš™οΈ Queue Management

  • Automatic Queue Handling: When editing active strategies, the system automatically:
    1. Pauses strategy execution
    2. Applies configuration changes
    3. Resumes strategy in the queue
  • Zero Downtime Updates: Seamless strategy updates without losing queue position
  • Execution Status Tracking: Real-time visibility into strategy execution status

πŸ“Š Performance Monitoring

  • Real-Time Metrics: Live performance tracking with P&L, win rate, and trade statistics
  • Execution Logs: Detailed execution history with filtering and status tracking
  • Visual Indicators: Color-coded status badges and performance indicators

Page Structure

Tabs Navigation

  1. Overview: Strategy information, performance metrics, and key statistics
  2. Rules: Strategy rules management with form-based editing
  3. Configuration: Risk management and execution settings
  4. Logs: Execution history and performance tracking

Key Components

Strategy Header

  • Strategy name, status, and version information
  • Action buttons: Edit, Execute, Pause/Resume, Save
  • Queue status indicators

Performance Dashboard

- Net P&L: Real-time profit/loss tracking
- Win Rate: Success percentage of executed trades
- Total Trades: Cumulative trade count
- Profit Factor: Risk-adjusted performance metric

Rule Editor

  • Visual rule configuration interface
  • Condition and action setup
  • Priority and cooldown management
  • Active/inactive toggle per rule

Configuration Manager

  • Risk management settings
  • Position sizing controls
  • Portfolio allocation limits
  • Execution timing parameters

API Integration

Strategy Service Methods

// Get strategy details
strategyService.getStrategy(id: string): Promise<Strategy>

// Update strategy (with queue management)
strategyService.updateStrategy(id: string, data: Partial<CreateStrategyData>): Promise<Strategy>

// Execute strategy (queued)
strategyService.executeStrategy(id: string, symbol: string, dryRun?: boolean): Promise<StrategyExecutionResult>

// Bulk execution
strategyService.executeAllActiveStrategies(symbol?: string, dryRun?: boolean): Promise<BulkExecutionResult>

// Schedule recurring execution
strategyService.scheduleStrategy(id: string, intervalMinutes: number): Promise<ScheduleResult>

Queue Integration

The system integrates with the backend queue system for:

  • Asynchronous Execution: All strategy executions are queued and processed in background
  • Rate Limiting: Built-in rate limiting to prevent system overload
  • Retry Logic: Automatic retry for failed executions
  • Monitoring: Real-time execution status and performance tracking

Usage Guide

Editing an Active Strategy

  1. Navigate to /strategy/{id}
  2. Click "Edit Strategy" button
  3. Make necessary changes to rules or configuration
  4. Click "Save Changes"
  5. System will automatically:
    • Show queue management dialog
    • Pause strategy execution
    • Apply updates
    • Resume execution

Testing Strategy Execution

  1. Click "Test Execute" button
  2. Strategy execution will be queued
  3. Monitor execution in "Logs" tab
  4. View results in real-time

Managing Strategy Status

  • Activate: Start strategy execution in queue
  • Pause: Temporarily stop execution (maintains queue position)
  • Deactivate: Stop and remove from queue

Security & Validation

Input Validation

  • Rule validation with comprehensive error checking
  • Configuration parameter bounds checking
  • Symbol format validation
  • Quantity and percentage limits

Authorization

  • User-specific strategy access
  • JWT-based authentication
  • Protected API endpoints

Performance Optimization

Lazy Loading

  • Execution logs loaded on-demand
  • Performance metrics cached
  • Real-time updates via WebSocket (when available)

Efficient Updates

  • Partial strategy updates
  • Optimistic UI updates
  • Background synchronization

Error Handling

User-Friendly Errors

  • Clear error messages for validation failures
  • Network error recovery
  • Graceful degradation for offline scenarios

Queue Error Management

  • Failed execution retry logic
  • Error status tracking
  • Automatic error reporting

Mobile Responsiveness

  • Responsive Design: Optimized for desktop, tablet, and mobile
  • Touch-Friendly: Large touch targets and swipe gestures
  • Progressive Enhancement: Core functionality works on all devices

Keyboard Shortcuts

  • Ctrl + S: Save changes (when editing)
  • Ctrl + E: Toggle edit mode
  • Escape: Cancel editing
  • Ctrl + R: Refresh data

Development Notes

Component Architecture

StrategyDetailPage (Main Container)
β”œβ”€β”€ Header (Status, Actions)
β”œβ”€β”€ TabsContainer
β”‚   β”œβ”€β”€ OverviewTab (Metrics, Info)
β”‚   β”œβ”€β”€ RulesTab (Rule Editor)
β”‚   β”œβ”€β”€ ConfigTab (Configuration Editor)
β”‚   └── LogsTab (Execution History)
β”œβ”€β”€ RuleEditor (Individual Rule Management)
β”œβ”€β”€ ConfigEditor (Risk Management Settings)
└── QueueManagementDialog (Queue Operations)

State Management

  • Local state for form editing
  • Optimistic updates for better UX
  • Automatic synchronization with backend
  • Error boundary for graceful error handling

Type Safety

  • Full TypeScript integration
  • Comprehensive interface definitions
  • Runtime validation for API responses
  • Type-safe queue operations

Future Enhancements

Planned Features

  • Enhanced visual strategy builder with improved forms
  • Advanced backtesting integration
  • Strategy template marketplace
  • Multi-timeframe analysis
  • Social trading features

Technical Improvements

  • WebSocket integration for real-time updates
  • Advanced caching strategies
  • Offline capability
  • Enhanced mobile experience
  • Strategy performance analytics

Troubleshooting

Common Issues

  1. Strategy Won't Save

    • Check validation errors in form
    • Ensure all required fields are filled
    • Verify network connectivity
  2. Execution Not Working

    • Confirm strategy is active
    • Check queue status
    • Verify API key permissions
  3. Performance Issues

    • Clear browser cache
    • Check network connection
    • Contact support if persistent

Debug Mode

Enable debug mode in browser console:

localStorage.setItem("debug", "strategy:*");

This comprehensive strategy management system provides a professional-grade interface for managing trading strategies with full queue integration and real-time monitoring capabilities.