|
| 1 | +/* |
| 2 | +Package quickfix is a full featured messaging engine for the FIX protocol. It is a 100% Go open source implementaiton of the popular C++ QuickFIX engine (http://quickfixengine.org). |
| 3 | +
|
| 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 class, 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 functions provide for you. |
| 9 | +
|
| 10 | + OnCreate(sessionID SessionID) |
| 11 | +
|
| 12 | +This method 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 | +This callback 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 | +This callback 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 | +This callback 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 adminstrative message before it is sent out. |
| 25 | +
|
| 26 | + ToApp(message Message, sessionID SessionID) error |
| 27 | +
|
| 28 | +This is a callback for 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 | +This callback notifies you when an administrative message is sent from a counterparty to your FIX engine. This can be usefull for doing extra validation on logon messages such as for checking passwords. |
| 33 | +
|
| 34 | + FromApp(msg Message, sessionID SessionID) MessageRejectError |
| 35 | +
|
| 36 | +This 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 class 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 | +package quickfix |
0 commit comments