forked from cyanly/gotrade
/
execution_fix44.go
46 lines (38 loc) · 1.32 KB
/
execution_fix44.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
package order
import (
"time"
"github.com/quickfixgo/quickfix"
fix44er "github.com/quickfixgo/quickfix/fix44/executionreport"
proto "github.com/cyanly/gotrade/proto/order"
util "github.com/cyanly/gotrade/services/marketconnectors"
)
// Common route handler for FIX4.4 Execution Report message
// this function can be sub-classed to extend with special fields if a market connector requires
func (app FIXClient) onFIX44ExecutionReport(msg fix44er.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError {
// Construct execution report protobuf struct from FIX message
er := &proto.Execution{
// required fields
ClientOrderId: *msg.ClOrdID,
BrokerOrderId: msg.OrderID,
ExecType: proto.Execution_ExecType(util.FIXEnumToProtoEnum(msg.ExecType)),
OrderStatus: proto.OrderStatus(util.FIXEnumToProtoEnum(msg.OrdStatus)),
BrokerExecId: msg.ExecID,
CumQuantity: msg.CumQty,
AvgPrice: msg.AvgPx,
// common tags
Quantity: *msg.LastQty,
Price: *msg.LastPx,
Lastmkt: *msg.LastMkt,
}
if msg.TransactTime != nil {
er.BrokerExecDatetime = msg.TransactTime.UTC().Format(time.RFC3339Nano)
}
if msg.ExecRefID != nil {
er.PrevBrokerExecId = *msg.ExecRefID
}
if msg.Text != nil {
er.Text = *msg.Text
}
//TODO: Check for Dups - Tags.PossDupFlag
return app.processExecutionReport(er)
}