forked from bitfinexcom/bfxfixgw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcancel_test.go
362 lines (305 loc) · 18 KB
/
cancel_test.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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
package main
import (
"fmt"
"time"
"github.com/quickfixgo/enum"
"github.com/quickfixgo/field"
fix42nos "github.com/quickfixgo/fix42/newordersingle"
fix42cxl "github.com/quickfixgo/fix42/ordercancelrequest"
"github.com/shopspring/decimal"
)
func (s *gatewaySuite) TestOrderCancelSimple() {
// assert FIX MD logon
fix, err := s.fixMd.WaitForMessage(s.MarketDataSessionID, 1)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=A", "49=BFXFIX", "56=EXORG_MD")
s.Require().Nil(err)
// assert FIX order logon
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 1)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=A", "49=BFXFIX", "56=EXORG_ORD")
s.Require().Nil(err)
// assume both ws clients connected in setup()
s.srvWs.Broadcast(`{"event":"info","version":2}`)
// assert MD ws auth request
msg, err := s.srvWs.WaitForMessage(MarketDataClient, 0)
s.Require().Nil(err)
s.Require().EqualValues(`{"subId":"nonce1","event":"auth","apiKey":"apiKey1","authSig":"2744ec1afc974eadbda7e09efa03da80578628ba90e2aa5fcba8c2c61014b811f3a8be5a041c3ee35c464a59856b3869","authPayload":"AUTHnonce1","authNonce":"nonce1"}`, msg)
// assert order ws auth request
msg, err = s.srvWs.WaitForMessage(OrdersClient, 0)
s.Require().Nil(err)
s.Require().EqualValues(`{"subId":"nonce1","event":"auth","apiKey":"apiKey1","authSig":"2744ec1afc974eadbda7e09efa03da80578628ba90e2aa5fcba8c2c61014b811f3a8be5a041c3ee35c464a59856b3869","authPayload":"AUTHnonce1","authNonce":"nonce1"}`, msg)
// broadcast auth ack to both clients
s.srvWs.Broadcast(`{"event":"auth","status":"OK","chanId":0,"userId":1,"subId":"nonce1","auth_id":"valid-auth-guid","caps":{"orders":{"read":1,"write":0},"account":{"read":1,"write":0},"funding":{"read":1,"write":0},"history":{"read":1,"write":0},"wallets":{"read":1,"write":0},"withdraw":{"read":0,"write":0},"positions":{"read":1,"write":0}}}`)
// send NOS, ClOrdID MUST be an integer
nos := fix42nos.New(field.NewClOrdID("555"),
field.NewHandlInst(enum.HandlInst_MANUAL_ORDER_BEST_EXECUTION),
field.NewSymbol("BTCUSD"),
field.NewSide(enum.Side_BUY),
field.NewTransactTime(time.Now()),
field.NewOrdType(enum.OrdType_LIMIT))
nos.Set(field.NewOrderQty(decimal.NewFromFloat(1.0), 1))
nos.Set(field.NewPrice(decimal.NewFromFloat(12000.0), 1))
session := s.fixOrd.LastSession()
err = session.Send(nos)
s.Require().Nil(err)
// assert OrderNew
msg, err = s.srvWs.WaitForMessage(OrdersClient, 1)
s.Require().Nil(err)
s.Require().EqualValues(`[0,"on",null,{"gid":0,"cid":555,"type":"EXCHANGE LIMIT","symbol":"BTCUSD","amount":"1","price":"12000"}]`, msg)
// service publish new ack
s.srvWs.Send(OrdersClient, `[0,"n",[null,"on-req",null,null,[1234567,null,555,"tBTCUSD",null,null,1,1,"EXCHANGE LIMIT",null,null,null,null,null,null,null,12000,null,null,null,null,null,null,0,null,null],null,"SUCCESS","Submitting limit buy order for 1.0 BTC."]]`)
// service publish new working
s.srvWs.Send(OrdersClient, `[0,"on",[1234567,0,555,"tBTCUSD",1521153050972,1521153051035,1,1,"EXCHANGE LIMIT",null,null,null,0,"ACTIVE",null,null,12000,0,null,null,null,null,null,0,0,0,null,null,"API>BFX",null,null,null]]`)
// assert FIX execution report NEW
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 2)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "20=3", "32=0.000", "39=0", "54=1", "55=tBTCUSD", "150=0", "151=1.00", "6=0.00", "14=0.00")
s.Require().Nil(err)
// attempt to cancel order
cxl := fix42cxl.New(field.NewOrigClOrdID("555"),
field.NewClOrdID("556"),
field.NewSymbol("BTCUSD"),
field.NewSide(enum.Side_BUY),
field.NewTransactTime(time.Now()))
err = session.Send(cxl)
s.Require().Nil(err)
// assert cancel req
msg, err = s.srvWs.WaitForMessage(OrdersClient, 2)
s.Require().Nil(err)
today := time.Now().Format("2006-01-02")
f := `[0,"oc",null,{"cid":555,"cid_date":"%s"}]`
exp := fmt.Sprintf(f, today)
s.Require().EqualValues(exp, msg)
// publish cancel ack
s.srvWs.Send(OrdersClient, `[0,"n",[1521153051035,"oc-req",null,null,[null,null,555,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,null,null,null,null,null,null,null,null],null,"SUCCESS","Submitted for cancellation; waiting for confirmation (ID: 1234567)."]]`)
// assert FIX PENDING CANCEL
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 3)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "14=0.0000", "20=3", "14=0.0000", "37=1234567", "39=6", "54=1", "151=1.0000")
s.Require().Nil(err)
// publish cancel success
s.srvWs.Send(OrdersClient, `[0,"oc",[1234567,0,555,"tBTCUSD",1521062529896,1521062593974,1,1,"EXCHANGE LIMIT",null,null,null,0,"CANCELED",null,null,12000,0,null,null,null,null,null,0,0,0,null,null,"API>BFX",null,null,null]]`)
// assert FIX CANCEL ack
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 4)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "14=0.0000", "20=3", "32=0.0000", "37=1234567", "39=4", "54=1", "55=tBTCUSD", "150=4")
s.Require().Nil(err)
}
func (s *gatewaySuite) TestOrderCancelInFlightFillOK() {
// assert FIX MD logon
fix, err := s.fixMd.WaitForMessage(s.MarketDataSessionID, 1)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=A", "49=BFXFIX", "56=EXORG_MD")
s.Require().Nil(err)
// assert FIX order logon
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 1)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=A", "49=BFXFIX", "56=EXORG_ORD")
s.Require().Nil(err)
// assume both ws clients connected in setup()
s.srvWs.Broadcast(`{"event":"info","version":2}`)
// assert MD ws auth request
msg, err := s.srvWs.WaitForMessage(MarketDataClient, 0)
s.Require().Nil(err)
s.Require().EqualValues(`{"subId":"nonce1","event":"auth","apiKey":"apiKey1","authSig":"2744ec1afc974eadbda7e09efa03da80578628ba90e2aa5fcba8c2c61014b811f3a8be5a041c3ee35c464a59856b3869","authPayload":"AUTHnonce1","authNonce":"nonce1"}`, msg)
// assert order ws auth request
msg, err = s.srvWs.WaitForMessage(OrdersClient, 0)
s.Require().Nil(err)
s.Require().EqualValues(`{"subId":"nonce1","event":"auth","apiKey":"apiKey1","authSig":"2744ec1afc974eadbda7e09efa03da80578628ba90e2aa5fcba8c2c61014b811f3a8be5a041c3ee35c464a59856b3869","authPayload":"AUTHnonce1","authNonce":"nonce1"}`, msg)
// broadcast auth ack to both clients
s.srvWs.Broadcast(`{"event":"auth","status":"OK","chanId":0,"userId":1,"subId":"nonce1","auth_id":"valid-auth-guid","caps":{"orders":{"read":1,"write":0},"account":{"read":1,"write":0},"funding":{"read":1,"write":0},"history":{"read":1,"write":0},"wallets":{"read":1,"write":0},"withdraw":{"read":0,"write":0},"positions":{"read":1,"write":0}}}`)
// send NOS, ClOrdID MUST be an integer
nos := fix42nos.New(field.NewClOrdID("555"),
field.NewHandlInst(enum.HandlInst_MANUAL_ORDER_BEST_EXECUTION),
field.NewSymbol("BTCUSD"),
field.NewSide(enum.Side_BUY),
field.NewTransactTime(time.Now()),
field.NewOrdType(enum.OrdType_LIMIT))
nos.Set(field.NewOrderQty(decimal.NewFromFloat(1.0), 1))
nos.Set(field.NewPrice(decimal.NewFromFloat(12000.0), 1))
session := s.fixOrd.LastSession()
err = session.Send(nos)
s.Require().Nil(err)
// assert OrderNew
msg, err = s.srvWs.WaitForMessage(OrdersClient, 1)
s.Require().Nil(err)
s.Require().EqualValues(`[0,"on",null,{"gid":0,"cid":555,"type":"EXCHANGE LIMIT","symbol":"BTCUSD","amount":"1","price":"12000"}]`, msg)
// service publish new ack
s.srvWs.Send(OrdersClient, `[0,"n",[null,"on-req",null,null,[1234567,null,555,"tBTCUSD",null,null,1,1,"EXCHANGE LIMIT",null,null,null,null,null,null,null,12000,null,null,null,null,null,null,0,null,null],null,"SUCCESS","Submitting limit buy order for 1.0 BTC."]]`)
// service publish new working
s.srvWs.Send(OrdersClient, `[0,"on",[1234567,0,555,"tBTCUSD",1521153050972,1521153051035,1,1,"EXCHANGE LIMIT",null,null,null,0,"ACTIVE",null,null,12000,0,null,null,null,null,null,0,0,0,null,null,"API>BFX",null,null,null]]`)
// assert FIX execution report NEW
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 2)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "20=3", "32=0.000", "39=0", "54=1", "55=tBTCUSD", "150=0", "151=1.00", "6=0.00", "14=0.00")
s.Require().Nil(err)
// trade execution
s.srvWs.Send(OrdersClient, `[0,"tu",[1,"tBTCUSD",1514909325593,1234567,0.21679716,12000,"MARKET",12000,-1,-0.39712904,"USD"]]`)
// assert FIX execution report PARTIAL FILL
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 3)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "20=3", "32=0.2168", "39=1", "54=1", "55=tBTCUSD", "150=1", "151=0.7832", "6=12000.00", "14=0.2168")
s.Require().Nil(err)
// attempt to cancel order
cxl := fix42cxl.New(field.NewOrigClOrdID("555"),
field.NewClOrdID("556"),
field.NewSymbol("BTCUSD"),
field.NewSide(enum.Side_BUY),
field.NewTransactTime(time.Now()))
err = session.Send(cxl)
s.Require().Nil(err)
// assert cancel req
msg, err = s.srvWs.WaitForMessage(OrdersClient, 2)
s.Require().Nil(err)
today := time.Now().Format("2006-01-02")
f := `[0,"oc",null,{"cid":555,"cid_date":"%s"}]`
exp := fmt.Sprintf(f, today)
s.Require().EqualValues(exp, msg)
// publish cancel ack
s.srvWs.Send(OrdersClient, `[0,"n",[1521153051035,"oc-req",null,null,[null,null,555,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,null,null,null,null,null,null,null,null],null,"SUCCESS","Submitted for cancellation; waiting for confirmation (ID: 1234567)."]]`)
// assert FIX PENDING CANCEL
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 4)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "20=3", "14=0.2168", "37=1234567", "39=6", "54=1", "150=6", "151=0.7832")
s.Require().Nil(err)
// publish cancel success
s.srvWs.Send(OrdersClient, `[0,"oc",[1234567,0,555,"tBTCUSD",1521062529896,1521062593974,1,1,"EXCHANGE LIMIT",null,null,null,0,"CANCELED",null,null,12000,0,null,null,null,null,null,0,0,0,null,null,"API>BFX",null,null,null]]`)
// assert FIX CANCEL ack
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 5)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "14=0.2168", "20=3", "37=1234567", "39=4", "54=1", "55=tBTCUSD", "150=4", "151=0.0000")
s.Require().Nil(err)
}
func (s *gatewaySuite) TestOrderCancelUnknownOrder() {
// assert FIX MD logon
fix, err := s.fixMd.WaitForMessage(s.MarketDataSessionID, 1)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=A", "49=BFXFIX", "56=EXORG_MD")
s.Require().Nil(err)
// assert FIX order logon
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 1)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=A", "49=BFXFIX", "56=EXORG_ORD")
s.Require().Nil(err)
// assume both ws clients connected in setup()
s.srvWs.Broadcast(`{"event":"info","version":2}`)
// assert MD ws auth request
msg, err := s.srvWs.WaitForMessage(MarketDataClient, 0)
s.Require().Nil(err)
s.Require().EqualValues(`{"subId":"nonce1","event":"auth","apiKey":"apiKey1","authSig":"2744ec1afc974eadbda7e09efa03da80578628ba90e2aa5fcba8c2c61014b811f3a8be5a041c3ee35c464a59856b3869","authPayload":"AUTHnonce1","authNonce":"nonce1"}`, msg)
// assert order ws auth request
msg, err = s.srvWs.WaitForMessage(OrdersClient, 0)
s.Require().Nil(err)
s.Require().EqualValues(`{"subId":"nonce1","event":"auth","apiKey":"apiKey1","authSig":"2744ec1afc974eadbda7e09efa03da80578628ba90e2aa5fcba8c2c61014b811f3a8be5a041c3ee35c464a59856b3869","authPayload":"AUTHnonce1","authNonce":"nonce1"}`, msg)
// broadcast auth ack to both clients
s.srvWs.Broadcast(`{"event":"auth","status":"OK","chanId":0,"userId":1,"subId":"nonce1","auth_id":"valid-auth-guid","caps":{"orders":{"read":1,"write":0},"account":{"read":1,"write":0},"funding":{"read":1,"write":0},"history":{"read":1,"write":0},"wallets":{"read":1,"write":0},"withdraw":{"read":0,"write":0},"positions":{"read":1,"write":0}}}`)
// attempt to cancel order
cxl := fix42cxl.New(field.NewOrigClOrdID("555"),
field.NewClOrdID("556"),
field.NewSymbol("BTCUSD"),
field.NewSide(enum.Side_BUY),
field.NewTransactTime(time.Now()))
session := s.fixOrd.LastSession()
err = session.Send(cxl)
s.Require().Nil(err)
// assert cancel req
msg, err = s.srvWs.WaitForMessage(OrdersClient, 1)
s.Require().Nil(err)
today := time.Now().Format("2006-01-02")
f := `[0,"oc",null,{"cid":555,"cid_date":"%s"}]`
exp := fmt.Sprintf(f, today)
s.Require().EqualValues(exp, msg)
// publish cancel error
s.srvWs.Send(OrdersClient, `[0,"n",[1521231457686,"oc-req",null,null,[null,null,555,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,null,null,null,null,null,null,null,null],null,"ERROR","Order not found."]]`)
// assert FIX cancel reject
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 2)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=9", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "11=555", "41=555", "39=8", "434=1", "102=1")
s.Require().Nil(err)
}
func (s *gatewaySuite) TestOrderCancelInFlightFillReject() {
// assert FIX MD logon
fix, err := s.fixMd.WaitForMessage(s.MarketDataSessionID, 1)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=A", "49=BFXFIX", "56=EXORG_MD")
s.Require().Nil(err)
// assert FIX order logon
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 1)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=A", "49=BFXFIX", "56=EXORG_ORD")
s.Require().Nil(err)
// assume both ws clients connected in setup()
s.srvWs.Broadcast(`{"event":"info","version":2}`)
// assert MD ws auth request
msg, err := s.srvWs.WaitForMessage(MarketDataClient, 0)
s.Require().Nil(err)
s.Require().EqualValues(`{"subId":"nonce1","event":"auth","apiKey":"apiKey1","authSig":"2744ec1afc974eadbda7e09efa03da80578628ba90e2aa5fcba8c2c61014b811f3a8be5a041c3ee35c464a59856b3869","authPayload":"AUTHnonce1","authNonce":"nonce1"}`, msg)
// assert order ws auth request
msg, err = s.srvWs.WaitForMessage(OrdersClient, 0)
s.Require().Nil(err)
s.Require().EqualValues(`{"subId":"nonce1","event":"auth","apiKey":"apiKey1","authSig":"2744ec1afc974eadbda7e09efa03da80578628ba90e2aa5fcba8c2c61014b811f3a8be5a041c3ee35c464a59856b3869","authPayload":"AUTHnonce1","authNonce":"nonce1"}`, msg)
// broadcast auth ack to both clients
s.srvWs.Broadcast(`{"event":"auth","status":"OK","chanId":0,"userId":1,"subId":"nonce1","auth_id":"valid-auth-guid","caps":{"orders":{"read":1,"write":0},"account":{"read":1,"write":0},"funding":{"read":1,"write":0},"history":{"read":1,"write":0},"wallets":{"read":1,"write":0},"withdraw":{"read":0,"write":0},"positions":{"read":1,"write":0}}}`)
// send NOS, ClOrdID MUST be an integer
nos := fix42nos.New(field.NewClOrdID("555"),
field.NewHandlInst(enum.HandlInst_MANUAL_ORDER_BEST_EXECUTION),
field.NewSymbol("BTCUSD"),
field.NewSide(enum.Side_BUY),
field.NewTransactTime(time.Now()),
field.NewOrdType(enum.OrdType_LIMIT))
nos.Set(field.NewOrderQty(decimal.NewFromFloat(1.0), 1))
nos.Set(field.NewPrice(decimal.NewFromFloat(12000.0), 1))
session := s.fixOrd.LastSession()
err = session.Send(nos)
s.Require().Nil(err)
// assert OrderNew
msg, err = s.srvWs.WaitForMessage(OrdersClient, 1)
s.Require().Nil(err)
s.Require().EqualValues(`[0,"on",null,{"gid":0,"cid":555,"type":"EXCHANGE LIMIT","symbol":"BTCUSD","amount":"1","price":"12000"}]`, msg)
// service publish new ack
s.srvWs.Send(OrdersClient, `[0,"n",[null,"on-req",null,null,[1234567,null,555,"tBTCUSD",null,null,1,1,"EXCHANGE LIMIT",null,null,null,null,null,null,null,12000,null,null,null,null,null,null,0,null,null],null,"SUCCESS","Submitting limit buy order for 1.0 BTC."]]`)
// service publish new working
s.srvWs.Send(OrdersClient, `[0,"on",[1234567,0,555,"tBTCUSD",1521153050972,1521153051035,1,1,"EXCHANGE LIMIT",null,null,null,0,"ACTIVE",null,null,12000,0,null,null,null,null,null,0,0,0,null,null,"API>BFX",null,null,null]]`)
// assert FIX execution report NEW
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 2)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "20=3", "32=0.000", "39=0", "54=1", "55=tBTCUSD", "150=0", "151=1.00", "6=0.00", "14=0.00")
s.Require().Nil(err)
// trade execution
s.srvWs.Send(OrdersClient, `[0,"tu",[1,"tBTCUSD",1514909325593,1234567,0.21679716,12000,"MARKET",12000,1,-0.39712904,"USD"]]`)
// assert FIX execution report PARTIAL FILL
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 3)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "20=3", "32=0.2168", "39=1", "54=1", "55=tBTCUSD", "150=1", "151=0.7832", "6=12000.00", "14=0.2168")
s.Require().Nil(err)
// trade execution
s.srvWs.Send(OrdersClient, `[0,"tu",[1,"tBTCUSD",1514909325593,1234567,0.78320284,12000,"MARKET",12000,1,-0.39712904,"USD"]]`)
// assert FIX execution report FULL FILL
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 4)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=8", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "20=3", "32=0.7832", "39=2", "54=1", "55=tBTCUSD", "150=2", "151=0.0000", "6=12000", "14=1.000")
s.Require().Nil(err)
// attempt to cancel order
cxl := fix42cxl.New(field.NewOrigClOrdID("555"),
field.NewClOrdID("556"),
field.NewSymbol("BTCUSD"),
field.NewSide(enum.Side_BUY),
field.NewTransactTime(time.Now()))
err = session.Send(cxl)
s.Require().Nil(err)
// assert cancel req
msg, err = s.srvWs.WaitForMessage(OrdersClient, 2)
s.Require().Nil(err)
today := time.Now().Format("2006-01-02")
f := `[0,"oc",null,{"cid":555,"cid_date":"%s"}]`
exp := fmt.Sprintf(f, today)
s.Require().EqualValues(exp, msg)
// publish cancel error
s.srvWs.Send(OrdersClient, `[0,"n",[1521231457686,"oc-req",null,null,[null,null,555,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,null,null,null,null,null,null,null,null],null,"ERROR","Order not found."]]`)
// assert FIX cancel reject
fix, err = s.fixOrd.WaitForMessage(s.OrderSessionID, 5)
s.Require().Nil(err)
err = s.checkFixTags(fix, "35=9", "49=BFXFIX", "56=EXORG_ORD", "1=user123", "37=NONE", "11=555", "41=555", "39=8", "434=1", "102=1")
s.Require().Nil(err)
}