Documentation
¶
Overview ¶
Package client is the initiator side: one QuickFIX/Go initiator session that logs on to the exchange, sends NewOrderSingle and OrderCancelRequest, and keeps its own view of its orders from the ExecutionReports it receives.
Every session-level behavior — logon, heartbeats, TestRequest, sequence numbers, ResendRequest and the resend or gap fill that answers it, logout — is the engine's. This package only starts it, sends application messages through it, and listens.
Index ¶
- Variables
- type CancelReject
- type Config
- type Event
- type Exec
- type Order
- type Session
- func (s *Session) Cancel(origClOrdID string) (string, error)
- func (s *Session) FromAdmin(*quickfix.Message, quickfix.SessionID) quickfix.MessageRejectError
- func (s *Session) FromApp(msg *quickfix.Message, _ quickfix.SessionID) quickfix.MessageRejectError
- func (s *Session) ID() quickfix.SessionID
- func (s *Session) LoggedOn() bool
- func (s *Session) NewOrder(symbol, side, price string, qty int64) (string, error)
- func (s *Session) OnCreate(quickfix.SessionID)
- func (s *Session) OnLogon(quickfix.SessionID)
- func (s *Session) OnLogout(quickfix.SessionID)
- func (s *Session) Orders() []Order
- func (s *Session) Seq() (nextOut, nextIn int, ok bool)
- func (s *Session) Start() error
- func (s *Session) Stop()
- func (s *Session) ToAdmin(*quickfix.Message, quickfix.SessionID)
- func (s *Session) ToApp(*quickfix.Message, quickfix.SessionID) error
- func (s *Session) WaitLogon(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotLoggedOn = errors.New("the session is not logged on")
ErrNotLoggedOn is a send attempted outside a logged-on session.
Functions ¶
This section is empty.
Types ¶
type CancelReject ¶
type CancelReject struct {
ClOrdID string `json:"cl_ord_id"`
OrigClOrdID string `json:"orig_cl_ord_id"`
Reason string `json:"reason"`
Text string `json:"text"`
}
CancelReject is an OrderCancelReject as the client read it.
type Config ¶
type Config struct {
SenderCompID string
// Addr is the exchange's (or a tap's) host:port.
Addr string
// HeartBtInt is the heartbeat interval in seconds sent in the Logon.
HeartBtInt int
// ReconnectInterval is how long the engine waits before dialing again
// after a disconnect. The lab stops a session that disconnects, so this
// only matters to a long-running client.
ReconnectInterval time.Duration
// Log is the engine's log; nil is no log.
Log quickfix.LogFactory
}
Config is one session's settings.
type Event ¶
type Event struct {
Logon bool
Logout bool
Exec *Exec
CancelReject *CancelReject
// At is when the engine handed the client the event.
At time.Time
}
Event is what a session's handler hears. Exactly one field is set, except Logon/Logout which are flags.
type Exec ¶
type Exec struct {
OrderID string `json:"order_id"`
ClOrdID string `json:"cl_ord_id"`
OrigClOrdID string `json:"orig_cl_ord_id,omitempty"`
ExecID string `json:"exec_id"`
ExecType string `json:"exec_type"`
OrdStatus string `json:"ord_status"`
Symbol string `json:"symbol"`
Side string `json:"side"`
OrderQty string `json:"order_qty"`
Price string `json:"price"`
LeavesQty string `json:"leaves_qty"`
CumQty string `json:"cum_qty"`
AvgPx string `json:"avg_px"`
LastQty string `json:"last_qty,omitempty"`
LastPx string `json:"last_px,omitempty"`
MatchID string `json:"match_id,omitempty"`
Text string `json:"text,omitempty"`
}
Exec is an ExecutionReport as the client read it.
type Order ¶
type Order struct {
ClOrdID string `json:"cl_ord_id"`
OrderID string `json:"order_id"`
Symbol string `json:"symbol"`
Side string `json:"side"`
Price string `json:"price"`
Qty string `json:"qty"`
Leaves string `json:"leaves"`
Cum string `json:"cum"`
AvgPx string `json:"avg_px"`
Status string `json:"status"`
Text string `json:"text,omitempty"`
// contains filtered or unexported fields
}
Order is the client's view of one of its orders, built only from what the exchange reported.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is one initiator session.
func New ¶
New prepares a session; Start connects and logs on. handler is called from the engine's session goroutine for every event, so it must not block long and must not call Stop.
func (*Session) Cancel ¶
Cancel sends an OrderCancelRequest for the order with origClOrdID and returns the request's own ClOrdID.
func (*Session) Seq ¶
Seq returns the engine's next outbound and next expected inbound sequence numbers for this session.