diff options
Diffstat (limited to 'sql/dawn.sql')
| -rw-r--r-- | sql/dawn.sql | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index e54ec115..834b9863 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -3168,30 +3168,6 @@ AS SELECT t.settle_date, GROUP BY t.settle_date, t.fund, c.name, t.cp_code, t.asset_class, t.currency, t.account ORDER BY t.settle_date DESC, t.fund, c.name, t.asset_class, t.currency; - -CREATE TABLE equities ( - id serial4 NOT NULL, - dealid varchar(28) NULL GENERATED ALWAYS AS ((('EQ'::text || id::text))) STORED, - lastupdate timestamp NULL DEFAULT now(), - "action" action NOT NULL, - folder future_strat NOT NULL, - trade_date date NOT NULL, - settle_date date NOT NULL, - buysell bool NOT NULL, - bbg_ticker varchar(32) NOT NULL, - quantity float8 NOT NULL, - price float8 NOT NULL, - commission float8 NULL, - security_desc varchar(32) NOT NULL, - "currency" currency NOT NULL, - exchange varchar(3) NOT NULL, - "fund" fund NOT NULL DEFAULT 'SERCGMAST'::fund, - account_code text NOT NULL DEFAULT 'IB'::text, - CONSTRAINT equities_dealid_key UNIQUE (dealid), - CONSTRAINT equities_pkey PRIMARY KEY (id), - CONSTRAINT equities_account_code_fkey FOREIGN KEY (account_code) REFERENCES accounts(code) -); - CREATE TYPE exercise_type AS ENUM ('European', 'American'); CREATE TYPE equity_option_strat AS ENUM ('VOLRV'); @@ -3229,6 +3205,29 @@ CREATE TABLE equityoptions ( CONSTRAINT equity_options2_cp_code_fkey FOREIGN KEY (cp_code) REFERENCES counterparties(code) ON UPDATE CASCADE ); +CREATE TABLE equities2 ( + id int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY, + dealid varchar(28) NULL GENERATED ALWAYS AS ((('EQ_'::text || id::text))) STORED, + "fund" "fund" NOT NULL, + lastupdate timestamp NULL DEFAULT now(), + "action" "action" NOT NULL, + "portfolio" "portfolio" NOT NULL, + folder text NOT NULL, + cash_account text NOT NULL REFERENCES accounts2(cash_account) ON UPDATE CASCADE, + cp_code text NOT NULL REFERENCES counterparties(code) ON UPDATE CASCADE, + trade_date date NOT NULL, + settle_date date NOT NULL, + buysell bool NOT NULL, + bbg_ticker varchar(32) NOT NULL, + quantity float8 NOT NULL, + price float8 NOT NULL, + commission float8 NULL, + "currency" public."currency" NOT NULL, + exchange varchar(5) NOT NULL, + "fund" public."fund" NOT NULL +); + + CREATE OR REPLACE VIEW equityoption_trades AS SELECT eo.id, |
