-
Notifications
You must be signed in to change notification settings - Fork 1
/
tutorialState.ipl
107 lines (98 loc) · 2.16 KB
/
tutorialState.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
//
// Imandra Inc.
// Copyright (c) 2024
//
// Code for 'Tutorial State Model'
//
// For further info see https://docs.imandra.ai
//
//
//
import FIX_4_4
@title: "Tutorial State Model"
messageFlows {
NewOrderOnly {
name "NewOrderOnly"
description "Send NewOrderSingle Message"
template[NewOrderSingle]
}
}
internal state {
assignable{
Side : Side
Price :? Price
OrderQtyData.OrderQty : Qty
OrdType : OrdType
OrdStatus : OrdStatus = OrdStatus.PendingNew;
ExecType : ExecType = ExecType.PendingNew;
LeavesQty : Qty
CumQty : Qty
OrderID : string
}
live_order : bool = false;
AvgPx : float
bestBid : float
bestAsk : float
}
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){
state.live_order = true
state.LeavesQty = msg.OrderQtyData.OrderQty
state.OrderID = fresh()
state.OrdStatus = OrdStatus.New
assignFrom(msg,state)
send ExecutionReport {
state with
ExecID = fresh();
ExecType = ExecType.New;
}
}
reject (msg:NewOrderSingle, text:string)
{
missingfield:{
send ExecutionReport {
state with
ExecID = fresh();
Text = Some text;
}
}
invalidfield, invalid:{
state.ExecType = ExecType.Rejected
state.OrdStatus = OrdStatus.Rejected
send ExecutionReport {
state with
ExecID = fresh();
Text = Some text;
}
}
}