Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chenjunpc2008/go-fix
The Financial Information Exchange (FIX) Protocol Engine
https://github.com/chenjunpc2008/go-fix
finance financial-information-exchange fintech fixprotocol go golang messaging-library protocol quickfix stock-market stocks trading trading-systems
Last synced: 6 days ago
JSON representation
The Financial Information Exchange (FIX) Protocol Engine
- Host: GitHub
- URL: https://github.com/chenjunpc2008/go-fix
- Owner: chenjunpc2008
- License: mit
- Created: 2023-10-07T08:24:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-08T07:56:03.000Z (over 1 year ago)
- Last Synced: 2024-06-21T04:51:21.804Z (8 months ago)
- Topics: finance, financial-information-exchange, fintech, fixprotocol, go, golang, messaging-library, protocol, quickfix, stock-market, stocks, trading, trading-systems
- Language: Go
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-fix
The Financial Information Exchange (FIX) Protocol Engine## fixacceptor
Go FIX server## fixinitiator
Go FIX client# Usage
## fixacceptor
---
for example: ```example/demoServer```1. Create a struct for server event call back, and put your own message process in the callback functions.
```go
type myApp struct {
}var _ fixacceptor.ApplicationIF = (*myApp)(nil)
func (a *myApp) OnError(msg string, err error) {
fmt.Printf(msg, err)
}func (a *myApp) OnErrorStr(msg string) {
fmt.Printf(msg)
}func (app *myApp) OnEvent(msg string) {
fmt.Println(msg)
}func (app *myApp) FromAdmin(fixMsg *quickfix.Message) {
fmt.Println("FromAdmin:", fixMsg)
}func (app *myApp) FromApp(fixMsg *quickfix.Message) {
fmt.Println("FromApp:", fixMsg)
}func (app *myApp) OnSendedData(fixMsg *quickfix.Message) {
fmt.Println("OnSent:", fixMsg)
}func (app *myApp) OnDisconnected(serverIP string, serverPort uint16) {
fmt.Printf("OnDisconnected:%s:%d/n", serverIP, serverPort)
}
```
2. Use the server and go
```go
var setting = fixacceptor.DefaultConfig()
setting.Port = 5001
setting.SenderCompID = "NASDAQ"
setting.FixDataDictPath = "./spec/FIX42.xml"app := new(myApp)
acceptor := fixacceptor.NewAcceptor(setting, app)
acceptor.Start()
```## fixinitiator
---
for example: ```example/fixTradeClient```1. Create a struct for server event call back, and put your own message process in the callback functions.
```go
type tradeCliApp struct {
}var _ fixinitiator.ApplicationIF = (*tradeCliApp)(nil)
func (app *tradeCliApp) OnConnected(serverIP string, serverPort uint16) {
}
func (app *tradeCliApp) OnError(msg string, err error) {
fmt.Println(msg, err)
}func (app *tradeCliApp) OnErrorStr(msg string) {
fmt.Println(msg)
}func (app *tradeCliApp) OnEvent(msg string) {
fmt.Println(msg)
}func (app *tradeCliApp) OnAdminMsg(fixmsg *quickfix.Message) {
fmt.Println(fixmsg)
}func (app *tradeCliApp) OnAppMsg(fixmsg *quickfix.Message) {
atomic.AddInt64(&GRspRcvNum, 1)
fmt.Println(fixmsg)
}func (app *tradeCliApp) OnDisconnected(serverIP string, serverPort uint16) {
}
func (app *tradeCliApp) OnSendedData(msg *fixinitiator.MsgPkg) {}
```
2. Use the client and go
```go
var setting = fixinitiator.DefaultConfig()
setting.FixDataDictPath = "./spec/FIX42.xml"
setting.RemoteIP = "127.0.0.1"
setting.RemotePort = 5001setting.BeginString = "FIX.4.2"
setting.SenderCompID = "qaib84"
setting.TargetCompID = "IB"app := new(tradeCliApp)
gFixCli = fixinitiator.NewInitiator(setting, app)
var (
senderStartSeqNum uint64 = 1
targetStartSeqNum uint64 = 1
)
gFixCli.Start(senderStartSeqNum, targetStartSeqNum)
```
3. Send a new trade order
```go
fixOrder = buildIBNewOrderSingle()
mpkg.Fixmsg = fixOrder
gFixCli.SendMsgToSvr(mpkg)
```