Skip to content

Commit 34c582c

Browse files
committed
Updates examples repo.
1 parent 63f3d0f commit 34c582c

File tree

13 files changed

+208
-101
lines changed

13 files changed

+208
-101
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- master
8+
- main
9+
pull_request:
10+
branches:
11+
- master
12+
- main
13+
jobs:
14+
golangci:
15+
name: lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: golangci-lint
20+
uses: golangci/golangci-lint-action@v2
21+
with:
22+
version: v1.41
23+
24+
build:
25+
name: build
26+
runs-on: ubuntu-latest
27+
strategy:
28+
matrix:
29+
go: [1.16, 1.15]
30+
steps:
31+
- name: Setup
32+
uses: actions/setup-go@v2
33+
with:
34+
go-version: ${{ matrix.go }}
35+
- name: Check out source
36+
uses: actions/checkout@v2
37+
- name: Build
38+
run: make build

.github/workflows/codeql-analysis.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [ main ]
9+
schedule:
10+
- cron: '42 21 * * 3'
11+
12+
jobs:
13+
analyze:
14+
name: Analyze
15+
runs-on: ubuntu-latest
16+
permissions:
17+
actions: read
18+
contents: read
19+
security-events: write
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: [ 'go' ]
25+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
26+
# Learn more:
27+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v2
32+
33+
# Initializes the CodeQL tools for scanning.
34+
- name: Initialize CodeQL
35+
uses: github/codeql-action/init@v1
36+
with:
37+
languages: ${{ matrix.language }}
38+
# If you wish to specify custom queries, you can do so here or in a config file.
39+
# By default, queries listed here will override any specified in a config file.
40+
# Prefix the list here with "+" to use these queries and those in the config file.
41+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
42+
43+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
44+
# If this step fails, then you should remove it and run the build manually (see below)
45+
- name: Autobuild
46+
uses: github/codeql-action/autobuild@v1
47+
48+
# ℹ️ Command-line programs to run using the OS shell.
49+
# 📚 https://git.io/JvXDl
50+
51+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
52+
# and modify them (or add more) to build your code if your project
53+
# uses a compiled language
54+
55+
#- run: |
56+
# make bootstrap
57+
# make release
58+
59+
- name: Perform CodeQL Analysis
60+
uses: github/codeql-action/analyze@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ tmp
33
vendor
44
bin
55
.exe
6+
dist/

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The QuickFIX Software License, Version 1.0
22

3-
Copyright (c) 2001-2010 quickfixengine.org All rights
3+
Copyright (c) 2001-present quickfixengine.org All rights
44
reserved.
55

66
Redistribution and use in source and binary forms, with or without

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SHELL := /bin/bash
33
test: lint vet build
44

55
lint:
6-
golint ./...
6+
golangci-lint run
77

88
vet:
99
go vet ./...

README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
1-
Example QuickFIX/Go Applications
2-
================================
1+
# Example QuickFIX/Go Applications
32

