Skip to content

Commit d5238f8

Browse files
author
Chris Busbey
committed
docs for receiving messages, sample config
1 parent 211bc77 commit d5238f8

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

doc.go

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,89 @@ SessionSettings can be read in from any input stream such as a file stream. If y
8484
A settings file is set up with two types of heading, a [DEFAULT] and a [SESSION] heading. [SESSION] tells QuickFIX/Go that a new Session is being defined. [DEFAULT] is a place that you can define settings which will be inherited by sessions that don't explicitly define them. If you do not provide a setting that QuickFIX/Go needs, it will return an error indicating that a setting is missing or improperly formatted.
8585
8686
See the quickfix/config package for settings you can associate with a session based on the default components provided with QuickFIX/Go.
87+
88+
Here is a typical initiator settings file you might find for a firm that wants to connect to several ECNs.
89+
90+
# default settings for sessions
91+
[DEFAULT]
92+
FileLogPath=log
93+
SenderCompID=TW
94+
95+
# session definition
96+
[SESSION]
97+
# inherit FileLogPath, SenderCompID from default
98+
BeginString=FIX.4.1
99+
TargetCompID=ARCA
100+
HeartBtInt=20
101+
SocketConnectPort=9823
102+
SocketConnectHost=123.123.123.123
103+
DataDictionary=somewhere/FIX41.xml
104+
105+
[SESSION]
106+
BeginString=FIX.4.0
107+
TargetCompID=ISLD
108+
HeartBtInt=30
109+
SocketConnectPort=8323
110+
SocketConnectHost=23.23.23.23
111+
DataDictionary=somewhere/FIX40.xml
112+
113+
[SESSION]
114+
BeginString=FIX.4.2
115+
TargetCompID=INCA
116+
HeartBtInt=30
117+
SocketConnectPort=6523
118+
SocketConnectHost=3.3.3.3
119+
DataDictionary=somewhere/FIX42.xml
120+
121+
Receiving Messages
122+
123+
Most of the messages you will be interested in looking at will be arriving in your FromApp function of your application. All messages have a header and trailer. If you want to get Header or Trailer fields, you must access those fields from the Header or Trailer embedded Struct. All other fields are accessible in the Body embedded struct.
124+
125+
QuickFIX/Go has a type for all messages, components, and fields defined in the standard spec. The easiest and most typesafe method of receiving messages is by using the quickfix MessageRouter generated message types.
126+
127+
import "github.com/quickfixgo/quickfix/fix42/newordersingle"
128+
129+
type MyApplication struct {
130+
*quickfix.MessageRouter
131+
}
132+
133+
func (m *MyApplication) init() {
134+
m.MessageRouter=quickfix.NewMessageRouter()
135+
m.AddRoute(newordersingle.Route(m.onNewOrderSingle))
136+
}
137+
138+
func (m *MyApplication) FromApp(msg quickfix.Message, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
139+
return m.Route(msg, sessionID)
140+
}
141+
142+
func (m *MyApplication) onNewOrderSingle(msg newordersingle.Message, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
143+
price:=msg.Price
144+
clordID:=msg.ClOrdID
145+
146+
return
147+
}
148+
149+
You can also bypass the MessageRouter and type safe classes by inspecting the Message directly. The preferred way of doing this is to use the quickfix generated Field types.
150+
151+
import "github.com/quickfixgo/quickfix/field"
152+
153+
func (m *MyApplication) FromApp(msg quickfix.Message, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
154+
price:=new(field.PriceField)
155+
if err=msg.Body.Get(field); err!=nil {
156+
return
157+
}
158+
159+
clordid:=new(field.ClOrdID)
160+
err=msg.Body.Get(field)
161+
return
162+
}
163+
164+
165+
Or you can go the least type safe route.
166+
func (m *MyApplication) FromApp(msg quickfix.Message, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
167+
field:=new(quickfix.FIXString)
168+
err:=msg.Body.GetField(quickfix.Tag(44), field)
169+
return
170+
}
87171
*/
88172
package quickfix

0 commit comments

Comments
 (0)