-
Notifications
You must be signed in to change notification settings - Fork 1
/
ordersOnlyExplicitFrom44.ipl
92 lines (76 loc) · 2.18 KB
/
ordersOnlyExplicitFrom44.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
//
// Imandra Inc.
// Copyright (c) 2024
//
// Minimal FIX 4.2 model with explicit import from 4.4
//
//
// For further info see https://docs.imandra.ai
//
//
import FIX_4_2
import FIX_4_4
// Import an explicitly reference message from another Library
message FIX_4_4.NewOrderSingle {
req ClOrdID
// Side can reference the union of values from 4.2 and 4.4
// such as Redeem
req Side valid when it != Side.Redeem
req TransactTime
req OrdType valid when it in [ OrdType.Limit, OrdType.Market ]
req HandlInst
validate { state.live_order == false }
}
//
// Import an outbound message we would send out
//
//
outbound message ExecutionReport {
req OrderID
req ExecID
req ExecType
req OrdStatus
// note how Side includes enum values from the 4.4 dictionary
// as we have an explicit import
req Side valid when it != Side.Redeem
req LeavesQty
req CumQty
req AvgPx
req ExecTransType
req Symbol
}
// Define our internal state
internal state {
// The following fields would be assigned to
assignable {
OrdStatus : OrdStatus = OrdStatus.New;
Side : Side = Side.Buy;
LeavesQty : Qty = 0.0;
CumQty : Qty = 0.0;
AvgPx : Price = 0.0;
}
live_order : bool = false;
// These are not required within the orders, etc...
OrdQty : Qty = 0.0;
current_time : UTCTimeOnly = UTCTimeOnly (8, 0, 0, None);
// Define the opening and closing times
opening_time : UTCTimeOnly = UTCTimeOnly (8, 0, 0, None);
closing_time : UTCTimeOnly = UTCTimeOnly (16, 0, 0, None);
}
receive (msg:FIX_4_4.NewOrderSingle){
// Extract all relevant fields from within the message
assignFrom (msg, state)
state.live_order = true
send ExecutionReport {
state with
ExecID = "";
OrderID = msg.ClOrdID;
ExecType = ExecType.New;
ExecTransType = ExecTransType.New;
Symbol = "";
// override Side with a new value
// this can come from the union of Side values
// from 4.2 or 4.4
Side = Side.Redeem;
}
}