-
Notifications
You must be signed in to change notification settings - Fork 1
/
tutorialBasic.ipl
103 lines (94 loc) · 2.19 KB
/
tutorialBasic.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
//
// Imandra Inc.
// Copyright (c) 2024
//
// Code for 'Basic Model'
//
//
// For further info see https://docs.imandra.ai
//
//
import FIX_4_4
@title: "Basic Model"
messageFlows {
NewOrderOnly {
name "NewOrderOnly"
description "Send NewOrderSingle Message"
template[NewOrderSingle]
}
}
message NewOrderSingle {
req ClOrdID
req Side
req TransactTime
req OrdType valid when it in [ OrdType.Limit, OrdType.Market ]
req OrderQtyData.OrderQty
opt Price
ign Account
validate {
(this.OrdType == OrdType.Market <==> !present(this.Price)) &&
(this.OrdType == OrdType.Limit ==> present(this.Price))
}
validate {
this.OrdType == OrdType.Limit ==>
(case this.Price
{Some price: price > 0.0}
{None: false}
)
}
}
outbound message ExecutionReport {
req OrderID
req ExecID
req ExecType
req OrdStatus
req Side
req OrderQtyData.OrderQty
req LeavesQty
req CumQty
opt Text
}
receive (msg:NewOrderSingle){
send ExecutionReport {
OrderID = msg.ClOrdID;
ExecID = fresh();
ExecType = ExecType.New;
OrdStatus = OrdStatus.New;
Side = msg.Side;
OrderQtyData.OrderQty = msg.OrderQtyData.OrderQty;
LeavesQty = msg.OrderQtyData.OrderQty;
CumQty = 0.0;
}
}
reject (msg:NewOrderSingle, text:string)
{
missingfield:{
send ExecutionReport {
OrderID = fresh();
ExecID = fresh();
ExecType = ExecType.New;
OrdStatus = OrdStatus.New;
/* we don't have access to the message here as it is
* incomplete, so we must put in a dummy value as it
is required in ExecutionReport */
Side = Side.Buy;
OrderQtyData.OrderQty = 0.0;
LeavesQty = 0.0;
CumQty = 0.0;
Text = Some text;
}
}
invalidfield, invalid:{
send ExecutionReport {
OrderID = msg.ClOrdID;
ExecID = "REJECTID";
ExecType = ExecType.New;
OrdStatus = OrdStatus.New;
Side = msg.Side;
OrderQtyData.OrderQty = msg.OrderQtyData.OrderQty;
LeavesQty = msg.OrderQtyData.OrderQty;
CumQty = 0.0;
Text = Some text;
}
}
}