-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmodel.xml
More file actions
152 lines (152 loc) · 7.63 KB
/
model.xml
File metadata and controls
152 lines (152 loc) · 7.63 KB
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
<project heartbeat-interval="1" luaroot="@ESP_PROJECT_OUTPUT@/luaroot" name="trades_lua" pubsub="auto" threads="4">
<description><![CDATA[This model can be used to identify large securities transactions and the traders who were involved in those trades.]]></description>
<metadata>
<meta id="layout">{"trades_cq":{"AddTraderName":{"x":50,"y":295},"BySecurity":{"x":50,"y":665},"LargeTrades":{"x":290,"y":175},"LargeTradesCopy":{"x":290,"y":295},"TotalCost":{"x":50,"y":420},"TotalCostCopy":{"x":50,"y":540},"Traders":{"x":50,"y":175},"Trades":{"x":290,"y":50}}}</meta>
<meta id="studioTags">Example</meta>
<meta id="studioUploadedBy">anonymous</meta>
<meta id="studioUploaded">1764341668597</meta>
<meta id="studioModifiedBy">anonymous</meta>
<meta id="studioModified">1764341698541</meta>
</metadata>
<contqueries>
<contquery name="trades_cq">
<windows>
<window-source index="pi_EMPTY" insert-only="true" name="Trades">
<description><![CDATA[This Source window is where the stock trades from the trades.csv file enter the model. When data is passed into this window, the following date format must be used: %d/%b/%Y:%H:%M:%S]]></description>
<schema>
<fields>
<field name="tradeID" type="string" key="true"/>
<field name="security" type="string"/>
<field name="quantity" type="int32"/>
<field name="price" type="double"/>
<field name="traderID" type="int64"/>
<field name="time" type="stamp"/>
</fields>
</schema>
<connectors>
<connector class="fs" name="input_trades">
<properties>
<property name="type"><![CDATA[pub]]></property>
<property name="dateformat"><![CDATA[%d/%b/%Y:%H:%M:%S]]></property>
<property name="rate"><![CDATA[100]]></property>
<property name="fsname"><![CDATA[@ESP_PROJECT_HOME@/test_files/trades.csv]]></property>
<property name="fstype"><![CDATA[csv]]></property>
</properties>
</connector>
</connectors>
</window-source>
<window-source index="pi_EMPTY" name="Traders">
<description><![CDATA[This Source window is where the trader names from the traders.csv file enter the model.]]></description>
<schema>
<fields>
<field name="ID" type="int64" key="true"/>
<field name="name" type="string"/>
</fields>
</schema>
<connectors>
<connector class="fs" name="input_traders">
<properties>
<property name="type"><![CDATA[pub]]></property>
<property name="fsname"><![CDATA[@ESP_PROJECT_HOME@/test_files/traders.csv]]></property>
<property name="fstype"><![CDATA[csv]]></property>
</properties>
</connector>
</connectors>
</window-source>
<window-filter index="pi_EMPTY" func="filter" name="LargeTrades">
<description><![CDATA[This Filter window filters out all trades that are not in the specified range.]]></description>
<use><![CDATA[quantity]]></use>
<code><![CDATA[
function filter(data)
return data.quantity >= 100
end
]]></code>
</window-filter>
<window-join index="pi_EMPTY" collapse-updates="false" name="AddTraderName">
<description><![CDATA[This Join window combines the large trades with their corresponding trader names.]]></description>
<join type="leftouter" no-regenerates="true">
<conditions>
<fields left="traderID" right="ID"/>
</conditions>
</join>
<output>
<field-selection name="security" source="l_security"/>
<field-selection name="quantity" source="l_quantity"/>
<field-selection name="price" source="l_price"/>
<field-selection name="traderID" source="l_traderID"/>
<field-selection name="time" source="l_time"/>
<field-selection name="name" source="r_name"/>
</output>
</window-join>
<window-copy collapse-updates="false" name="LargeTradesCopy">
<description><![CDATA[This Copy window retains a list of all large trades, in accordance with the retention policy, but only shows Insert events.]]></description>
<retention type="bytime_sliding"><![CDATA[5 minutes]]></retention>
</window-copy>
<window-compute index="pi_EMPTY" name="TotalCost">
<description><![CDATA[This Compute window shows the total cost of each transaction. You can use this information to identify high-value transactions.]]></description>
<schema>
<fields>
<field name="tradeID" type="string" key="true"/>
<field name="security" type="string"/>
<field name="quantity" type="int32"/>
<field name="price" type="double"/>
<field name="totalCost" type="double"/>
<field name="traderID" type="int64"/>
<field name="time" type="stamp"/>
<field name="name" type="string"/>
</fields>
</schema>
<output>
<field-expr><![CDATA[security]]></field-expr>
<field-expr><![CDATA[quantity]]></field-expr>
<field-expr><![CDATA[price]]></field-expr>
<field-expr><![CDATA[price*quantity]]></field-expr>
<field-expr><![CDATA[traderID]]></field-expr>
<field-expr><![CDATA[time]]></field-expr>
<field-expr><![CDATA[name]]></field-expr>
</output>
</window-compute>
<window-copy collapse-updates="false" name="TotalCostCopy">
<description><![CDATA[This Copy window retains a list of the total costs of each transaction, in accordance with the retention policy, but shows Insert events and then Delete events.]]></description>
<retention type="bytime_sliding"><![CDATA[1 days]]></retention>
</window-copy>
<window-aggregate collapse-updates="false" name="BySecurity">
<description><![CDATA[This Aggregate window shows all the inserts, deletes, and update blocks for the large trades.]]></description>
<schema>
<fields>
<field name="security" type="string" key="true"/>
<field name="quantityTotal" type="double"/>
<field name="costTotal" type="double"/>
</fields>
</schema>
<output>
<field-expr><![CDATA[ESP_aSum(quantity)]]></field-expr>
<field-expr><![CDATA[ESP_aSum(totalCost)]]></field-expr>
</output>
</window-aggregate>
</windows>
<edges>
<edge source="Trades" target="LargeTrades"/>
<edge role="left" source="LargeTrades" target="AddTraderName"/>
<edge role="right" source="Traders" target="AddTraderName"/>
<edge source="LargeTrades" target="LargeTradesCopy"/>
<edge source="TotalCost" target="TotalCostCopy"/>
<edge source="AddTraderName" target="TotalCost"/>
<edge source="TotalCostCopy" target="BySecurity"/>
</edges>
</contquery>
</contqueries>
<project-connectors>
<connector-groups>
<connector-group name="Trades">
<connector-entry connector="trades_cq/Trades/input_trades" state="finished"/>
</connector-group>
<connector-group name="Traders">
<connector-entry connector="trades_cq/Traders/input_traders" state="finished"/>
</connector-group>
</connector-groups>
<edges>
<edge source="Traders" target="Trades"/>
</edges>
</project-connectors>
</project>