import { Agent } from './Agent';

export const AVAILABLE_FACTORS = {
  moving_average_cross: { cost: 0, type: 'buy', description: 'MA Cross' },
  rsi_oversold: { cost: 0, type: 'buy', description: 'RSI Oversold' },
  bollinger_squeeze: { cost: 50.0, type: 'buy', description: 'Bollinger Squeeze' },
  macd_divergence: { cost: 80.0, type: 'buy', description: 'MACD Divergence' },
  machine_learning_pred: { cost: 500.0, type: 'buy', description: 'ML Prediction' },
  sentiment_momentum: { cost: 300.0, type: 'buy', description: 'Sentiment Momentum' },
  atr_trailing_stop: { cost: 100.0, type: 'sell', description: 'ATR Trailing Stop' },
  time_decay_exit: { cost: 150.0, type: 'sell', description: 'Time Decay Exit' }
};

export class FactorSystem {
  purchaseFactor(agent: Agent, factorName: keyof typeof AVAILABLE_FACTORS): boolean {
    const factor = AVAILABLE_FACTORS[factorName];
    if (agent.economicTracker.balance < factor.cost * 1.2) return false;
    
    agent.economicTracker.balance -= factor.cost;
    if (!agent.unlockedFactors.includes(factorName)) {
      agent.unlockedFactors.push(factorName);
    }
    return true;
  }
}
