forked from quickfixgo/quickfix
/
DontKnowTrade.go
92 lines (85 loc) · 3.98 KB
/
DontKnowTrade.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
//Package dontknowtrade msg type = Q.
package dontknowtrade
import (
"github.com/quickfixgo/quickfix"
"github.com/quickfixgo/quickfix/enum"
"github.com/quickfixgo/quickfix/fix50sp1/instrmtleggrp"
"github.com/quickfixgo/quickfix/fix50sp1/instrument"
"github.com/quickfixgo/quickfix/fix50sp1/orderqtydata"
"github.com/quickfixgo/quickfix/fix50sp1/undinstrmtgrp"
"github.com/quickfixgo/quickfix/fixt11"
)
//Message is a DontKnowTrade FIX Message
type Message struct {
FIXMsgType string `fix:"Q"`
fixt11.Header
//OrderID is a required field for DontKnowTrade.
OrderID string `fix:"37"`
//SecondaryOrderID is a non-required field for DontKnowTrade.
SecondaryOrderID *string `fix:"198"`
//ExecID is a required field for DontKnowTrade.
ExecID string `fix:"17"`
//DKReason is a required field for DontKnowTrade.
DKReason string `fix:"127"`
//Instrument is a required component for DontKnowTrade.
instrument.Instrument
//UndInstrmtGrp is a non-required component for DontKnowTrade.
UndInstrmtGrp *undinstrmtgrp.UndInstrmtGrp
//InstrmtLegGrp is a non-required component for DontKnowTrade.
InstrmtLegGrp *instrmtleggrp.InstrmtLegGrp
//Side is a required field for DontKnowTrade.
Side string `fix:"54"`
//OrderQtyData is a required component for DontKnowTrade.
orderqtydata.OrderQtyData
//LastQty is a non-required field for DontKnowTrade.
LastQty *float64 `fix:"32"`
//LastPx is a non-required field for DontKnowTrade.
LastPx *float64 `fix:"31"`
//Text is a non-required field for DontKnowTrade.
Text *string `fix:"58"`
//EncodedTextLen is a non-required field for DontKnowTrade.
EncodedTextLen *int `fix:"354"`
//EncodedText is a non-required field for DontKnowTrade.
EncodedText *string `fix:"355"`
fixt11.Trailer
}
//Marshal converts Message to a quickfix.Message instance
func (m Message) Marshal() quickfix.Message { return quickfix.Marshal(m) }
//New returns an initialized DontKnowTrade instance
func New(orderid string, execid string, dkreason string, instrument instrument.Instrument, side string, orderqtydata orderqtydata.OrderQtyData) *Message {
var m Message
m.SetOrderID(orderid)
m.SetExecID(execid)
m.SetDKReason(dkreason)
m.SetInstrument(instrument)
m.SetSide(side)
m.SetOrderQtyData(orderqtydata)
return &m
}
func (m *Message) SetOrderID(v string) { m.OrderID = v }
func (m *Message) SetSecondaryOrderID(v string) { m.SecondaryOrderID = &v }
func (m *Message) SetExecID(v string) { m.ExecID = v }
func (m *Message) SetDKReason(v string) { m.DKReason = v }
func (m *Message) SetInstrument(v instrument.Instrument) { m.Instrument = v }
func (m *Message) SetUndInstrmtGrp(v undinstrmtgrp.UndInstrmtGrp) { m.UndInstrmtGrp = &v }
func (m *Message) SetInstrmtLegGrp(v instrmtleggrp.InstrmtLegGrp) { m.InstrmtLegGrp = &v }
func (m *Message) SetSide(v string) { m.Side = v }
func (m *Message) SetOrderQtyData(v orderqtydata.OrderQtyData) { m.OrderQtyData = v }
func (m *Message) SetLastQty(v float64) { m.LastQty = &v }
func (m *Message) SetLastPx(v float64) { m.LastPx = &v }
func (m *Message) SetText(v string) { m.Text = &v }
func (m *Message) SetEncodedTextLen(v int) { m.EncodedTextLen = &v }
func (m *Message) SetEncodedText(v string) { m.EncodedText = &v }
//A RouteOut is the callback type that should be implemented for routing Message
type RouteOut func(msg Message, 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 {
m := new(Message)
if err := quickfix.Unmarshal(msg, m); err != nil {
return err
}
return router(*m, sessionID)
}
return enum.ApplVerID_FIX50SP1, "Q", r
}