aboutsummaryrefslogtreecommitdiffstats
path: root/sql/dawn.sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql/dawn.sql')
-rw-r--r--sql/dawn.sql20
1 files changed, 11 insertions, 9 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index fc3721a2..23f7e05c 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -4046,8 +4046,8 @@ EXECUTE PROCEDURE update_account('ISDA');
CREATE TYPE author AS ENUM ('auto', 'manual');
-CREATE OR REPLACE VIEW forward_trades
-AS SELECT a.*, c.name from(SELECT unnest(ARRAY[fx_swaps.dealid::text, fx_swaps.dealid::text]) AS dealid,
+ CREATE OR REPLACE VIEW forward_trades
+AS SELECT a.*, c.name from(SELECT unnest(ARRAY[fx_swaps.dealid::text, fx_swaps.dealid::text]) AS dealid,
fx_swaps.trade_date,
unnest(ARRAY[fx_swaps.near_settle_date, fx_swaps.far_settle_date]) AS settle_date,
fx_swaps.fund,
@@ -4056,14 +4056,15 @@ AS SELECT a.*, c.name from(SELECT unnest(ARRAY[fx_swaps.dealid::text, fx_swaps.d
fx_swaps.cp_code,
unnest(ARRAY[fx_swaps.near_buy_currency, fx_swaps.far_buy_currency]) AS buy_currency,
unnest(ARRAY[fx_swaps.near_sell_currency, fx_swaps.far_sell_currency]) AS sell_currency,
- unnest(ARRAY[fx_swaps.near_buy_amount, fx_swaps.far_buy_amount]) AS buy_amount,
- unnest(ARRAY[fx_swaps.near_sell_amount, fx_swaps.far_sell_amount]) AS sell_amount,
+ unnest(ARRAY[fx_swaps.near_buy_amount::numeric(11,2), fx_swaps.far_buy_amount::numeric(11,2)]) AS buy_amount,
+ unnest(ARRAY[fx_swaps.near_sell_amount::numeric(11,2), fx_swaps.far_sell_amount::numeric(11,2)]) AS sell_amount,
unnest(ARRAY[fx_swaps.near_cpty_id, fx_swaps.far_cpty_id]) AS cpty_id,
unnest(ARRAY[fx_swaps.near_rate, fx_swaps.far_rate]) AS spot_rate,
- fx_swaps.id as id
+ fx_swaps.id as id,
+ unnest(ARRAY['NEAR', 'FAR']) as fx_type
FROM fx_swaps
UNION
- SELECT spots.dealid,
+ SELECT spots.dealid,
spots.trade_date,
spots.settle_date,
spots.fund,
@@ -4072,11 +4073,12 @@ UNION
spots.cp_code,
spots.buy_currency,
spots.sell_currency,
- spots.buy_amount,
- spots.sell_amount,
+ spots.buy_amount::numeric(11,2),
+ spots.sell_amount::numeric(11,2),
spots.cpty_id,
spots.spot_rate,
- spots.id as id
+ spots.id as id,
+ 'SPOT' as fx_type
FROM spots) a
LEFT JOIN counterparties c ON cp_code=code ;