4-
[![Build Status](https://travis-ci.org/quickfixgo/examples.svg?branch=master)](https://travis-ci.org/quickfixgo/examples)
3+
[![Build Status](https://github.com/quickfixgo/examples/workflows/CI/badge.svg)](https://github.com/quickfixgo/examples/actions) [![GoDoc](https://godoc.org/github.com/quickfixgo/examples?status.png)](https://godoc.org/github.com/quickfixgo/examples) [![Go Report Card](https://goreportcard.com/badge/github.com/quickfixgo/examples)](https://goreportcard.com/report/github.com/quickfixgo/examples)
54

65
* TradeClient is a simple console based trading client
76
* Executor is a server that fills every limit order it receives
87
* OrderMatch is a primitive matching engine
98

109
All examples have been ported from [QuickFIX](http://quickfixengine.org)
1110

12-
Installation
13-
------------
11+
## Installation
1412

15-
To build and run the examples, you will first need [Go](http://www.golang.org) installed on your machine (version 1.6+ is *required*).
13+
### Build From Source
14+
To build and run the examples, you will first need [Go](https://www.golang.org) installed on your machine
1615

17-
For local dev first make sure Go is properly installed, including setting up a [GOPATH](http://golang.org/doc/code.html#GOPATH).
18-
19-
Next, using [Git](https://git-scm.com/), clone this repository into `$GOPATH/src/github.com/quickfixgo/examples`. All the necessary dependencies are either vendored, so you just need to type `make`. This will compile and install the examples into `$GOPATH/bin`. If this exits with exit status 0, then everything is working!
16+
Next, clone this repository with `git clone git@github.com:quickfixgo/examples.git`. All the necessary dependencies are vendored, so you just need to type `make build`. This will compile and install the examples into the `./bin` dir in the local copy of the repo. If this exits with exit status 0, then everything is working!
2017

2118
```sh
22-
$ make
19+
make build
2320
```
2421

25-
Running the Examples
26-
--------------------
22+
### Running the Examples
2723

28-
Following installation, the examples can be found in `$GOPATH/bin`. The examples are meant to be run in pairs- the TradeClient as a client of either the Executor or OrderMatch. By default, the examples will load the default configurations named after the example apps provided in the `config/` root directory. Eg, running `$GOPATH/bin/tradeclient` will load the `config/tradeclient.cfg` configuration. Each example can be run with a custom configuration as a command line argument (`$GOPATH/bin/tradeclient my_trade_client.cfg`).
24+
Following installation, the examples can be found in `./bin`. The examples are meant to be run in pairs- the TradeClient as a client of either the Executor or OrderMatch. By default, the examples will load the default configurations named after the example apps provided in the `config/` root directory. <i>i.e.</i>, running `./bin/tradeclient` will load the `config/tradeclient.cfg` configuration. Each example can be run with a custom configuration as a command line argument (`./bin/tradeclient my_trade_client.cfg`).
2925

30-
Licensing
31-
---------
26+
### Licensing
3227

33-
This software is available under the QuickFIX Software License. Please see the [LICENSE.txt](https://github.com/quickfixgo/examples/blob/master/LICENSE.txt) for the terms specified by the QuickFIX Software License.
28+
This software is available under the QuickFIX Software License. Please see the [LICENSE.txt](https://github.com/quickfixgo/examples/blob/main/LICENSE.txt) for the terms specified by the QuickFIX Software License.

cmd/executor/main.go

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"flag"
55
"fmt"
66
"path"
7+
"syscall"
78

89
"github.com/quickfixgo/enum"
910
"github.com/quickfixgo/field"
@@ -59,10 +60,10 @@ func (e *executor) genExecID() field.ExecIDField {
5960
}
6061

6162
//quickfix.Application interface
62-
func (e executor) OnCreate(sessionID quickfix.SessionID) { return }
63-
func (e executor) OnLogon(sessionID quickfix.SessionID) { return }
64-
func (e executor) OnLogout(sessionID quickfix.SessionID) { return }
65-
func (e executor) ToAdmin(msg *quickfix.Message, sessionID quickfix.SessionID) { return }
63+
func (e executor) OnCreate(sessionID quickfix.SessionID) {}
64+
func (e executor) OnLogon(sessionID quickfix.SessionID) {}
65+
func (e executor) OnLogout(sessionID quickfix.SessionID) {}
66+
func (e executor) ToAdmin(msg *quickfix.Message, sessionID quickfix.SessionID) {}
6667
func (e executor) ToApp(msg *quickfix.Message, sessionID quickfix.SessionID) error { return nil }
6768
func (e executor) FromAdmin(msg *quickfix.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError {
6869
return nil
@@ -123,7 +124,10 @@ func (e *executor) OnFIX40NewOrderSingle(msg fix40nos.NewOrderSingle, sessionID
123124
}
124125
execReport.SetClOrdID(clOrdID)
125126

126-
quickfix.SendToTarget(execReport, sessionID)
127+
sendErr := quickfix.SendToTarget(execReport, sessionID)
128+
if sendErr != nil {
129+
fmt.Println(sendErr)
130+
}
127131

128132
return nil
129133
}
@@ -179,8 +183,10 @@ func (e *executor) OnFIX41NewOrderSingle(msg fix41nos.NewOrderSingle, sessionID
179183
}
180184
execReport.SetClOrdID(clOrdID)
181185

182-
quickfix.SendToTarget(execReport, sessionID)
183-
186+
sendErr := quickfix.SendToTarget(execReport, sessionID)
187+
if sendErr != nil {
188+
fmt.Println(sendErr)
189+
}
184190
return
185191
}
186192

@@ -245,7 +251,10 @@ func (e *executor) OnFIX42NewOrderSingle(msg fix42nos.NewOrderSingle, sessionID
245251
execReport.SetAccount(acct)
246252
}
247253

248-
quickfix.SendToTarget(execReport, sessionID)
254+
sendErr := quickfix.SendToTarget(execReport, sessionID)
255+
if sendErr != nil {
256+
fmt.Println(sendErr)
257+
}
249258

250259
return
251260
}
@@ -309,7 +318,10 @@ func (e *executor) OnFIX43NewOrderSingle(msg fix43nos.NewOrderSingle, sessionID
309318
execReport.SetAccount(acct)
310319
}
311320

312-
quickfix.SendToTarget(execReport, sessionID)
321+
sendErr := quickfix.SendToTarget(execReport, sessionID)
322+
if sendErr != nil {
323+
fmt.Println(sendErr)
324+
}
313325

314326
return
315327
}
@@ -374,7 +386,10 @@ func (e *executor) OnFIX44NewOrderSingle(msg fix44nos.NewOrderSingle, sessionID
374386
execReport.SetAccount(acct)
375387
}
376388

377-
quickfix.SendToTarget(execReport, sessionID)
389+
sendErr := quickfix.SendToTarget(execReport, sessionID)
390+
if sendErr != nil {
391+
fmt.Println(sendErr)
392+
}
378393

379394
return
380395
}
@@ -439,7 +454,10 @@ func (e *executor) OnFIX50NewOrderSingle(msg fix50nos.NewOrderSingle, sessionID
439454
execReport.SetAccount(acct)
440455
}
441456

442-
quickfix.SendToTarget(execReport, sessionID)
457+
sendErr := quickfix.SendToTarget(execReport, sessionID)
458+
if sendErr != nil {
459+
fmt.Println(sendErr)
460+
}
443461

444462
return
445463
}
@@ -479,8 +497,8 @@ func main() {
479497
return
480498
}
481499

482-
interrupt := make(chan os.Signal)
483-
signal.Notify(interrupt, os.Interrupt, os.Kill)
500+
interrupt := make(chan os.Signal, 1)
501+
signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM)
484502
<-interrupt
485503

486504
acceptor.Stop()

cmd/ordermatch/main.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os/signal"
99
"path"
1010
"strconv"
11+
"syscall"
1112

1213
"github.com/quickfixgo/enum"
1314
"github.com/quickfixgo/examples/cmd/ordermatch/internal"
@@ -39,16 +40,16 @@ func newApplication() *Application {
3940
}
4041

4142
//OnCreate implemented as part of Application interface
42-
func (a Application) OnCreate(sessionID quickfix.SessionID) { return }
43+
func (a Application) OnCreate(sessionID quickfix.SessionID) {}
4344

4445
//OnLogon implemented as part of Application interface
45-
func (a Application) OnLogon(sessionID quickfix.SessionID) { return }
46+
func (a Application) OnLogon(sessionID quickfix.SessionID) {}
4647

4748
//OnLogout implemented as part of Application interface
48-
func (a Application) OnLogout(sessionID quickfix.SessionID) { return }
49+
func (a Application) OnLogout(sessionID quickfix.SessionID) {}
4950

5051
//ToAdmin implemented as part of Application interface
51-
func (a Application) ToAdmin(msg *quickfix.Message, sessionID quickfix.SessionID) { return }
52+
func (a Application) ToAdmin(msg *quickfix.Message, sessionID quickfix.SessionID) {}
5253

5354
//ToApp implemented as part of Application interface
5455
func (a Application) ToApp(msg *quickfix.Message, sessionID quickfix.SessionID) error {
@@ -205,7 +206,11 @@ func (a *Application) updateOrder(order internal.Order, status enum.OrdStatus) {
205206
execReport.Header.SetTargetCompID(order.SenderCompID)
206207
execReport.Header.SetSenderCompID(order.TargetCompID)
207208

208-
quickfix.Send(execReport)
209+
sendErr := quickfix.Send(execReport)
210+
if sendErr != nil {
211+
fmt.Println(sendErr)
212+
}
213+
209214
}
210215

211216
func main() {
@@ -243,8 +248,8 @@ func main() {
243248
return
244249
}
245250

246-
interrupt := make(chan os.Signal)
247-
signal.Notify(interrupt, os.Interrupt, os.Kill)
251+
interrupt := make(chan os.Signal, 1)
252+
signal.Notify(interrupt, os.Interrupt, syscall.SIGTERM)
248253
go func() {
249254
<-interrupt
250255
acceptor.Stop()

0 commit comments

Comments
 (0)