Robinhood-style stock trading database schema

How a retail brokerage models its data: accounts and instruments, orders with type and time-in-force, partial fills, positions derived from executions with average cost basis, cash settlement, dividends, watchlists and price alerts.

Robinhood Trading ER diagram

Robinhood-style stock trading database schema n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 users idBIGINT emailVARCHAR legal_nameVARCHAR date_of_birthDATE tax_id_last_fourCHAR country_codeCHAR kyc_statusVARCHAR created_atTIMESTAMPTZ closed_atTIMESTAMPTZ accounts idBIGINT user_idBIGINT account_numberVARCHAR account_typeVARCHAR currency_codeCHAR statusVARCHAR settled_cash_minorBIGINT unsettled_cash_mi…BIGINT buying_power_minorBIGINT pattern_day_traderBOOLEAN opened_atTIMESTAMPTZ closed_atTIMESTAMPTZ instruments idBIGINT symbolVARCHAR exchange_micCHAR nameVARCHAR instrument_typeVARCHAR currency_codeCHAR is_tradableBOOLEAN fractional_enabledBOOLEAN tick_size_microsBIGINT listed_onDATE delisted_onDATE orders idBIGINT account_idBIGINT instrument_idBIGINT client_order_idVARCHAR venue_order_idVARCHAR sideVARCHAR order_typeVARCHAR time_in_forceVARCHAR quantityDECIMAL notional_minorBIGINT limit_price_microsBIGINT stop_price_microsBIGINT filled_quantityDECIMAL average_fill_pric…BIGINT statusVARCHAR reject_reasonVARCHAR extended_hoursBOOLEAN submitted_atTIMESTAMPTZ expires_atTIMESTAMPTZ canceled_atTIMESTAMPTZ executions idBIGINT order_idBIGINT execution_referen…VARCHAR quantityDECIMAL price_microsBIGINT gross_amount_minorBIGINT fee_minorBIGINT venueVARCHAR liquidity_flagVARCHAR trade_dateDATE settlement_dateDATE executed_atTIMESTAMPTZ positions idBIGINT account_idBIGINT instrument_idBIGINT quantityDECIMAL average_cost_micr…BIGINT total_cost_minorBIGINT realized_pnl_minorBIGINT opened_atTIMESTAMPTZ last_fill_atTIMESTAMPTZ cash_movements idBIGINT account_idBIGINT movement_typeVARCHAR execution_idBIGINT dividend_payment_…BIGINT amount_minorBIGINT currency_codeCHAR trade_dateDATE settlement_dateDATE statusVARCHAR descriptionVARCHAR created_atTIMESTAMPTZ dividends idBIGINT instrument_idBIGINT dividend_typeVARCHAR amount_per_share_…BIGINT currency_codeCHAR declared_dateDATE ex_dateDATE record_dateDATE payable_dateDATE created_atTIMESTAMPTZ dividend_payments idBIGINT dividend_idBIGINT account_idBIGINT entitled_quantityDECIMAL gross_amount_minorBIGINT withholding_minorBIGINT net_amount_minorBIGINT statusVARCHAR reinvestedBOOLEAN paid_atTIMESTAMPTZ watchlists idBIGINT user_idBIGINT nameVARCHAR is_defaultBOOLEAN display_orderSMALLINT created_atTIMESTAMPTZ watchlist_items watchlist_idBIGINT instrument_idBIGINT display_orderSMALLINT added_atTIMESTAMPTZ price_alerts idBIGINT user_idBIGINT instrument_idBIGINT directionVARCHAR threshold_price_m…BIGINT statusVARCHAR triggered_price_m…BIGINT triggered_atTIMESTAMPTZ expires_atTIMESTAMPTZ created_atTIMESTAMPTZ

Related database schemas