Skip to content

Commit 5060a0a

Browse files
authored
Merge pull request #7 from cbusbey/makefile
adds makefile for easy compilation, more readme
2 parents c2b814b + ef59f60 commit 5060a0a

File tree

11 files changed

+33
-64
lines changed

11 files changed

+33
-64
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
*.swp
22
tmp
3-
tradeclient
4-
executor

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ matrix:
1111

1212
install:
1313

14-
script: go build ./cmd/...
14+
script: make

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
all:
2+
go install ./cmd/...

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ To build and run the examples, you will first need [Go](http://www.golang.org) i
1616

1717
For local dev first make sure Go is properly installed, including setting up a [GOPATH](http://golang.org/doc/code.html#GOPATH).
1818

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 `go build ./cmd/...`. This will compile the example code. If this exits with exit status 0, then everything is working!
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!
20+
21+
```sh
22+
$ make
23+
```
2024

2125
Licensing
2226
---------

cmd/executor/executor.go

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"flag"
55
"fmt"
6+
"path"
67

78
"github.com/quickfixgo/quickfix"
89
"github.com/quickfixgo/quickfix/enum"
@@ -428,49 +429,10 @@ func (e *executor) OnFIX50NewOrderSingle(msg fix50nos.NewOrderSingle, sessionID
428429
return
429430
}
430431

431-
/*
432-
func (e *executor) OnFIX50NewOrderSingle(msg fix50nos.NewOrderSingle, sessionID quickfix.SessionID) (err quickfix.MessageRejectError) {
433-
if msg.OrdType != enum.OrdType_LIMIT {
434-
err = quickfix.ValueIsIncorrect(tag.OrdType)
435-
return
436-
}
437-
438-
if msg.Price == nil {
439-
err = quickfix.ConditionallyRequiredFieldMissing(tag.Price)
440-
return
441-
}
442-
443-
if msg.OrderQtyData.OrderQty == nil {
444-
err = quickfix.ConditionallyRequiredFieldMissing(tag.OrderQty)
445-
return
446-
}
447-
448-
execReport := fix50er.ExecutionReport{
449-
ClOrdID: &msg.ClOrdID,
450-
Instrument: msg.Instrument,
451-
Account: msg.Account,
452-
OrderID: e.genOrderID(),
453-
ExecID: strconv.Itoa(e.genExecID()),
454-
ExecType: enum.ExecType_FILL,
455-
OrdStatus: enum.OrdStatus_FILLED,
456-
Side: msg.Side,
457-
OrderQtyData: msg.OrderQtyData,
458-
LastQty: msg.OrderQtyData.OrderQty,
459-
LeavesQty: 0,
460-
CumQty: *msg.OrderQtyData.OrderQty,
461-
LastPx: msg.Price,
462-
AvgPx: msg.Price,
463-
}
464-
465-
quickfix.SendToTarget(execReport, sessionID)
466-
467-
return
468-
}*/
469-
470432
func main() {
471433
flag.Parse()
472434

473-
cfgFileName := "executor.cfg"
435+
cfgFileName := path.Join("config", "executor.cfg")
474436
if flag.NArg() > 0 {
475437
cfgFileName = flag.Arg(0)
476438
}

cmd/ordermatch/market.go renamed to cmd/ordermatch/internal/market.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package main
1+
package internal
22

33
import (
44
"fmt"
5-
"github.com/quickfixgo/quickfix/enum"
65
"sort"
76
"time"
7+
8+
"github.com/quickfixgo/quickfix/enum"
89
)
910

1011
type orderList struct {

cmd/ordermatch/order.go renamed to cmd/ordermatch/internal/order.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package internal
22

33
import (
44
"time"

cmd/ordermatch/ordermatcher.go renamed to cmd/ordermatch/internal/ordermatcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package internal
22

33
import "fmt"
44

cmd/ordermatch/ordermatch.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import (
66
"fmt"
77
"os"
88
"os/signal"
9+
"path"
910
"strconv"
1011

12+
"github.com/quickfixgo/examples/cmd/ordermatch/internal"
1113
"github.com/quickfixgo/quickfix"
1214
"github.com/quickfixgo/quickfix/enum"
1315
"github.com/quickfixgo/quickfix/field"
@@ -20,14 +22,14 @@ import (
2022
//Application implements the quickfix.Application interface
2123
type Application struct {
2224
*quickfix.MessageRouter
23-
*OrderMatcher
25+
*internal.OrderMatcher
2426
execID int
2527
}
2628

2729
func newApplication() *Application {
2830
app := &Application{
2931
MessageRouter: quickfix.NewMessageRouter(),
30-
OrderMatcher: NewOrderMatcher(),
32+
OrderMatcher: internal.NewOrderMatcher(),
3133
}
3234
app.AddRoute(newordersingle.Route(app.onNewOrderSingle))
3335
app.AddRoute(ordercancelrequest.Route(app.onOrderCancelRequest))
@@ -104,7 +106,7 @@ func (a *Application) onNewOrderSingle(msg newordersingle.NewOrderSingle, sessio
104106
return err
105107
}
106108

107-
order := Order{
109+
order := internal.Order{
108110
ClOrdID: clOrdID.String(),
109111
Symbol: symbol.String(),
110112
SenderCompID: senderCompID.String(),
@@ -157,19 +159,19 @@ func (a *Application) onMarketDataRequest(msg marketdatarequest.MarketDataReques
157159
return
158160
}
159161

160-
func (a *Application) acceptOrder(order Order) {
162+
func (a *Application) acceptOrder(order internal.Order) {
161163
a.updateOrder(order, enum.OrdStatus_NEW)
162164
}
163165

164-
func (a *Application) fillOrder(order Order) {
166+
func (a *Application) fillOrder(order internal.Order) {
165167
status := enum.OrdStatus_FILLED
166168
if !order.IsClosed() {
167169
status = enum.OrdStatus_PARTIALLY_FILLED
168170
}
169171
a.updateOrder(order, status)
170172
}
171173

172-
func (a *Application) cancelOrder(order Order) {
174+
func (a *Application) cancelOrder(order internal.Order) {
173175
a.updateOrder(order, enum.OrdStatus_CANCELED)
174176
}
175177

@@ -178,7 +180,7 @@ func (a *Application) genExecID() string {
178180
return strconv.Itoa(a.execID)
179181
}
180182

181-
func (a *Application) updateOrder(order Order, status string) {
183+
func (a *Application) updateOrder(order internal.Order, status string) {
182184
execReport := executionreport.New(
183185
field.NewOrderID(order.ClOrdID),
184186
field.NewExecID(a.genExecID()),
@@ -203,7 +205,7 @@ func (a *Application) updateOrder(order Order, status string) {
203205
func main() {
204206
flag.Parse()
205207

206-
cfgFileName := "ordermatch.cfg"
208+
cfgFileName := path.Join("config", "ordermatch.cfg")
207209
if flag.NArg() > 0 {
208210
cfgFileName = flag.Arg(0)
209211
}

cmd/tradeclient/internal/console.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ func QueryEnterOrder() (err error) {
531531
return quickfix.Send(order)
532532
}
533533

534-
func queryCancelOrder() (err error) {
534+
func QueryCancelOrder() (err error) {
535535
defer func() {
536536
if e := recover(); e != nil {
537537
err = e.(error)
@@ -572,7 +572,7 @@ func queryCancelOrder() (err error) {
572572
return
573573
}
574574

575-
func queryMarketDataRequest() error {
575+
func QueryMarketDataRequest() error {
576576
beginString, err := queryVersion()
577577
if err != nil {
578578
return err

0 commit comments

Comments
 (0)