
export enum MarketType {
  DOMESTIC = 'Domestic',
  OVERSEAS = 'Overseas'
}

export enum OrderType {
  BUY = 'BUY',
  SELL = 'SELL'
}

export type AiProviderType = 'gemini' | 'openai-compatible';

export interface AiConfig {
  id: string;
  name: string;
  providerType: AiProviderType;
  modelName: string;
  baseUrl?: string; 
}

export interface ApiSettings {
  appKey: string;
  appSecret: string;
  accountNumber: string;
  useTelegram: boolean;
  telegramToken: string;
  telegramChatId: string;
  useNaverNews: boolean;
  naverClientId: string;
  naverClientSecret: string;
  aiConfigs: AiConfig[];
  preferredNewsAiId?: string;
  preferredStockAiId?: string;
  preferredNewsJudgementAiId?: string;
  preferredAutoBuyAiId?: string;
  preferredAutoSellAiId?: string;
}

export interface StockTick {
  code: string;
  price: number;
  timestamp: number;
}

export interface StockItem {
  code: string;
  name: string;
  price: number;
  change: number;
  changePercent: number;
  market: MarketType;
  volume: number;
  tradingValue?: number; // 거래대금
  buyRatio?: number;     // 매수 비율 (0-100)
  sellRatio?: number;    // 매도 비율 (0-100)
  per?: number;
  pbr?: number;
  roe?: number;
  marketCap?: number;
  dividendYield?: number;
  aiScoreBuy: number;
  aiScoreSell: number;
  openPrice?: number;   // 시가
  highPrice?: number;   // 고가
  lowPrice?: number;    // 저가
  themes?: string[]; 
  // --- New Fields ---
  memo?: string;         // 사용자 메모
  aiAnalysis?: string;   // AI 분석 리포트 텍스트
  isHidden?: boolean;    // 종목 숨김 여부
}

export interface TradeOrder {
  id: string;
  stockCode: string;
  stockName: string;
  type: OrderType;
  price: number;
  quantity: number;
  status: 'PENDING' | 'COMPLETED' | 'CANCELLED';
  timestamp: Date;
}

export interface ReservedOrder {
  id: string;
  stockCode: string;
  stockName: string;
  type: OrderType;
  quantity: number;
  monitoringType: 'PRICE_TRIGGER' | 'TRAILING_STOP';
  triggerPrice: number;
  trailingType: 'PERCENT' | 'AMOUNT'; 
  trailingValue: number; 
  useStopLoss?: boolean;
  stopLossType?: 'PERCENT' | 'AMOUNT';
  stopLossValue?: number;
  sellAll?: boolean;
  highestPrice?: number; 
  lowestPrice?: number; 
  market: MarketType;
  status: 'WAITING' | 'MONITORING' | 'TRIGGERED' | 'CANCELLED';
  createdAt: Date;
  expiryDate: Date;
}

export interface AutoTradeConfig {
  id: string;
  stockCode?: string;
  stockName: string;
  groupId?: string;
  type: 'ACCUMULATION' | 'TRAILING_STOP';
  quantity: number;
  frequency: 'DAILY' | 'WEEKLY' | 'MONTHLY';
  specificDay?: number; 
  executionTime: string; 
  trailingPercent?: number;
  active: boolean;
  market: MarketType;
}

export interface WatchlistGroup {
  id: string;
  name: string;
  codes: string[];
  market: MarketType;
}

export interface NewsItem {
  title: string;
  description: string;
  link: string;
  pubDate: string;
}
