-
Notifications
You must be signed in to change notification settings - Fork 1
/
repeatingGroupsSimple.ipl
104 lines (88 loc) · 2.58 KB
/
repeatingGroupsSimple.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
//
// 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 = "";
}
}
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
valid when present(it.NoUnderlyings)
valid when it.UnderlyingInstrument.EncodedUnderlyingIssuer == ("a")
valid when it.UnderlyingInstrument.UndSecAltIDGrp.UnderlyingSecurityAltIDSource == SecurityIDSource.Belgian
// for elements of component blocks, each one must be explicitly imported
opt Instrument.CFICode valid when it == (Some "")
}
action fill {
// a declaration of an action field which is a repeating group type
undInstrmntGrp : UndInstrmtGrp
cumQty : float
}
repeatingGroup UndSecAltIDGrp {
req NoUnderlyingSecurityAltID
req UnderlyingSecurityAltIDSource
}
repeatingGroup UndInstrmtGrp {
opt NoUnderlyings
req UnderlyingInstrument.EncodedUnderlyingIssuer
req UnderlyingInstrument.UndSecAltIDGrp
}
message NewOrderSingle {
opt Account default = "d"
opt AccountType
req ClOrdID
req Side
req TransactTime
req OrdType
req UndInstrmtGrp
req Instrument.CFICode
}
receive (msg:NewOrderSingle){
// the state assignable variables are set here
// including all element of the repeating group recursively
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
}