diff options
| -rw-r--r-- | sql/dawn.sql | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index 50040029..cdc7e6b1 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -4012,3 +4012,50 @@ CREATE TABLE bond_csv_upload( interest decimal NOT NULL, CONSTRAINT unique_upload_check UNIQUE (tradeid, cusip, principal, interest) ); + +CREATE OR REPLACE VIEW irs_trades AS +SELECT irs.id, + dealid, + termination_date AS trade_date, + termination_amount AS notional, + maturity_date, + float_index, + CASE WHEN termination_cp=cp_code THEN + 'Termination' + ELSE + 'Assignment' + END AS trade_type, + folder, + fund, + termination_cp AS cp_code, + name, + fixed_rate, + CASE WHEN payreceive THEN + False + ELSE + True + END AS payreceive, + termination_fee AS upfront, + fee_payment_date as settle_date, + swap_type +FROM terminations RIGHT JOIN irs USING (dealid) +LEFT JOIN counterparties on termination_cp=code +WHERE termination_date is NOT NULL +UNION ALL ( +SELECT id, + dealid, + trade_date, + notional, + maturity_date, + float_index, + 'New', + folder, + fund, + cp_code, + name, + fixed_rate, + payreceive, + upfront, + settle_date, + swap_type +FROM irs JOIN counterparties ON cp_code = code) ORDER BY trade_date DESC, folder;
\ No newline at end of file |
