Documentation
¶
Overview ¶
Package exchange is the acceptor side: a QuickFIX/Go acceptor whose application is a matching engine with one order book per instrument.
It takes NewOrderSingle (D) and OrderCancelRequest (F) and answers with ExecutionReport (8) and OrderCancelReject (9). Every fill is reported to BOTH sides, each on its own session, and the two reports carry the same match ID in SecondaryExecID (527) so a reader can pair them. Any other application message is refused by the engine with a BusinessMessageReject.
THE INSTRUMENTS ARE FICTIONAL. Their symbols end in ".LAB", their names say so, and their reference prices are made up; nothing here reads or resembles a market.
When a session ends for any reason, its resting orders are canceled: there is no session to report a later fill to.
Index ¶
- Constants
- Variables
- func SessionID(clientCompID string) quickfix.SessionID
- func Symbols() []string
- type Config
- type Event
- type Exchange
- func (x *Exchange) Addr() *net.TCPAddr
- func (x *Exchange) Depth(symbol string, n int) (bids, asks []book.Level, ok bool)
- func (x *Exchange) FromAdmin(*quickfix.Message, quickfix.SessionID) quickfix.MessageRejectError
- func (x *Exchange) FromApp(msg *quickfix.Message, id quickfix.SessionID) quickfix.MessageRejectError
- func (x *Exchange) Observe(fn func(Event))
- func (x *Exchange) OnCreate(quickfix.SessionID)
- func (x *Exchange) OnLogon(quickfix.SessionID)
- func (x *Exchange) OnLogout(id quickfix.SessionID)
- func (x *Exchange) Seq(clientCompID string) (nextOut, nextIn int, ok bool)
- func (x *Exchange) Stats() Stats
- func (x *Exchange) Stop()
- func (x *Exchange) ToAdmin(*quickfix.Message, quickfix.SessionID)
- func (x *Exchange) ToApp(*quickfix.Message, quickfix.SessionID) error
- type Instrument
- type Stats
Constants ¶
const ( BandPercent = 20 MaxOrderQty = 1000 )
Limits the exchange enforces on every order.
const CompID = "PFXLAB"
CompID is the exchange's SenderCompID.
Variables ¶
var Instruments = []Instrument{
{Symbol: "ACORN.LAB", Name: "Acorn (fictional)", Ref: 10000},
{Symbol: "BIRCH.LAB", Name: "Birch (fictional)", Ref: 2500},
}
Instruments are the two books.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Addr is the listen address; "" means 127.0.0.1 on a free port.
Addr string
// HeartBtInt is the heartbeat interval in seconds the exchange asks for;
// the initiator's Logon sets the session's actual value.
HeartBtInt int
// Allow, if set, decides which SenderCompIDs may log on.
Allow func(compID string) bool
// Log is the engine's log; nil is no log.
Log quickfix.LogFactory
}
Config is how an exchange starts.
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
Exchange is a running acceptor.
func (*Exchange) Observe ¶
Observe registers fn for every book change and trade. It is called outside the exchange's lock, possibly from several goroutines.
type Instrument ¶
type Instrument struct {
Symbol string `json:"symbol"`
Name string `json:"name"`
// Ref is the made-up reference price in ticks; orders must be within
// BandPercent of it.
Ref int64 `json:"ref"`
}
Instrument is one fictional instrument.