export type AssetClass = 'energy' | 'metals' | 'agriculture' | 'equities' | 'indices' | 'forex' | 'crypto' | 'rates' | 'etfs'
export type RiskLevel = 'low' | 'medium' | 'high' | 'extreme'
export type GeoCategory =
  | 'military' | 'sanctions' | 'elections' | 'natural_disaster'
  | 'health_crisis' | 'resource_scarcity' | 'trade_war'
  | 'energy' | 'political_speech' | 'financial_crisis' | 'general'

export interface Quote {
  symbol: string
  name: string
  price: number
  change: number
  change_pct: number
  volume: number
  iv?: number
  asset_class: AssetClass
  timestamp: string
  error?: string
}

export interface GeoNews {
  id: string
  title: string
  summary: string
  source: string
  category: GeoCategory
  impact_score: number
  asset_impacts: Partial<Record<AssetClass, number>>
  date: string
  tags: string[]
  url: string
}

export interface GeoRiskScore {
  score: number
  level: RiskLevel
  breakdown: Record<string, number>
  top_risks: string[]
  computed_at?: string
  rationale?: string
  run_id?: string
}

export interface GeoPattern {
  id: string
  name: string
  description: string
  triggers: string[]
  keywords: string[]
  historical_instances: Array<{date: string; event: string; [key: string]: unknown}>
  suggested_trades: Array<{strategy: string; underlying: string; rationale: string}>
  asset_class: AssetClass
  expected_move_pct: number
  probability: number
  horizon_days: number
}

export interface PatternMatch extends GeoPattern {
  pattern_id: string
  similarity: number
}

export interface TradeIdea {
  id: string
  title: string
  rationale: string
  pattern: string
  asset_class: AssetClass
  underlying: string
  strategy: string
  expected_move_pct: number
  confidence: number
  horizon_days: number
  capital_required: number
  risk_level: RiskLevel
  pattern_similarity: number
  geo_trigger?: string
  expiry_days?: number
  max_loss_eur?: number
  target_gain_eur?: number
  strike_guidance?: string
  timing?: string
  invalidation?: string
  rank?: number
}

export interface OptionPrice {
  price: number
  delta: number
  gamma: number
  theta: number
  vega: number
  rho: number
  underlying_price: number
  sigma: number
}

export interface PnLPoint {
  underlying: number
  pnl: number
}

export interface BacktestResult {
  symbol: string
  strategy: string
  period: string
  total_trades: number
  wins: number
  losses: number
  win_rate: number
  total_pnl: number
  total_return_pct: number
  max_drawdown_pct: number
  profit_factor: number
  final_capital: number
  equity_curve: Array<{index: number; capital: number}>
  trades: Array<Record<string, unknown>>
  error?: string
}

export interface EconomicEvent {
  title: string
  country: string
  importance: 'low' | 'medium' | 'high'
  date: string
  asset_impact: AssetClass[]
  previous?: string
  forecast?: string
  actual?: string
  surprise_zscore?: number
  surprise_direction?: 'bullish' | 'bearish' | 'neutral'
  source?: string
}

export interface HistoricalCandle {
  date: string
  open: number
  high: number
  low: number
  close: number
  volume: number
}
