StockClaw

Tables (19)

app_agent_outputs (각 Agent의 개별 분석 결과)

  • id (Agent 결과 식별자) — Primary key — NOT NULL
  • analysis_request_id (분석 요청 식별자) — Foreign key → app_analysis_requests.id — NOT NULL
  • agent_type (어떤 Agent인지)
  • score (Agent가 산출한 점수)
  • summary (Agent 결과 요약)
  • output_payload (Agent의 상세 결과 JSON)
  • created_at (Field5)
  • updated_at (Field6)

app_analysis_reports (최종 AI 종합 리포트)

  • id (리포트 식별자) — Primary key — NOT NULL
  • analysis_request_id (분석 요청 식별자) — Foreign key → app_analysis_requests.id — NOT NULL
  • opinion (최종 의견)
  • target_price (Field)
  • risk_level (Field2)
  • report_text (Field3)
  • created_at (Field4)
  • updated_at (Field5)

app_analysis_requests (사용자의 분석 요청)

  • id (분석 요청 식별자) — Primary key — NOT NULL
  • user_id (사용자 아이디) — bigint — Foreign key → app_users.id — NOT NULL
  • stock_id (내부 종목 식별자) — Foreign key → app_stocks.id — NOT NULL
  • request_text (사용자가 입력한 원문)
  • status (분석 진행 상태)
  • requested_at (분석 요청 시점)
  • completed_at (분석 완료 시점)
  • created_at (Field5)
  • updated_at (Field6)

app_approval_requests (Human-in-the-Loop 승인 요청)

  • id (승인 요청 식별자) — Primary key — NOT NULL
  • user_id (사용자 아이디) — bigint — Foreign key → app_users.id — NOT NULL
  • rule_trigger_event_id (룰 발동 이벤트 식별자) — Foreign key → app_rule_trigger_events.id — NOT NULL
  • message (Telegram에 보낸 승인 메시지 원문)
  • status (승인 대기, 승인, 거절, 만료 상태)
  • requested_at (승인 요청을 보낸 시점)
  • responded_at (사용자가 응답한 시점)
  • expires_at (승인 요청 만료 시점)
  • created_at (Field5)
  • updated_at (Field6)

app_broker_accounts (증권사 계좌 연동 정보)

  • id (계좌 연동 정보 식별자) — Primary key — NOT NULL
  • user_id (사용자 아이디) — bigint — Foreign key → app_users.id — NOT NULL
  • broker (증권사 구분 (MVP에서는 KIS))
  • account_no_masked (실제 계좌번호 전체가 아니라 마스킹된 계좌번호)
  • credential_ref (민감정보 KeyVault/RaaK 참조값)
  • trade_mode (모의투자 MOCK / 실거래 LIVE)
  • is_active (현재 사용한 계좌인지 여부)
  • created_at (Field)
  • updated_at (Field2)

app_executions (실제 체결 내역)

  • id (체결 식별자) — Primary key — NOT NULL
  • order_id (주문 식별자) — Foreign key → app_orders.id — NOT NULL
  • executed_quantity (체결 수량)
  • executed_price (체결 가격)
  • fee (수수료)
  • tax (세금)
  • executed_at (실제 체결 시각)
  • kis_execution_no (KIS 체결 번호)
  • created_at (Field)
  • updated_at (Field2)

app_holdings (현재 보유 종목상태)

  • id (보유 상태 식별자) — Primary key — NOT NULL
  • stock_id (내부 종목 식별자) — Foreign key → app_stocks.id — NOT NULL
  • broker_account_id (계좌 연동 정보 식별자) — Foreign key → app_broker_accounts.id — NOT NULL
  • quantity (현재 보유 수량)
  • average_price (평균 매입가)
  • current_price (현재가)
  • evaluation_amount (평가금액)
  • unrealized_pnl (평가손익)
  • unrealized_pnl_rate (평가손익률)
  • synced_at (KIS 계좌와 마지막으로 동기화한 시점)
  • created_at (Field8)
  • updated_at (Field9)

app_investment_rules (투자 룰)

  • id (투자 룰 식별자) — Primary key — NOT NULL
  • user_id (사용자 아이디) — bigint — Foreign key → app_users.id — NOT NULL
  • stock_id (내부 종목 식별자) — Foreign key → app_stocks.id — NOT NULL
  • original_text (사용자가 입력한 원문)
  • action (조건 충족 시 무엇을 할지) — enum
  • metric (어떤 값을 감시할지)
  • operator (비교 연산자)
  • threshold_value (조건 기준값)
  • unit (기준값 단위)
  • order_type (시장가/지정가 주문 구분)
  • quantity (주문 수량)
  • limit_price (지정가 주문일 경우 가격)
  • status (룰 상태)
  • requires_approval (조건 충족 시 바로 주문할지, Telegram 승인을 받을지)
  • valid_until (룰의 유효기간)
  • created_at (Field)
  • updated_at (Field2)

app_job_runs (스케줄러, Browser-Use, Computer-Use, 데이터 마트 배치 실행 이력)

  • id (run 아이디) — bigint — Primary key — NOT NULL
  • job_name (job 이름) — varchar
  • job_type (작업 종류) — SCHEDULER, BROWSER_USE, COMPUTER_USE, MART_BATCH 등
  • status (작업 상태)
  • started_at (작업 시작 시각)
  • ended_at (작업 종료 시각)
  • error_message (실패시 오류 메시지)

