/**
 * Portfolio & Position Types
 * Types for portfolio management and position tracking
 */

/**
 * Individual portfolio position
 */
export interface PortfolioPosition {
  /** Security symbol/ticker */
  symbol: string;
  /** Number of shares/units */
  shares: number;
  /** Average entry price */
  averagePrice: number;
  /** Current market price */
  currentPrice: number;
  /** Current market value */
  marketValue: number;
  /** Unrealized P&L */
  unrealizedPnL: number;
  /** Unrealized P&L percentage */
  unrealizedPnLPercent: number;
  /** Weight in portfolio */
  weight: number;
  /** Security type (stock, bond, option, etc.) */
  securityType?: string;
  /** Currency */
  currency?: string;
}

/**
 * Portfolio analysis metrics
 */
export interface PortfolioAnalysis {
  /** Total portfolio value */
  totalValue: number;
  /** Total cash balance */
  cash: number;
  /** Total invested amount */
  invested: number;
  /** Total unrealized P&L */
  unrealizedPnL: number;
  /** Total unrealized P&L percentage */
  unrealizedPnLPercent: number;
  /** Total return */
  totalReturn: number;
  /** Total return percentage */
  totalReturnPercent: number;
  /** Annualized return */
  annualizedReturn: number;
  /** Portfolio volatility (annualized) */
  volatility: number;
  /** Sharpe ratio */
  sharpeRatio: number;
  /** Maximum drawdown */
  maxDrawdown: number;
  /** Number of positions */
  positionCount: number;
  /** Portfolio concentration (largest position weight) */
  concentration: number;
}

/**
 * Asset allocation breakdown
 */
export interface AssetAllocation {
  /** Asset class or category */
  category: string;
  /** Allocation value */
  value: number;
  /** Allocation percentage */
  percentage: number;
  /** Target allocation percentage */
  target?: number;
  /** Deviation from target */
  deviation?: number;
}

/**
 * Position sizing parameters
 */
export interface PositionSizeParams {
  /** Account size */
  accountSize: number;
  /** Risk percentage per trade */
  riskPercent: number;
  /** Entry price */
  entryPrice: number;
  /** Stop loss price */
  stopPrice: number;
  /** Commission per share */
  commission?: number;
}

/**
 * Kelly Criterion parameters
 */
export interface KellyParams {
  /** Win rate (0-1) */
  winRate: number;
  /** Average winning trade */
  averageWin: number;
  /** Average losing trade */
  averageLoss: number;
  /** Risk-free rate */
  riskFreeRate?: number;
}
