forked from quickfixgo/quickfix
/
ListStatus.go
237 lines (195 loc) · 5.98 KB
/
ListStatus.go
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package liststatus
import (
"time"
"github.com/quickfixgo/quickfix"
"github.com/quickfixgo/quickfix/field"
"github.com/quickfixgo/quickfix/fix40"
"github.com/quickfixgo/quickfix/tag"
)
//ListStatus is the fix40 ListStatus type, MsgType = N
type ListStatus struct {
fix40.Header
quickfix.Body
fix40.Trailer
//ReceiveTime is the time that this message was read from the socket connection
ReceiveTime time.Time
}
//FromMessage creates a ListStatus from a quickfix.Message instance
func FromMessage(m quickfix.Message) ListStatus {
return ListStatus{
Header: fix40.Header{Header: m.Header},
Body: m.Body,
Trailer: fix40.Trailer{Trailer: m.Trailer},
ReceiveTime: m.ReceiveTime,
}
}
//ToMessage returns a quickfix.Message instance
func (m ListStatus) ToMessage() quickfix.Message {
return quickfix.Message{
Header: m.Header.Header,
Body: m.Body,
Trailer: m.Trailer.Trailer,
ReceiveTime: m.ReceiveTime,
}
}
//New returns a ListStatus initialized with the required fields for ListStatus
func New(listid field.ListIDField, norpts field.NoRptsField, rptseq field.RptSeqField) (m ListStatus) {
m.Header = fix40.NewHeader()
m.Init()
m.Trailer.Init()
m.Header.Set(field.NewMsgType("N"))
m.Set(listid)
m.Set(norpts)
m.Set(rptseq)
return
}
//A RouteOut is the callback type that should be implemented for routing Message
type RouteOut func(msg ListStatus, sessionID quickfix.SessionID) quickfix.MessageRejectError
//Route returns the beginstring, message type, and MessageRoute for this Message type
func Route(router RouteOut) (string, string, quickfix.MessageRoute) {
r := func(msg quickfix.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError {
return router(FromMessage(msg), sessionID)
}
return "FIX.4.0", "N", r
}
//SetListID sets ListID, Tag 66
func (m ListStatus) SetListID(v string) {
m.Set(field.NewListID(v))
}
//SetNoOrders sets NoOrders, Tag 73
func (m ListStatus) SetNoOrders(f NoOrdersRepeatingGroup) {
m.SetGroup(f)
}
//SetNoRpts sets NoRpts, Tag 82
func (m ListStatus) SetNoRpts(v int) {
m.Set(field.NewNoRpts(v))
}
//SetRptSeq sets RptSeq, Tag 83
func (m ListStatus) SetRptSeq(v int) {
m.Set(field.NewRptSeq(v))
}
//SetWaveNo sets WaveNo, Tag 105
func (m ListStatus) SetWaveNo(v string) {
m.Set(field.NewWaveNo(v))
}
//GetListID gets ListID, Tag 66
func (m ListStatus) GetListID() (f field.ListIDField, err quickfix.MessageRejectError) {
err = m.Get(&f)
return
}
//GetNoOrders gets NoOrders, Tag 73
func (m ListStatus) GetNoOrders() (NoOrdersRepeatingGroup, quickfix.MessageRejectError) {
f := NewNoOrdersRepeatingGroup()
err := m.GetGroup(f)
return f, err
}
//GetNoRpts gets NoRpts, Tag 82
func (m ListStatus) GetNoRpts() (f field.NoRptsField, err quickfix.MessageRejectError) {
err = m.Get(&f)
return
}
//GetRptSeq gets RptSeq, Tag 83
func (m ListStatus) GetRptSeq() (f field.RptSeqField, err quickfix.MessageRejectError) {
err = m.Get(&f)
return
}
//GetWaveNo gets WaveNo, Tag 105
func (m ListStatus) GetWaveNo() (f field.WaveNoField, err quickfix.MessageRejectError) {
err = m.Get(&f)
return
}
//HasListID returns true if ListID is present, Tag 66
func (m ListStatus) HasListID() bool {
return m.Has(tag.ListID)
}
//HasNoOrders returns true if NoOrders is present, Tag 73
func (m ListStatus) HasNoOrders() bool {
return m.Has(tag.NoOrders)
}
//HasNoRpts returns true if NoRpts is present, Tag 82
func (m ListStatus) HasNoRpts() bool {
return m.Has(tag.NoRpts)
}
//HasRptSeq returns true if RptSeq is present, Tag 83
func (m ListStatus) HasRptSeq() bool {
return m.Has(tag.RptSeq)
}
//HasWaveNo returns true if WaveNo is present, Tag 105
func (m ListStatus) HasWaveNo() bool {
return m.Has(tag.WaveNo)
}
//NoOrders is a repeating group element, Tag 73
type NoOrders struct {
quickfix.Group
}
//SetClOrdID sets ClOrdID, Tag 11
func (m NoOrders) SetClOrdID(v string) {
m.Set(field.NewClOrdID(v))
}
//SetCumQty sets CumQty, Tag 14
func (m NoOrders) SetCumQty(v float64) {
m.Set(field.NewCumQty(v))
}
//SetCxlQty sets CxlQty, Tag 84
func (m NoOrders) SetCxlQty(v float64) {
m.Set(field.NewCxlQty(v))
}
//SetAvgPx sets AvgPx, Tag 6
func (m NoOrders) SetAvgPx(v float64) {
m.Set(field.NewAvgPx(v))
}
//GetClOrdID gets ClOrdID, Tag 11
func (m NoOrders) GetClOrdID() (f field.ClOrdIDField, err quickfix.MessageRejectError) {
err = m.Get(&f)
return
}
//GetCumQty gets CumQty, Tag 14
func (m NoOrders) GetCumQty() (f field.CumQtyField, err quickfix.MessageRejectError) {
err = m.Get(&f)
return
}
//GetCxlQty gets CxlQty, Tag 84
func (m NoOrders) GetCxlQty() (f field.CxlQtyField, err quickfix.MessageRejectError) {
err = m.Get(&f)
return
}
//GetAvgPx gets AvgPx, Tag 6
func (m NoOrders) GetAvgPx() (f field.AvgPxField, err quickfix.MessageRejectError) {
err = m.Get(&f)
return
}
//HasClOrdID returns true if ClOrdID is present, Tag 11
func (m NoOrders) HasClOrdID() bool {
return m.Has(tag.ClOrdID)
}
//HasCumQty returns true if CumQty is present, Tag 14
func (m NoOrders) HasCumQty() bool {
return m.Has(tag.CumQty)
}
//HasCxlQty returns true if CxlQty is present, Tag 84
func (m NoOrders) HasCxlQty() bool {
return m.Has(tag.CxlQty)
}
//HasAvgPx returns true if AvgPx is present, Tag 6
func (m NoOrders) HasAvgPx() bool {
return m.Has(tag.AvgPx)
}
//NoOrdersRepeatingGroup is a repeating group, Tag 73
type NoOrdersRepeatingGroup struct {
*quickfix.RepeatingGroup
}
//NewNoOrdersRepeatingGroup returns an initialized, NoOrdersRepeatingGroup
func NewNoOrdersRepeatingGroup() NoOrdersRepeatingGroup {
return NoOrdersRepeatingGroup{
quickfix.NewRepeatingGroup(tag.NoOrders,
quickfix.GroupTemplate{quickfix.GroupElement(tag.ClOrdID), quickfix.GroupElement(tag.CumQty), quickfix.GroupElement(tag.CxlQty), quickfix.GroupElement(tag.AvgPx)})}
}
//Add create and append a new NoOrders to this group
func (m NoOrdersRepeatingGroup) Add() NoOrders {
g := m.RepeatingGroup.Add()
return NoOrders{g}
}
//Get returns the ith NoOrders in the NoOrdersRepeatinGroup
func (m NoOrdersRepeatingGroup) Get(i int) NoOrders {
return NoOrders{m.RepeatingGroup.Get(i)}
}