-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmodel.xml
103 lines (98 loc) · 4.08 KB
/
model.xml
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
<project heartbeat-interval="1" luaroot="@ESP_PROJECT_OUTPUT@/luaroot" name="lua_pattern" pubsub="auto" threads="1">
<description><![CDATA[This model identifies increases in a stock's price within a specific time interval. The Pattern window uses Lua code to define the events of interest to be matched.]]></description>
<metadata>
<meta id="studioUploadedBy">anonymousUser</meta>
<meta id="studioUploaded">1722341401254</meta>
<meta id="studioModifiedBy">anonymousUser</meta>
<meta id="studioModified">1722341525270</meta>
<meta id="layout">{"cq1":{"patternWindow_01":{"x":50,"y":175},"sourceWindow_01":{"x":50,"y":50}}}</meta>
<meta id="studioTags">Example</meta>
</metadata>
<contqueries>
<contquery name="cq1">
<windows>
<window-source index="pi_EMPTY" insert-only="true" name="sourceWindow_01">
<description><![CDATA[This Source window is where stock trades from the stocktrades.csv file enter the model. When data is passed into this window, the following date format must be used: %Y-%m-%d %H:%M:%S]]></description>
<schema>
<fields>
<field key="true" name="ID" type="int32"/>
<field name="symbol" type="string"/>
<field name="currency" type="int32"/>
<field name="udate" type="int64"/>
<field name="msecs" type="int32"/>
<field name="price" type="double"/>
<field name="quant" type="int32"/>
<field name="venue" type="int32"/>
<field name="broker" type="int32"/>
<field name="buyer" type="int32"/>
<field name="seller" type="int32"/>
<field name="buysellflg" type="int32"/>
<field name="trade_time" type="stamp"/>
</fields>
</schema>
<connectors>
<connector class="fs" name="input_pattern">
<properties>
<property name="type"><![CDATA[pub]]></property>
<property name="dateformat"><![CDATA[%Y-%m-%d %H:%M:%S]]></property>
<property name="fsname"><![CDATA[@ESP_PROJECT_HOME@/test_files/stocktrades.csv]]></property>
<property name="fstype"><![CDATA[csv]]></property>
</properties>
</connector>
</connectors>
</window-source>
<window-pattern name="patternWindow_01">
<description><![CDATA[Stock trade patterns are matched in this Pattern window.]]></description>
<schema>
<fields>
<field key="true" name="ID" type="int64"/>
<field name="ID1" type="int32"/>
<field name="ID2" type="int32"/>
<field name="ID3" type="int32"/>
</fields>
</schema>
<patterns>
<pattern name="pattern1" index="symbol">
<lua-events>
<event name="e1" func="f1"/>
<event name="e2" func="f2"/>
<event name="e3" func="f3"/>
</lua-events>
<logic><![CDATA[fby{200 milliseconds}(e1, e2, e3)]]></logic>
<code output="output"><![CDATA[function f1(event,context)
if (event.symbol=="GMTC") then
return true,{p0=event.price,q0=event.quant}
end
return false
end
function f2(event,context)
if (context.data.p0<event.price*1.5 and context.data.q0<event.quant*1.5)
then
return true,{p1=event.price,q1=event.quant}
end
return false
end
function f3(event,context)
return context.data.p1<event.price*1.5 and context.data.q1<event.quant*1.5
end
function output(context)
local event = {}
event.ID1 = context.events.e1.ID
event.ID2 = context.events.e2.ID
event.ID3 = context.events.e3.ID
return event
end
]]></code>
<timefields>
<timefield source="sourceWindow_01" field="trade_time"/>
</timefields>
</pattern>
</patterns>
</window-pattern>
</windows>
<edges>
<edge source="sourceWindow_01" target="patternWindow_01"/>
</edges>
</contquery>
</contqueries>
</project>