aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sql/dawn.sql46
1 files changed, 45 insertions, 1 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index e09afbba..c6d1a865 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -73,6 +73,18 @@ CREATE TABLE accounts(
account_type account_type NOT NULL,
active boolean NOT NULL);
+CREATE TABLE accounts2 (
+ id int4 NOT NULL GENERATED ALWAYS AS IDENTITY,
+ "name" text NULL,
+ custodian text NOT NULL,
+ cash_account text NOT NULL,
+ "fund" fund NOT NULL,
+ "account_type" account_type NOT NULL,
+ active bool NOT NULL,
+ CONSTRAINT accounts2_cash_account_key UNIQUE (cash_account),
+ CONSTRAINT accounts2_pkey PRIMARY KEY (id)
+);
+
CREATE TABLE counterparties(code varchar(12) PRIMARY KEY,
name text,
city text,
@@ -529,8 +541,10 @@ CREATE TABLE spots (
dealid varchar(28) NULL,
lastupdate timestamp NULL DEFAULT now(),
"action" action NOT NULL,
+ portfolio portfolio NOT NULL,
folder spot_strat NOT NULL,
- account_code varchar(12) NOT NULL REFERENCES accounts(code),
+ account_code varchar(12) NOT NULL REFERENCES accounts(cash_account),
+ cp_code
trade_date date NOT NULL,
settle_date date NOT NULL,
spot_rate float8 NOT NULL,
@@ -540,9 +554,39 @@ CREATE TABLE spots (
sell_amount float8 NOT NULL,
commission_currency currency NULL,
commission float8 NULL,
+ initial_margin_percentage float8,
+ cpty_id text,
+ globeop_id text,
+
CONSTRAINT spots_pkey PRIMARY KEY (id),
);
+CREATE TABLE fx_swaps (
+ id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
+ dealid varchar(28) NOT NULL GENERATED ALWAYS AS ((('FXSWAP_'::text || id::text))) STORED,
+ "fund" fund NOT NULL DEFAULT 'SERCGMAST'::fund,
+ lastupdate timestamp NULL DEFAULT now(),
+ "portfolio" portfolio NOT NULL,
+ folder spot_strat NOT NULL,
+ cp_code varchar(12) NOT NULL REFERENCES counterparties(code) ON UPDATE CASCADE,
+ trade_date date NOT NULL,
+ near_rate float8 NOT NULL,
+ near_settle_date date NOT NULL,
+ near_buy_currency currency NOT NULL,
+ near_buy_amount float8 NOT NULL,
+ near_sell_currency currency NOT NULL,
+ near_sell_amount float8 NOT NULL,
+ far_rate float8 NOT NULL,
+ far_settle_date date NOT NULL,
+ far_buy_currency currency NULL,
+ far_buy_amount float8 NOT NULL,
+ far_sell_currency currency NULL,
+ far_sell_amount float8 NOT NULL,
+ near_cpty_id text NULL,
+ far_cpty_id text NULL,
+);
+
+
CREATE TABLE terminations (
id int GENERATED BY default as identity primary KEY,
dealid varchar(28) NOT NULL,