"""Rebalancing strategies."""

from typing import Dict
from decimal import Decimal

class RebalancingStrategy:
    """Base rebalancing strategy."""
    
    def calculate_trades(
        self,
        current_allocations: Dict[str, float],
        target_allocations: Dict[str, float],
        total_value: Decimal
    ) -> Dict[str, Decimal]:
        """Calculate required trades.
        
        Args:
            current_allocations: Current allocations
            target_allocations: Target allocations
            total_value: Total portfolio value
            
        Returns:
            Dictionary of symbol -> trade value (positive = buy, negative = sell)
        """
        trades = {}
        for symbol, target_pct in target_allocations.items():
            current_pct = current_allocations.get(symbol, 0.0)
            deviation = target_pct - current_pct
            
            if abs(deviation) > 0.01:  # 1% threshold
                target_value = total_value * Decimal(str(target_pct))
                current_value = Decimal(str(current_pct)) * total_value
                trades[symbol] = target_value - current_value
        
        return trades

