Changeset ef1c1c7 for server/db/schema_creation.sql
- Timestamp:
- 09/24/26 17:43:19 (5 days ago)
- Branches:
- main
- Children:
- 0cee8ec
- Parents:
- a531b45
- File:
-
- 1 edited
-
server/db/schema_creation.sql (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
server/db/schema_creation.sql
ra531b45 ref1c1c7 26 26 available_balance numeric(18,4) NOT NULL DEFAULT 0 CHECK (available_balance >= 0), 27 27 invested_balance numeric(18,4) NOT NULL DEFAULT 0 CHECK (invested_balance >= 0), 28 -- P7: cash committed to the user's active buy orders, moved out of 29 -- available_balance when the order is placed and consumed as it fills. 30 reserved_balance numeric(18,4) NOT NULL DEFAULT 0 CHECK (reserved_balance >= 0), 28 31 created_at timestamptz NOT NULL DEFAULT now(), 29 32 updated_at timestamptz … … 86 89 side varchar(4) NOT NULL CHECK (side IN ('buy', 'sell')), 87 90 type varchar(20) NOT NULL CHECK (type IN ('market', 'limit')), 88 status varchar(20) NOT NULL CHECK (status IN ('open', ' executed', 'cancelled')),91 status varchar(20) NOT NULL CHECK (status IN ('open', 'partially_filled', 'executed', 'cancelled')), 89 92 quantity numeric(20,4) NOT NULL CHECK (quantity > 0), 93 -- P7: how much of the order has been traded so far; remaining is 94 -- quantity - filled_quantity. Maintained from market_trades. 95 filled_quantity numeric(20,4) NOT NULL DEFAULT 0 96 CHECK (filled_quantity >= 0 AND filled_quantity <= quantity), 90 97 price numeric(18,6), 91 98 placed_at timestamptz NOT NULL DEFAULT now(), … … 125 132 quantity numeric(20,6) NOT NULL CHECK (quantity > 0), 126 133 side varchar(4) CHECK (side IN ('buy', 'sell')), 127 source varchar(50) NOT NULL DEFAULT 'simulation' 134 source varchar(50) NOT NULL DEFAULT 'simulation', 135 -- P7: the orders this trade filled. NULL on a side means the counterparty 136 -- was the simulated market (bot ticks have both NULL). 137 buy_order_id uuid REFERENCES project.orders(id), 138 sell_order_id uuid REFERENCES project.orders(id) 128 139 ); 129 140 130 141 CREATE INDEX idx_market_trades_market_time ON project.market_trades(market_id, executed_at DESC); 142 CREATE INDEX idx_market_trades_buy_order ON project.market_trades(buy_order_id) WHERE buy_order_id IS NOT NULL; 143 CREATE INDEX idx_market_trades_sell_order ON project.market_trades(sell_order_id) WHERE sell_order_id IS NOT NULL; 131 144 132 145 -- ============================================================================
Note:
See TracChangeset
for help on using the changeset viewer.
