-
Notifications
You must be signed in to change notification settings - Fork 0
/
trade.view.lkml
164 lines (141 loc) · 3.37 KB
/
trade.view.lkml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
view: trade {
sql_table_name: (SELECT t.*,
CASE
WHEN sc.new_symbol is null then t.security_symbol
ELSE sc.new_symbol
END as symbol
FROM brokerage.trade t
LEFT JOIN brokerage.symbol_convert sc
ON t.security_symbol = sc.old_symbol) ;;
dimension: customer_account_id {
type: number
sql: ${TABLE}.CUSTOMER_ACCOUNT_ID ;;
hidden: yes
}
dimension: executor_id {
type: string
sql: ${TABLE}.EXECUTOR_ID ;;
hidden: yes
}
dimension: trade_id {
primary_key: yes
type: number
sql: ${TABLE}.TRADE_ID ;;
hidden: yes
}
dimension_group: trade {
type: time
timeframes: [
raw,
time,
minute5,
hour_of_day,
date,
day_of_week_index,
week,
day_of_week,
month,
month_num,
month_name,
day_of_month,
quarter,
day_of_year,
year
]
sql: CAST(${TABLE}.TRADE_DT AS TIMESTAMP) ;;
}
dimension: status_type {
hidden: yes
type: string
sql: ${TABLE}.STATUS_TYPE ;;
}
dimension: trade_type {
hidden: yes
type: string
sql: ${TABLE}.TRADE_TYPE ;;
}
dimension: stock_symbol {
hidden: yes
type: string
sql: ${TABLE}.SYMBOL ;;
}
dimension: transaction_type {
type: string
sql: CASE ${TABLE}.IS_CASH WHEN 1 then 'Cash' else 'Non-cash' end;;
}
measure: unique_customer_account_count {
type: count_distinct
sql: ${TABLE}.CUSTOMER_ACCOUNT_ID ;;
}
measure: unique_trade_count {
type: count_distinct
sql: ${TABLE}.TRADE_ID ;;
}
measure: total_trade_price {
type: sum
label: "Total Trade Price"
value_format: "$#.00;($#.00)"
sql: ${TABLE}.TRADE_PRICE ;;
}
measure: average_trade_price {
type: average
label: "Average Trade Price"
value_format: "$#.00;($#.00)"
sql: ${TABLE}.TRADE_PRICE ;;
}
measure:total_bid_price {
type: sum
label: "Total Bid Price"
value_format: "$#.00;($#.00)"
sql: ${TABLE}.BID_PRICE ;;
}
measure:average_bid_price {
type: average
label: "Average Bid Price"
value_format: "$#.00;($#.00)"
sql: ${TABLE}.BID_PRICE ;;
}
measure: total_commission {
type: sum
label: "Total Commission"
value_format: "$#.00;($#.00)"
sql: ${TABLE}.COMMISSION ;;
}
measure: average_commission {
type: average
label: "Average Commission"
value_format: "$#.00;($#.00)"
sql: ${TABLE}.COMMISSION ;;
}
measure: total_fees {
type: sum
value_format: "$#.00;($#.00)"
sql: ${TABLE}.FEES ;;
}
measure: average_fees {
type: average
value_format: "$#.00;($#.00)"
sql: ${TABLE}.FEES ;;
}
measure: total_quantity {
type: sum
sql: ${TABLE}.QUANTITY ;;
}
measure: average_quantity {
type: average
sql: ${TABLE}.QUANTITY ;;
}
measure: total_tax {
type: sum
value_format: "$#.00;($#.00)"
sql: ${TABLE}.TAX ;;
}
measure: average_tax {
type: average
value_format: "$#.00;($#.00)"
sql: ${TABLE}.TAX ;;
}
measure: count {
type: count
}
}