app_orders (주문 요청)

  • id (주문 식별자) — Primary key — NOT NULL
  • broker_account_id (계좌 연동 정보 식별자) — Foreign key → app_broker_accounts.id — NOT NULL
  • stock_id (내부 종목 식별자) — Foreign key → app_stocks.id — NOT NULL
  • rule_id (투자 룰 식별자(Null 가능)) — Foreign key → app_investment_rules.id — NOT NULL
  • approval_request_id (승인 요청 식별자) — Foreign key → app_approval_requests.id — NOT NULL
  • side (매수/매도 구분)
  • order_type (시장가/지정가 구분)
  • quantity (주문 수량)
  • limit_price (지정가 주문 가격)
  • status (주문 상태)
  • kis_order_no (KIS에서 받은 주문번호)
  • requested_at (내부적으로 주문이 생성된 시점)
  • submitted_at (실제 KIS API에 주문을 제출한 시점)
  • failure_reason (주문 실패 시 원인을 저장)
  • created_at (Field10)
  • updated_at (Field11)

app_portfolio_snapshots (포트폴리오의 시점별 과거 상태)

  • id (포트폴리오 과거 상태 식별자) — Primary key — NOT NULL
  • brocker_account_id (계좌 연동 정보 식별자) — Foreign key → app_broker_accounts.id — NOT NULL
  • stock_id (내부 종목 식별자) — Foreign key → app_stocks.id — NOT NULL
  • snapshot_at (스냅샷 기준 시점)
  • total_asset_value (총자산 평가금액)
  • cash_balance (예수금)
  • evaluation_amount (평가금액)
  • realized_pnl (실현손익)
  • unrealized_pnl (평가손익)
  • pnl_rate (수익률)
  • position_weight (포트폴리오 내 종목 비중)
  • created_at (스냅샷 저장 시점)

app_rule_trigger_events (투자 룰이 실제로 발동된 기록)

  • id (룰 발동 이벤트 식별자) — Primary key — NOT NULL
  • rule_id (투자 룰 식별자) — Foreign key → app_investment_rules.id — NOT NULL
  • triggered_at (조건이 충족된 시점)
  • observed_value (조건 판단 당시 실제 관측값)
  • trigger_status (발동 후 상태)
  • created_at (Field3)
  • updated_at (Field4)

app_stocks (종목 기준 정보)

  • id (내부 종목 식별자) — Primary key — NOT NULL
  • symbol (종목코드)
  • name_ko (사용자가 자연어로 입력한 종목명 매핑용)
  • market (KOSPI, KOSDAQ, ETF 등 시장 구분)
  • sector (업종 단위 분석이나 군집화에 필요)
  • industry (더 세부적인 산업 분류)
  • is_active (상장폐지, 거래정지 등 비활성 종목을 구분)
  • created_at (Field7)
  • updated_at (Field8)

app_users (사용자)

  • id (사용자 아이디) — bigint — Primary key — NOT NULL
  • telegram_user_id (Telegram 사용자를 식별)
  • telegram_chat_id (봇이 사용자에게 메시지, 승인 요청, 리포트를 보내려면 필요) — string
  • username (관리자 화면이나 로그에서 사용자 식별을 위한 값) — string
  • status (활성/정지/삭제 상태)
  • created_at (Field4) — timestamp
  • upldated_at (Field5) — timestamp

app_watchlist_items (관심종목 그룹 안에 실제 종목)

  • id (관심종목 항목 식별자) — Primary key — NOT NULL
  • watchlist_id (관심종목 그룹 식별자) — Foreign key → app_watchlists.id — NOT NULL
  • stock_id (내부 종목 식별자) — Foreign key → app_stocks.id — NOT NULL
  • memo ((-) 종목별 메모)
  • created_at (Field)
  • updated_at (Field2)

app_watchlists (사용자별 관심 종목 그룹)

  • id (관심종목 그룹 식별자) — Primary key — NOT NULL
  • user_id (사용자 아이디) — bigint — Foreign key → app_users.id — NOT NULL
  • name (관심종목 그룹 이름 (예) 반도체, 배당주, 단기매매)

raw_api_response (외부 API의 원본 응답)

  • id (Key) — Primary key — NOT NULL
  • collected_at (Field) — timestamp
  • source (KIS, DART, NEWS 등 데이터 출처)
  • endpoint (Field3)
  • request_params (Field4) — json
  • response_payload (Field5) — json
  • status_code (HTTP 응답 코드 또는 API 상태 코드)

raw_browser_captures (Browser-Use나 Computer-Use로 캡처한 화면 파일 정보)

  • id (Key) — Primary key — NOT NULL
  • collected_at (Field)
  • source (Naver Finance, DART, WTS, Notion 등 캡처 출처)
  • task_type (차트 캡처, 공시 수집, 투자일지 작성, 호가창 캡처 등 작업 유형)
  • file_path (캡처 이미지 파일 저장 경로)
  • page_url (브라우저 캡처라면 해당 페이지 URL) — text
  • metadata (화면 크기, 브라우저 상태, 종목코드 등 부가 정보) — json

raw_vision_extractions (Vision 모델이 캡처 이미지를 분석해 추출한 원본 결과)

  • id (Key) — Primary key — NOT NULL
  • collected_at (Field) — timestamp
  • capture_id (Key2) — Foreign key → raw_browser_captures.id — NOT NULL
  • model_name (어떤 Vision 모델을 사용했는지)
  • extracted_payload (모델이 추출한 원본 JSON 결과)
  • confidence (모델의 추출 신뢰도)
  • validation_status (추출 결과가 유효한지, 재검토가 필요한지 표시)