-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathupload-bond-instruments.sql
59 lines (53 loc) · 1.58 KB
/
upload-bond-instruments.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
-- ============================================================
-- Description:
-- 1. In this query, we run an ETL process on some instruments.
-- 2. First, we load a XML file of bond instruments from Drive.
-- 3. Next, we transform the shape of the instrument data.
-- 4. Finally we upload the instrument data into LUSID.
-- ============================================================
-- Extract Bond instrument data from LUSID Drive
@instruments_data =
use Drive.Xml
--file=/luminesce-examples/instruments.xml
--nodePath=instruments/bond
--columns
BondID=bondId
Name=name
ISIN=isin
IssueDate=issueDate
Maturity=maturity
Currency=crncy
CouponRate=couponRate
Principal=principal
CouponFreq=cpnFreq
DayCountConvention=dayCountConvention
RollConvention=rollConvention
PaymentCalendars=paymentCalendars
ResetCalendars=resetCalendars
SettleDays=settleDays
ResetDays=resetDays
enduse;
-- Transform data using SQL
@instruments =
select
Name as DisplayName,
ISIN as Isin,
Name || ' ' || ISIN as ClientInternal,
IssueDate as StartDate,
CouponRate as CouponRate,
Currency as DomCcy,
Currency as FlowConventionsCurrency,
CouponFreq as FlowConventionsPaymentFrequency,
DayCountConvention as FlowConventionsDayCountConvention,
RollConvention as FlowConventionsRollConvention,
'' as FlowConventionsPaymentCalendars,
'' as FlowConventionsResetCalendars,
SettleDays as FlowConventionsSettleDays,
ResetDays as FlowConventionsResetDays,
Principal as Principal,
Maturity as MaturityDate
from @instruments_data;
-- Upload the transformed data into LUSID
select *
from Lusid.Instrument.Bond.Writer
where ToWrite = @instruments;