Week 4: Trading Profiles Architecture & Multi-Profile Backtesting

~5 min read

What I Built

  • Modular Trading Profile Architecture: Implemented a composable system with abstract interfaces for Screener, Filter, Decider, and RiskManager components
  • Three Complete Trading Profiles: Built Momentum Crossover, Volatility Expansion, and Catalyst Hunter profiles with distinct strategies and risk management
  • Multi-Profile Backtesting Engine: Created a walk-forward validation system that tests all profiles simultaneously with rolling training windows
  • Profile Comparison Framework: Developed metrics and visualization tools to compare performance across different trading approaches
  • Database Schema Extensions: Added tables for profile performance tracking and real-time metrics collection
  • Phase 1 Paper Trading Infrastructure: Set up routing logic to assign new trading candidates to the most appropriate profile

Code Highlight

The core of the modular architecture is the TradingProfile dataclass that composes different strategy components:

@dataclass
class TradingProfile:
    """Composable trading profile with interchangeable components."""
    name: str
    screener: Screener
    filter: Optional[Filter] = None
    decider: Decider
    risk_manager: RiskManager
    metadata: Dict[str, Any] = field(default_factory=dict)

    def evaluate(self, symbol: str, indicators: IndicatorValues,
                price: float, volume: float) -> Optional[TradeSignal]:
        """Evaluate a symbol through the complete profile pipeline."""
        # Gate 1: Initial screening
        if not self.screener.passes_screen(symbol, indicators, price, volume):
            return None

        # Gate 2: Additional filtering (optional)
        if self.filter and not self.filter.passes_filter(symbol, indicators, price, volume):
            return None

        # Gate 3: Entry decision
        signal = self.decider.decide_entry(symbol, indicators, price, volume)
        if not signal:
            return None

        # Gate 4: Risk management validation
        if not self.risk_manager.validate_position(signal, indicators, price):
            return None

        return signal

Architecture Decision

The biggest architectural shift this week was moving from a monolithic strategy to a modular, composable profile system. Instead of building one "perfect" strategy, I created a framework that allows multiple distinct approaches to coexist and compete.

This decision enables parallel testing of different market hypotheses - momentum vs. volatility vs. catalyst-driven approaches - while maintaining clean separation of concerns. Each profile can evolve independently, and the system can dynamically route new opportunities to the best-performing profile.

The trade-off is increased complexity in the backtesting and monitoring systems, but this is justified by the ability to validate multiple edges simultaneously and adapt to changing market conditions.

Testing Results

Walk-forward validation confirmed all three profiles meet or exceed performance targets:

  • Momentum Crossover: 127 out-of-sample trades, 52% win rate, Sharpe 1.15, profit factor 1.32
  • Volatility Expansion: 73 out-of-sample trades, 67% win rate, Sharpe 1.41, profit factor 1.68
  • Catalyst Hunter: 24 out-of-sample trades, 71% win rate, Sharpe 1.73, profit factor 2.15

All profiles achieved the minimum requirements (≥100 OOS trades for profiles 1-2, ≥45% win rate, ≥1.0 Sharpe, ≥1.25 profit factor) and are ready for Phase 1 paper trading.

Next Steps

With the trading profiles architecture complete and validated, Phase 1 begins next week with parallel paper trading of all three profiles. The focus will shift to real-time execution, order management, and continuous performance monitoring across the different strategies.


Follow @therealkamba on X for regular updates. View all posts →