Skip to content

Commit 7a28360

Browse files
author
Chris Busbey
committed
documentation
1 parent 0d6f273 commit 7a28360

File tree

3 files changed

+6
-192
lines changed

3 files changed

+6
-192
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Open Source [FIX Protocol](http://www.fixprotocol.org/) library implemented in G
1111
Getting Started and Documentation
1212
---------------------------------
1313

14-
All documentation is available on [GoDoc](https://godoc.org/github.com/quickfixgo/quickfix).
14+
* [User Manual](http://quickfixgo.org/docs)
15+
* [API Documentation](https://godoc.org/github.com/quickfixgo/quickfix)
1516

1617
### Installation
1718

config/configuration.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package config
22

3+
//NOTE: Additions to this file should be made to both config/doc.go and http://www.quickfixgo.org/docs/
4+
5+
//Const configuration settings
36
const (
47
BeginString string = "BeginString"
58
SenderCompID string = "SenderCompID"

doc.go

Lines changed: 1 addition & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -1,196 +1,6 @@
11
/*
22
Package quickfix is a full featured messaging engine for the FIX protocol. It is a 100% Go open source implementation of the popular C++ QuickFIX engine (http://quickfixengine.org).
33
4-
Creating your QuickFIX Application
5-
6-
Creating a FIX application is as easy as implementing the QuickFIX Application interface. By implementing these interface methods in your derived type, you are requesting to be notified of events that occur on the FIX engine. The function that you should be most aware of is fromApp.
7-
8-
Here are explanations of what these callback functions provide for you.
9-
10-
OnCreate(sessionID SessionID)
11-
12-
OnCreate is called when quickfix creates a new session. A session comes into and remains in existence for the life of the application. Sessions exist whether or not a counter party is connected to it. As soon as a session is created, you can begin sending messages to it. If no one is logged on, the messages will be sent at the time a connection is established with the counterparty.
13-
14-
OnLogon(sessionID SessionID)
15-
16-
OnLogon notifies you when a valid logon has been established with a counter party. This is called when a connection has been established and the FIX logon process has completed with both parties exchanging valid logon messages.
17-
18-
OnLogout(sessionID SessionID)
19-
20-
OnLogout notifies you when an FIX session is no longer online. This could happen during a normal logout exchange or because of a forced termination or a loss of network connection.
21-
22-
ToAdmin(message Message, sessionID SessionID)
23-
24-
ToAdmin provides you with a peak at the administrative messages that are being sent from your FIX engine to the counter party. This is normally not useful for an application however it is provided for any logging you may wish to do. Notice that the Message is not const. This allows you to add fields before an administrative message is sent out.
25-
26-
ToApp(message Message, sessionID SessionID) error
27-
28-
ToApp notifies you of application messages that you are being sent to a counterparty. Notice that the Message is not const. This allows you to add fields before an application message before it is sent out.
29-
30-
FromAdmin(message Message, sessionID SessionID) MessageRejectError
31-
32-
FromAdmin notifies you when an administrative message is sent from a counterparty to your FIX engine. This can be useful for doing extra validation on logon messages such as for checking passwords.
33-
34-
FromApp(msg Message, sessionID SessionID) MessageRejectError
35-
36-
FromApp is one of the core entry points for your FIX application. Every application level request will come through here. If, for example, your application is a sell-side OMS, this is where you will get your new order requests. If you were a buy side, you would get your execution reports here.
37-
38-
The sample code below shows how you might start up a FIX acceptor which listens on a socket. If you wanted an initiator, you would simply replace NewAcceptor in this code fragment with NewInitiator.
39-
40-
package main
41-
42-
import (
43-
"flag"
44-
"github.com/quickfixgo/quickfix"
45-
"os"
46-
)
47-
48-
func main() {
49-
flag.Parse()
50-
fileName := flag.Arg(0)
51-
52-
//FooApplication is your type that implements the Application interface
53-
var app FooApplication
54-
55-
cfg, _ := os.Open(fileName)
56-
appSettings, _ := quickfix.ParseSettings(cfg)
57-
storeFactory := quickfix.NewMemoryStoreFactory()
58-
logFactory, _ := quickfix.NewFileLogFactory(appSettings)
59-
acceptor, _ := quickfix.NewAcceptor(app, storeFactory, appSettings, logFactory)
60-
61-
acceptor.Start()
62-
//for condition == true { do something }
63-
acceptor.Stop()
64-
}
65-
66-
Configuring QuickFIX
67-
68-
A QuickFIXGo acceptor or initiator can maintain as many FIX sessions as you would like. A FIX session is identified by a group of settings defined within the configuration section for a session (or inherited from the default section). The identification settings are:
69-
70-
| Setting | Required? |
71-
|--------------|-----------|
72-
| BeginString | Y |
73-
| SenderCompID | Y |
74-
| SenderSubID | N |
75-
| TargetCompID | Y |
76-
| TargetSubID | N |
77-
78-
The sender settings are your identification and the target settings are for the counterparty. A SessionQualifier can also be use to disambiguate otherwise identical sessions.
79-
80-
Each of the sessions can have several settings associated with them. Some of these settings may not be known at compile time and are therefore passed around in a struct called SessionSettings.
81-
82-
SessionSettings can be read in from any input stream such as a file stream. If you decide to write your own components, (storage for a particular database, a new kind of connector etc...), you may also use the session settings to store settings for your custom component.
83-
84-
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.
85-
86-
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 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. Any messages you do not establish routes for will by default return an UnsupportedMessageType reject.
126-
127-
import (
128-
"github.com/quickfixgo/quickfix"
129-
"github.com/quickfixgo/quickfix/field"
130-
"github.com/quickfixgo/quickfix/fix41/newordersingle"
131-
)
132-
133-
type MyApplication struct {
134-
*quickfix.MessageRouter
135-
}
136-
137-
func (m *MyApplication) init() {
138-
m.MessageRouter=quickfix.NewMessageRouter()
139-
m.AddRoute(newordersingle.Route(m.onNewOrderSingle))
140-
}
141-
142-
func (m *MyApplication) FromApp(msg quickfix.Message, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
143-
return m.Route(msg, sessionID)
144-
}
145-
146-
func (m *MyApplication) onNewOrderSingle(msg newordersingle.NewOrderSingle, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
147-
var clOrdID field.ClOrdIDField
148-
if clOrdID, err = msg.GetClOrdID(); err!=nil {
149-
return
150-
}
151-
152-
//compile time error!! field not defined in FIX41
153-
var clearingAccount field.ClearingAccountField
154-
clearingAccount, err = msg.GetClearingAccount()
155-
156-
...
157-
return
158-
}
159-
160-
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.
161-
162-
func (m *MyApplication) FromApp(msg quickfix.Message, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
163-
var price field.PriceField
164-
if err = msg.Body.Get(&field); err!=nil {
165-
return
166-
}
167-
168-
...
169-
return
170-
}
171-
172-
173-
Or you can go the least type safe route.
174-
175-
func (m *MyApplication) FromApp(msg quickfix.Message, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
176-
var field quickfix.FIXString
177-
if err = msg.Body.GetField(quickfix.Tag(44), &field); err!=nil {
178-
return
179-
}
180-
181-
...
182-
return
183-
}
184-
185-
Sending Messages
186-
187-
Messages can be sent to the counter party with the Send and SendToTarget functions.
188-
189-
//Send determines the session to send Messagable using header fields BeginString, TargetCompID, SenderCompID
190-
func Send(m Messagable) error
191-
192-
//SendToTarget sends Messagable based on the sessionID. Convenient for use in FromApp since it provides a session ID for incoming messages
193-
func SendToTarget(m Messagable, sessionID SessionID) error
194-
4+
User manual and additional information available at http://quickfixgo.org
1955
*/
1966
package quickfix

0 commit comments

Comments
 (0)