-
Notifications
You must be signed in to change notification settings - Fork 1
/
repeatingGroupsComplex.ipl
129 lines (104 loc) · 3.67 KB
/
repeatingGroupsComplex.ipl
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
//
// Imandra Inc.
// Copyright (c) 2024
//
// FIX 4.4 model with example repeating groups import
//
//
// For further info see https://docs.imandra.ai
//
//
import FIX_4_4
internal state {
assignable {
Side : Side = Side.Buy;
AccountType :? AccountType
Account : string = "";
OrderID: string = "";
ExecID: string = "";
ExecType:ExecType = ExecType.Trade;
LeavesQty:Qty = 0.0;
CumQty:Qty = 0.0;
AvgPx:Price = 0.0;
OrdStatus:OrdStatus = OrdStatus.Replaced;
// UndInstrmtGrp is a Repeating Group
UndInstrmtGrp: UndInstrmtGrp
// CFICode is a field within a component block.
// It is imported in messages both optionally and as a required field
// thus it has the ':*' annotation
Instrument.CFICode :* string = "1";
}
}
outbound message ExecutionReport {
req Account
opt AccountType
req OrderID
req ExecID
req ExecType
req OrdStatus
req Side
req LeavesQty
req CumQty
req AvgPx
// for repeating groups the whole group is imported and the optionality of field elements
// is the same for each copy
req UndInstrmtGrp
// for elements of component blocks, each one must be explicitly imported
opt Instrument.CFICode valid when it == (Some "")
}
repeatingGroup UndSecAltIDGrp {
req NoUnderlyingSecurityAltID
req UnderlyingSecurityAltIDSource
}
repeatingGroup UndInstrmtGrp {
opt NoUnderlyings
req UnderlyingInstrument.UnderlyingContractMultiplier
opt UnderlyingInstrument.EncodedUnderlyingIssuer
req UnderlyingInstrument.UndSecAltIDGrp
}
// a test to allow record in action
repeatingGroup UnderlyingStipulations {
req NoUnderlyingStips
req UnderlyingStipType
}
action fill {
// a declaration of an action field which is a repeating group type
//undInstrmntGrp : UndInstrmtGrp
testRec: UnderlyingInstrument
cumQty : float
}
message NewOrderSingle {
opt Account default = "d"
opt AccountType
req ClOrdID
req Side
req TransactTime
req OrdType valid when it in [OrdType.Limit, OrdType.Market] valid when it != MarketWithLeftOverAsLimit
req UndInstrmtGrp
valid when present(it.NoUnderlyings)
valid when it.UnderlyingInstrument.EncodedUnderlyingIssuer == (Some "a")
valid when it.UnderlyingInstrument.UndSecAltIDGrp.UnderlyingSecurityAltIDSource == SecurityIDSource.Belgian
// for elements of component blocks, each one must be explicitly imported
req Instrument.CFICode
// this is a validate statement which implicitly checks each copy of every repeating group
validate{this.UndInstrmtGrp.UnderlyingInstrument.EncodedUnderlyingIssuer ==
(if this.UndInstrmtGrp.UnderlyingInstrument.UndSecAltIDGrp.UnderlyingSecurityAltIDSource == (SecurityIDSource.Belgian) then (Some "Belgian") else (Some "NotBelgian")) &&
this.UndInstrmtGrp.UnderlyingInstrument.EncodedUnderlyingIssuer in ["a","b","c"]}
}
receive (msg:NewOrderSingle){
// the state assignable variables are set here
// including all element of the repeating group recursively
// can write a repeating groups comparison statement
// which checks each element of the repeating group
// this is only allowed for boolean type expressions
if msg.UndInstrmtGrp.UnderlyingInstrument.EncodedUnderlyingIssuer in ["a","b","c"] then return
assignFrom(msg,state)
send ExecutionReport state
}
receive (f:fill){
//state.UndInstrmtGrp = f.undInstrmntGrp
if f.cumQty > state.CumQty then
// here the "with" assignment overrides any within state
send ExecutionReport {state with CumQty = f.cumQty;}
else send ExecutionReport state
}