Documentation
¶
Overview ¶
Package lab runs the whole thing inside one process: the exchange on a loopback port, a few liquidity bots that are ordinary FIX sessions, and one initiator session per visitor, each behind its own tap.
pigfox.com's /demos/fix-lab imports this package. The host exposes no extra TCP port, so every FIX connection here is loopback; the browser never speaks FIX and reaches its session only through the host's own WebSocket.
Index ¶
Constants ¶
const BotLevels = 2
BotLevels is how many price levels each bot quotes a side.
const BotQty = 100
BotQty is each bot order's size.
Variables ¶
var ErrLogon = errors.New("the session did not log on")
ErrLogon is a visitor session that did not log on in time.
Functions ¶
Types ¶
type Book ¶
type Book struct {
Symbol string `json:"symbol"`
Name string `json:"name"`
Bids []book.Level `json:"bids"`
Asks []book.Level `json:"asks"`
}
Book is one instrument's depth.
type Config ¶
type Config struct {
// HeartBtInt is every session's heartbeat interval, in seconds. Short
// enough that "go silent" ends a session while the reader watches.
HeartBtInt int
// Bots is how many liquidity bots to run; 0 runs none.
Bots int
// Addr is the exchange's listen address; "" is 127.0.0.1 on a free port.
Addr string
// Open lets any SenderCompID log on. Off, only sessions the lab started
// itself can, which is how a host that runs visitors uses it.
Open bool
}
Config is how a lab starts.
type Lab ¶
type Lab struct {
// contains filtered or unexported fields
}
Lab is a running exchange with its bots.
func (*Lab) NewVisitor ¶
func (l *Lab) NewVisitor(ctx context.Context, compID string, onFrame func(wire.Frame), onEvent func(client.Event)) (*Visitor, error)
NewVisitor starts a session for compID through a fresh tap and waits for its logon. onFrame hears every message on the wire, onEvent every engine event; both run on engine or tap goroutines and must not block.
type Seq ¶
type Seq struct {
ClientNextOut int `json:"client_next_out"`
ClientNextIn int `json:"client_next_in"`
ExchangeNextOut int `json:"exchange_next_out"`
ExchangeNextIn int `json:"exchange_next_in"`
}
Seq is both ends' sequence numbers for the visitor's session.
type Visitor ¶
type Visitor struct {
CompID string
Session *client.Session
Tap *wire.Tap
// contains filtered or unexported fields
}
Visitor is one visitor's initiator session and the tap in front of it.