stock v2

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 → orders.id — NOT NULL
  • event_type — VARCHAR(20) — NOT NULL
  • status — VARCHAR(20) — 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
  • 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
  • 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