stock

Tables (8)

account

  • id — BIGINT — Primary key — NOT NULL
  • user_id — BIGINT — Foreign key → users.id — NOT NULL
  • account_number — VARCHAR(20) — NOT NULL
  • 확정 예수금 (cash_balance) — DECIMAL(18,2) — NOT NULL
  • 인출가능 예수금 (withdrawable_cash) — DECIMAL(18,2) — NOT NULL
  • 낙관적 락 (version) — BIGINT — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME

holding

  • id — BIGINT — Primary key — NOT NULL
  • account_id — BIGINT — Foreign key → account.id — NOT NULL
  • stock_id — BIGINT — Foreign key → stock.id — NOT NULL
  • 총 보유 수량 (quantity) — BIGINT — NOT NULL
  • 매도 가능 수량 (sellable_quantity) — BIGINT — NOT NULL
  • version — BIGINT — NOT NULL

order_history

  • id — BIGINT — Primary key — NOT NULL
  • order_id — BIGINT — Foreign key — NOT NULL
  • event_type — VARCHAR(20) — NOT NULL
  • status — VARCHAR(20) — NOT NULL
  • changed_quantity — BIGINT
  • remaining_quantity — BIGINT — NOT NULL
  • note — VARCHAR(255)
  • created_at — DATETIME — NOT NULL

orders

  • id — BIGINT — Primary key — NOT NULL
  • account_id — BIGINT — Foreign key → account.id — NOT NULL
  • stock_id — BIGINT — Foreign key → stock.id — NOT NULL
  • side — VARCHAR(10) — NOT NULL
  • type — VARCHAR(10) — NOT NULL
  • price — DECIMAL(18,2)
  • 최초 주문 수량 (quantity) — BIGINT — NOT NULL
  • 미체결 잔량 (remaining_quantity) — BIGINT — NOT NULL
  • status — VARCHAR(20) — NOT NULL
  • version — BIGINT — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME

settlement

  • id — BIGINT — Primary key — NOT NULL
  • trade_id — BIGINT — Foreign key → trade.id — NOT NULL
  • account_id — BIGINT — Foreign key → account.id — NOT NULL
  • side — VARCHAR(10) — NOT NULL
  • 매매수수료 (fee) — DECIMAL(18,2) — NOT NULL
  • 증권거래세 (tax) — DECIMAL(18,2) — NOT NULL
  • trade_date — DATE — NOT NULL
  • T+2 (settle_date) — DATE — NOT NULL
  • status — VARCHAR(20) — NOT NULL

stock

  • id — BIGINT — Primary key — NOT NULL
  • code — VARCHAR(10) — NOT NULL
  • name — VARCHAR(100) — NOT NULL
  • 호가 단위 (tick_size) — DECIMAL(10,2) — NOT NULL
  • 전일 종가 (prev_close_price) — DECIMAL(18,2) — NOT NULL
  • upper_limit_price — DECIMAL(18,2) — NOT NULL
  • lower_limit_price — DECIMAL(18,2) — NOT NULL

trade

  • id — BIGINT — Primary key — NOT NULL
  • buy_order_id — BIGINT — Foreign key → orders.id — NOT NULL
  • sell_order_id — BIGINT — Foreign key → orders.id — NOT NULL
  • stock_id — BIGINT — Foreign key → stock.id — NOT NULL
  • 체결가 (price) — DECIMAL(18,2) — NOT NULL
  • 체결수량 (quantity) — BIGINT — NOT NULL
  • executed_at — DATETIME — NOT NULL

users

  • id — BIGINT — Primary key — NOT NULL
  • email — VARCHAR(100) — NOT NULL
  • name — VARCHAR(50) — NOT NULL
  • password — VARCHAR(255) — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME