quickfix

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2023 License: Apache-1.1 Imports: 32 Imported by: 0

README ¶

QuickFIX/Go

Open Source FIX Protocol library implemented in Go

Getting Started and Documentation

Installation

To install QuickFIX/Go, use go get:

$ go get github.com/alpacahq/quickfix
Staying up to date

To update QuickFIX/Go to the latest version, use go get -u github.com/alpacahq/quickfix.

Example Apps

See examples for some simple examples of using QuickFIX/Go.

FIX Message Generation

QuickFIX/Go includes separate packages for tags, fields, enums, messages, and message components generated from the FIX 4.0 - FIX5.0SP2 specs. See:

For most FIX applications, these generated resources are sufficient. Custom FIX applications may generate source specific to the FIX spec of that application using the generate-fix tool included with QuickFIX/Go.

Following installation, generate-fix is installed to $GOPATH/bin/generate-fix. Run $GOPATH/bin/generate-fix --help for usage instructions.

Developing QuickFIX/Go

If you wish to work on QuickFIX/Go itself, you will first need Go installed on your machine (version 1.6+ is required).

For local dev first make sure Go is properly installed, including setting up a GOPATH.

Next, using Git, clone this repository into $GOPATH/src/github.com/alpacahq/quickfix.

Installing Dependencies

QuickFIX/Go uses dep to manage the vendored dependencies. Install dep with go get:

$ go get -u github.com/golang/dep/cmd/dep

Run dep ensure to install the correct versioned dependencies into vendor/, which Go 1.6+ automatically recognizes and loads.

$ $GOPATH/bin/dep ensure

Note: No vendored dependencies are included in the QuickFIX/Go source.

Build and Test

The default make target runs go vet and unit tests.

$ make

If this exits with exit status 0, then everything is working!

Generated Code

Generated code from the FIX40-FIX50SP2 specs are available as separate repos under the QuickFIX/Go organization. The source specifications for this generated code is located in spec/. Generated code can be identified by the .generated.go suffix. Any changes to generated code must be captured by changes to source in cmd/generate-fix. After making changes to the code generator source, run the following to re-generate the source

$ make generate-dist

If you are making changes to the generated code, please create Pull Requests for these changes for the affected repos.

Acceptance Tests

QuickFIX/Go has a comprehensive acceptance test suite covering the FIX protocol. These are the same tests used across all QuickFIX implementations.

QuickFIX/Go acceptance tests depend on ruby in path.

To run acceptance tests,

    # generate code locally
    make generate

	# build acceptance test rig
	make build-test-srv

	# run acceptance tests
	make accept
Dependencies

If you are developing QuickFIX/Go, there are a few tasks you might need to perform related to dependencies.

Adding a dependency

If you are adding a dependency, you will need to update the dep manifest in the same Pull Request as the code that depends on it. You should do this in a separate commit from your code, as this makes PR review easier and Git history simpler to read in the future.

To add a dependency:

  1. Add the dependency using dep:
$ dep ensure -add github.com/foo/bar
  1. Review the changes in git and commit them.
Updating a dependency

To update a dependency to the latest version allowed by constraints in Gopkg.toml:

  1. Run:
$ dep ensure -update github.com/foo/bar
  1. Review the changes in git and commit them.

To change the allowed version/branch/revision of a dependency:

  1. Manually edit Gopkg.toml
  2. Run:
$ dep ensure
  1. Review the changes in git and commit them.

Licensing

This software is available under the QuickFIX Software License. Please see the LICENSE.txt for the terms specified by the QuickFIX Software License.

Documentation ¶

Overview ¶

Package quickfix is a full featured messaging engine for the FIX protocol. It is a 100% Go open source implementation of the popular C++ QuickFIX engine (http://quickfixengine.org).

User manual and additional information available at https://quickfixgo.org

Index ¶

Constants ¶

View Source
const (
	BeginStringFIX40  = "FIX.4.0"
	BeginStringFIX41  = "FIX.4.1"
	BeginStringFIX42  = "FIX.4.2"
	BeginStringFIX43  = "FIX.4.3"
	BeginStringFIX44  = "FIX.4.4"
	BeginStringFIXT11 = "FIXT.1.1"
)

FIX BeginString string values.

View Source
const (
	LogIncomingMessage string = "FIX incoming"
	LogOutgoingMessage string = "FIX outgoing"
	LogPrefixGlobal    string = "GLOBAL"
)
View Source
const (
	ApplVerIDFIX27    = "0"
	ApplVerIDFIX30    = "1"
	ApplVerIDFIX40    = "2"
	ApplVerIDFIX41    = "3"
	ApplVerIDFIX42    = "4"
	ApplVerIDFIX43    = "5"
	ApplVerIDFIX44    = "6"
	ApplVerIDFIX50    = "7"
	ApplVerIDFIX50SP1 = "8"
	ApplVerIDFIX50SP2 = "9"
)

FIX ApplVerID string values.

Variables ¶

View Source
var ErrAccessToClosedStore = errors.New("this store is already closed")

ErrAccessToClosedStore defines error on accessing to closed message store.

View Source
var ErrDoNotLoggedOnSession = errors.New(doNotLoggedOnSessionMessage)

ErrDoNotLoggedOnSession defines no loggedOn session error.

View Source
var ErrDoNotSend = errors.New("Do Not Send")

ErrDoNotSend is a convenience error to indicate a DoNotSend in ToApp.

View Source
var ErrDuplicateSessionID = errors.New("duplicate SessionID")

ErrDuplicateSessionID defines duplicate SessionID.

View Source
var ErrExistSession = errors.New("exist session")

ErrExistSession defines already exist session error.

View Source
var ErrSendToStoppedSession = errors.New("this session is stopped")

ErrSendToStoppedSession defines error on sending to stopped session.

View Source
var ErrUnknownSession = errors.New("unknown session")

ErrUnknownSession defines unknown session.

Functions ¶

func CleanupInvalidStoppedSession ¶ added in v1.0.8

func CleanupInvalidStoppedSession()

CleanupInvalidStoppedSession deletes stopped sessions that has expired. If using DynamicQualifier and DynamicStoppedSessionKeepTime, call this function periodically to close invalid sessions.

func IsAliveSession ¶ added in v1.0.1

func IsAliveSession(sessionID SessionID) bool

IsAliveSession This function checks if the session is a logged on session or not.

func ParseMessage ¶ added in v0.3.0

func ParseMessage(msg *Message, rawMessage *bytes.Buffer) (err error)

ParseMessage constructs a Message from a byte slice wrapping a FIX message.

func ParseMessageWithDataDictionary ¶ added in v0.6.0

func ParseMessageWithDataDictionary(
	msg *Message,
	rawMessage *bytes.Buffer,
	transportDataDictionary *datadictionary.DataDictionary,
	applicationDataDictionary *datadictionary.DataDictionary,
) (err error)

ParseMessageWithDataDictionary constructs a Message from a byte slice wrapping a FIX message using an optional session and application DataDictionary for reference.

func Send ¶

func Send(m Messagable) (err error)

Send determines the session to send Messagable using header fields BeginString, TargetCompID, SenderCompID.

func SendToAliveSession ¶ added in v1.0.1

func SendToAliveSession(m Messagable, sessionID SessionID) (err error)

SendToAliveSession This function send message for logged on session.

func SendToAliveSessions ¶ added in v1.0.1

func SendToAliveSessions(m Messagable) (err error)

SendToAliveSessions This function send messages for logged on sessions.

func SendToSession ¶ added in v1.0.8

func SendToSession(m Messagable, sessionID SessionID) (err error)

SendToSession This function send message on session. If the session is stopped, It just saves the message without sending it.

func SendToTarget ¶

func SendToTarget(m Messagable, sessionID SessionID) error

SendToTarget sends a message based on the sessionID. Convenient for use in FromApp since it provides a session ID for incoming messages.

func StoreMessageToSession ¶ added in v1.0.9

func StoreMessageToSession(m Messagable, sessionID SessionID) (err error)

StoreMessageToSession stores a message on session. If returns ErrExistSession, please call SendToSession because already connected session.

func UnregisterSession ¶ added in v1.0.0

func UnregisterSession(sessionID SessionID) (err error)

UnregisterSession removes a session from the set of known sessions.

func WaitForLogon ¶ added in v1.0.3

func WaitForLogon(sessionID SessionID) <-chan struct{}

WaitForLogon returns channel to receive logon event by specific session. if non-existing sessionID specified, it returns nil which blocks forever.

Types ¶

type Acceptor ¶

type Acceptor struct {
	// contains filtered or unexported fields
}

Acceptor accepts connections from FIX clients and manages the associated sessions.

func NewAcceptor ¶

func NewAcceptor(app Application, storeFactory MessageStoreFactory, settings *Settings, logFactory LogFactory) (a *Acceptor, err error)

NewAcceptor creates and initializes a new Acceptor.

func (*Acceptor) GetAliveSessionIDs ¶ added in v1.0.1

func (a *Acceptor) GetAliveSessionIDs() []SessionID

GetAliveSessionIDs This function returns loggedOn sessionID list.

func (*Acceptor) GetSessionIDs ¶ added in v1.0.1

func (a *Acceptor) GetSessionIDs() []SessionID

GetSessionIDs This function returns managed all sessionID list.

func (*Acceptor) IsAliveSession ¶ added in v1.0.1

func (a *Acceptor) IsAliveSession(sessionID SessionID) bool

IsAliveSession This function checks if the session is a logged on session or not.

func (*Acceptor) RemoteAddr ¶ added in v1.0.0

func (a *Acceptor) RemoteAddr(sessionID SessionID) (net.Addr, bool)

RemoteAddr Get remote IP address for a given session.

func (*Acceptor) SendToAliveSession ¶ added in v1.0.1

func (a *Acceptor) SendToAliveSession(m Messagable, sessionID SessionID) (err error)

SendToAliveSession This function send message for logged on session.

func (*Acceptor) SendToAliveSessions ¶ added in v1.0.1

func (a *Acceptor) SendToAliveSessions(m Messagable) (err error)

SendToAliveSessions This function send messages for logged on sessions.

func (*Acceptor) SetConnectionValidator ¶ added in v1.0.0

func (a *Acceptor) SetConnectionValidator(validator ConnectionValidator)

SetConnectionValidator sets an optional connection validator. Use it when you need a custom authentication logic that includes lower level interactions, like mTLS auth or IP whitelistening. To remove a previously set validator call it with a nil value:

a.SetConnectionValidator(nil)

func (*Acceptor) Start ¶

func (a *Acceptor) Start() (err error)

Start accepting connections.

func (*Acceptor) Stop ¶

func (a *Acceptor) Stop()

Stop logs out existing sessions, close their connections, and stop accepting new connections.

type Application ¶

type Application interface {
	// OnCreate notification of a session begin created.
	OnCreate(sessionID SessionID)

	// OnLogon notification of a session successfully logging on.
	OnLogon(sessionID SessionID)

	// OnLogout notification of a session logging off or disconnecting.
	OnLogout(sessionID SessionID)

	// ToAdmin notification of admin message being sent to target.
	ToAdmin(message *Message, sessionID SessionID)

	// ToApp notification of app message being sent to target.
	ToApp(message *Message, sessionID SessionID) error

	// FromAdmin notification of admin message being received from target.
	FromAdmin(message *Message, sessionID SessionID) MessageRejectError

	// FromApp notification of app message being received from target.
	FromApp(message *Message, sessionID SessionID) MessageRejectError
}

Application interface should be implemented by FIX Applications. This is the primary interface for processing messages from a FIX Session.

type Body ¶ added in v0.3.0

type Body struct{ FieldMap }

Body is the primary application section of a FIX message.

func (*Body) Init ¶ added in v0.3.0

func (b *Body) Init()

Init initializes the FIX message.

func (Body) Len ¶ added in v0.6.0

func (t Body) Len() int

func (Body) Less ¶ added in v0.6.0

func (t Body) Less(i, j int) bool

func (Body) Swap ¶ added in v0.6.0

func (t Body) Swap(i, j int)

type BuildMessageInput ¶ added in v1.0.9

type BuildMessageInput struct {
	Msg                          *Message
	InReplyTo                    *Message
	EnableLastMsgSeqNumProcessed bool
	IsResetSeqNum                bool
}

BuildMessageInput stores for building message data.

type BuildMessageOutput ¶ added in v1.0.9

type BuildMessageOutput struct {
	MsgBytes  []byte
	Msg       *Message
	SeqNum    int
	SentReset bool
}

BuildMessageOutput stores build message output data.

type ConditionallyRequiredSetting ¶ added in v0.5.0

type ConditionallyRequiredSetting struct {
	Setting string
}

ConditionallyRequiredSetting indicates a missing setting.

func (ConditionallyRequiredSetting) Error ¶ added in v0.5.0

type ConnectionValidator ¶ added in v1.0.0

type ConnectionValidator interface {
	// Validate the connection for validity. This can be a part of authentication process.
	// For example, you may tie up a SenderCompID to an IP range, or to a specific TLS certificate as a part of mTLS.
	Validate(netConn net.Conn, session SessionID) error
}

ConnectionValidator is an interface allowing to implement a custom authentication logic.

type ErrorBySessionID ¶ added in v1.0.1

type ErrorBySessionID struct {
	ErrorMap map[SessionID]error
	// contains filtered or unexported fields
}

ErrorBySessionID This struct has error map by sessionID.

func NewErrorBySessionID ¶ added in v1.0.1

func NewErrorBySessionID(err error) (response *ErrorBySessionID)

NewErrorBySessionID This function returns NewErrorBySessionID object.

type FIXBoolean ¶

type FIXBoolean bool

FIXBoolean is a FIX Boolean value, implements FieldValue.

func (FIXBoolean) Bool ¶ added in v0.4.0

func (f FIXBoolean) Bool() bool

Bool converts the FIXBoolean value to bool.

func (*FIXBoolean) Read ¶

func (f *FIXBoolean) Read(bytes []byte) error

func (FIXBoolean) Write ¶

func (f FIXBoolean) Write() []byte

type FIXBytes ¶ added in v0.6.0

type FIXBytes []byte

FIXBytes is a generic FIX field value, implements FieldValue. Enables zero copy read from a FieldMap.

func (*FIXBytes) Read ¶ added in v0.6.0

func (f *FIXBytes) Read(bytes []byte) (err error)

func (FIXBytes) Write ¶ added in v0.6.0

func (f FIXBytes) Write() []byte

type FIXDecimal ¶ added in v0.5.0

type FIXDecimal struct {
	decimal.Decimal

	// Scale is the number of digits after the decimal point when Writing the field value as a FIX value.
	Scale int32
}

FIXDecimal is a FIX Float Value that implements an arbitrary precision fixed-point decimal. Implements FieldValue.

func (*FIXDecimal) Read ¶ added in v0.5.0

func (d *FIXDecimal) Read(bytes []byte) (err error)

func (FIXDecimal) Write ¶ added in v0.5.0

func (d FIXDecimal) Write() []byte

type FIXFloat ¶

type FIXFloat float64

FIXFloat is a FIX Float Value, implements FieldValue.

func (FIXFloat) Float64 ¶ added in v0.4.0

func (f FIXFloat) Float64() float64

Float64 converts the FIXFloat value to float64.

func (*FIXFloat) Read ¶

func (f *FIXFloat) Read(bytes []byte) error

func (FIXFloat) Write ¶

func (f FIXFloat) Write() []byte

type FIXInt ¶

type FIXInt int

FIXInt is a FIX Int Value, implements FieldValue.

func (FIXInt) Int ¶ added in v0.4.0

func (f FIXInt) Int() int

Int converts the FIXInt value to int.

func (*FIXInt) Read ¶

func (f *FIXInt) Read(bytes []byte) error

func (FIXInt) Write ¶

func (f FIXInt) Write() []byte

type FIXString ¶

type FIXString string

FIXString is a FIX String Value, implements FieldValue.

func (*FIXString) Read ¶

func (f *FIXString) Read(bytes []byte) (err error)

func (FIXString) String ¶

func (f FIXString) String() string

func (FIXString) Write ¶

func (f FIXString) Write() []byte

type FIXUTCTimestamp ¶

type FIXUTCTimestamp struct {
	time.Time
	Precision TimestampPrecision
}

FIXUTCTimestamp is a FIX UTC Timestamp value, implements FieldValue.

func (*FIXUTCTimestamp) Read ¶

func (f *FIXUTCTimestamp) Read(bytes []byte) (err error)

func (FIXUTCTimestamp) Write ¶

func (f FIXUTCTimestamp) Write() []byte

type Field ¶

type Field interface {
	FieldWriter
	FieldValueReader
}

Field is the interface implemented by all typed Fields in a Message.

type FieldGroup ¶ added in v0.3.0

type FieldGroup interface {
	Tag() Tag
	Write() []TagValue
	Read([]TagValue) ([]TagValue, error)
}

FieldGroup is the interface implemented by all typed Groups in a Message.

type FieldGroupReader ¶ added in v0.3.0

type FieldGroupReader interface {
	Tag() Tag
	Read([]TagValue) ([]TagValue, error)
}

FieldGroupReader is an interface for reading a FieldGroup.

type FieldGroupWriter ¶ added in v0.3.0

type FieldGroupWriter interface {
	Tag() Tag
	Write() []TagValue
}

FieldGroupWriter is an interface for writing a FieldGroup.

type FieldMap ¶

type FieldMap struct {
	// contains filtered or unexported fields
}

FieldMap is a collection of fix fields that make up a fix message.

func (*FieldMap) Clear ¶

func (m *FieldMap) Clear()

Clear purges all fields from field map.

func (*FieldMap) CopyInto ¶ added in v1.0.0

func (m *FieldMap) CopyInto(to *FieldMap)

CopyInto overwrites the given FieldMap with this one.

func (*FieldMap) DeleteTag ¶ added in v1.0.14

func (m *FieldMap) DeleteTag(tag Tag)

DeleteTag removes a tag's value from field map, if present.

func (FieldMap) Get ¶

func (m FieldMap) Get(parser Field) MessageRejectError

Get parses out a field in this FieldMap. Returned reject may indicate the field is not present, or the field value is invalid.

func (FieldMap) GetBool ¶ added in v0.6.0

func (m FieldMap) GetBool(tag Tag) (bool, MessageRejectError)

GetBool is a GetField wrapper for bool fields.

func (FieldMap) GetBytes ¶ added in v0.6.0

func (m FieldMap) GetBytes(tag Tag) ([]byte, MessageRejectError)

GetBytes is a zero-copy GetField wrapper for []bytes fields.

func (FieldMap) GetField ¶

func (m FieldMap) GetField(tag Tag, parser FieldValueReader) MessageRejectError

GetField parses of a field with Tag tag. Returned reject may indicate the field is not present, or the field value is invalid.

func (FieldMap) GetGroup ¶

func (m FieldMap) GetGroup(parser FieldGroupReader) MessageRejectError

GetGroup is a Get function specific to Group Fields.

func (FieldMap) GetInt ¶ added in v0.2.0

func (m FieldMap) GetInt(tag Tag) (int, MessageRejectError)

GetInt is a GetField wrapper for int fields.

func (FieldMap) GetString ¶ added in v0.2.0

func (m FieldMap) GetString(tag Tag) (string, MessageRejectError)

GetString is a GetField wrapper for string fields.

func (FieldMap) GetTime ¶ added in v0.6.0

func (m FieldMap) GetTime(tag Tag) (t time.Time, err MessageRejectError)

GetTime is a GetField wrapper for utc timestamp fields.

func (FieldMap) Has ¶

func (m FieldMap) Has(tag Tag) bool

Has returns true if the Tag is present in this FieldMap.

func (FieldMap) Len ¶ added in v0.6.0

func (t FieldMap) Len() int

func (FieldMap) Less ¶ added in v0.6.0

func (t FieldMap) Less(i, j int) bool

func (*FieldMap) Set ¶

func (m *FieldMap) Set(field FieldWriter) *FieldMap

Set is a setter for fields.

func (*FieldMap) SetBool ¶ added in v0.6.0

func (m *FieldMap) SetBool(tag Tag, value bool) *FieldMap

SetBool is a SetField wrapper for bool fields.

func (*FieldMap) SetBytes ¶ added in v0.6.0

func (m *FieldMap) SetBytes(tag Tag, value []byte) *FieldMap

SetBytes sets bytes.

func (*FieldMap) SetField ¶

func (m *FieldMap) SetField(tag Tag, field FieldValueWriter) *FieldMap

SetField sets the field with Tag tag.

func (*FieldMap) SetGroup ¶

func (m *FieldMap) SetGroup(field FieldGroupWriter) *FieldMap

SetGroup is a setter specific to group fields.

func (*FieldMap) SetInt ¶ added in v0.5.0

func (m *FieldMap) SetInt(tag Tag, value int) *FieldMap

SetInt is a SetField wrapper for int fields.

func (*FieldMap) SetString ¶ added in v0.5.0

func (m *FieldMap) SetString(tag Tag, value string) *FieldMap

SetString is a SetField wrapper for string fields.

func (FieldMap) Swap ¶ added in v0.6.0

func (t FieldMap) Swap(i, j int)

func (FieldMap) Tags ¶

func (m FieldMap) Tags() []Tag

Tags returns all of the Field Tags in this FieldMap.

type FieldValue ¶

type FieldValue interface {
	FieldValueWriter
	FieldValueReader
}

The FieldValue interface is used to write/extract typed field values to/from raw bytes.

type FieldValueReader ¶

type FieldValueReader interface {
	// Read reads the contents of the `[]byte` into FieldValue.
	// Returns an error if there are issues in the data processing.
	Read([]byte) error
}

FieldValueReader is an interface for reading field values.

type FieldValueWriter ¶

type FieldValueWriter interface {
	// Write writes out the contents of the FieldValue to a `[]byte`.
	Write() []byte
}

FieldValueWriter is an interface for writing field values.

type FieldWriter ¶

type FieldWriter interface {
	Tag() Tag
	FieldValueWriter
}

FieldWriter is an interface for a writing a field.

type Group ¶

type Group struct{ FieldMap }

Group is a group of fields occurring in a repeating group.

func (Group) Len ¶ added in v0.6.0

func (t Group) Len() int

func (Group) Less ¶ added in v0.6.0

func (t Group) Less(i, j int) bool

func (Group) Swap ¶ added in v0.6.0

func (t Group) Swap(i, j int)

type GroupItem ¶

type GroupItem interface {
	// Tag returns the tag identifying this GroupItem.
	Tag() Tag

	// Read Parameter to Read is tagValues.  For most fields, only the first tagValue will be required.
	// The length of the slice extends from the tagValue mapped to the field to be read through the
	// following fields. This can be useful for GroupItems made up of repeating groups.
	//
	// The Read function returns the remaining tagValues not processed by the GroupItem. If there was a
	// problem reading the field, an error may be returned.
	Read([]TagValue) ([]TagValue, error)

	// Clone makes a copy of this GroupItem.
	Clone() GroupItem
}

GroupItem interface is used to construct repeating group templates.

func GroupElement ¶

func GroupElement(tag Tag) GroupItem

GroupElement returns a GroupItem made up of a single field.

type GroupTemplate ¶

type GroupTemplate []GroupItem

GroupTemplate specifies the group item order for a RepeatingGroup.

func (GroupTemplate) Clone ¶ added in v0.4.0

func (gt GroupTemplate) Clone() GroupTemplate

Clone makes a copy of this GroupTemplate.

type Header struct{ FieldMap }

Header is first section of a FIX Message.

func (*Header) Init ¶ added in v0.3.0

func (h *Header) Init()

Init initializes the Header instance.

func (Header) Len ¶ added in v0.6.0

func (t Header) Len() int

func (Header) Less ¶ added in v0.6.0

func (t Header) Less(i, j int) bool

func (Header) Swap ¶ added in v0.6.0

func (t Header) Swap(i, j int)

type IncorrectFormatForSetting ¶ added in v0.5.0

type IncorrectFormatForSetting struct {
	Setting, Value string
	Err            error
}

IncorrectFormatForSetting indicates a setting that is incorrectly formatted.

func (IncorrectFormatForSetting) Error ¶ added in v0.5.0

type Initiator ¶

type Initiator struct {
	// contains filtered or unexported fields
}

Initiator initiates connections and processes messages for all sessions.

func NewInitiator ¶

func NewInitiator(app Application, storeFactory MessageStoreFactory, appSettings *Settings, logFactory LogFactory) (*Initiator, error)

NewInitiator creates and initializes a new Initiator.

func (*Initiator) GetAliveSessionIDs ¶ added in v1.0.1

func (i *Initiator) GetAliveSessionIDs() []SessionID

GetAliveSessionIDs This function returns loggedOn sessionID list.

func (*Initiator) GetSessionIDs ¶ added in v1.0.3

func (i *Initiator) GetSessionIDs() []SessionID

GetSessionIDs This function returns sessionID list.

func (*Initiator) IsAliveSession ¶ added in v1.0.1

func (i *Initiator) IsAliveSession(sessionID SessionID) bool

IsAliveSession This function checks if the session is a logged on session or not.

func (*Initiator) SendToAliveSession ¶ added in v1.0.1

func (i *Initiator) SendToAliveSession(m Messagable, sessionID SessionID) (err error)

SendToAliveSession This function send message for logged on session.

func (*Initiator) SendToAliveSessions ¶ added in v1.0.1

func (i *Initiator) SendToAliveSessions(m Messagable) (err error)

SendToAliveSessions This function send messages for logged on sessions.

func (*Initiator) Start ¶

func (i *Initiator) Start() (err error)

Start Initiator.

func (*Initiator) Stop ¶

func (i *Initiator) Stop()

Stop Initiator.

type Log ¶

type Log interface {
	// OnIncoming log incoming fix message.
	OnIncoming([]byte)

	// OnOutgoing log outgoing fix message.
	OnOutgoing([]byte)

	// OnEvent log fix event.
	OnEvent(string)

	// OnEventf log fix event according to format specifier.
	OnEventf(string, ...interface{})

	// OnErrorEvent log fix error event
	OnErrorEvent(string, error)

	// OnEventParams log fix event according to logging parameter
	OnEventParams(string, ...LogParam)

	// OnErrorEventParams log fix error event according to logging parameter
	OnErrorEventParams(string, error, ...LogParam)
}

Log is a generic interface for logging FIX messages and events.

type LogFactory ¶

type LogFactory interface {
	// Create global log.
	Create() (Log, error)

	// CreateSessionLog session specific log.
	CreateSessionLog(sessionID SessionID) (Log, error)
}

The LogFactory interface creates global and session specific Log instances.

func NewCustomLogFactory ¶ added in v1.0.0

func NewCustomLogFactory(
	logFunc func(prefix, msg string, keysAndValues ...LogParam),
	logErrorFunc func(prefix, msg string, err error, keysAndValues ...LogParam),
) LogFactory

NewCustomLogFactory creates an instance of LogFactory that logs messages and events using the provided log function.

func NewFileLogFactory ¶

func NewFileLogFactory(settings *Settings) (LogFactory, error)

NewFileLogFactory creates an instance of LogFactory that writes messages and events to file. The location of global and session log files is configured via FileLogPath.

func NewNullLogFactory ¶

func NewNullLogFactory() LogFactory

NewNullLogFactory creates an instance of LogFactory that returns no-op loggers.

func NewScreenLogFactory ¶

func NewScreenLogFactory() LogFactory

NewScreenLogFactory creates an instance of LogFactory that writes messages and events to stdout.

type LogParam ¶ added in v1.1.0

type LogParam struct {
	Name  string
	Value interface{}
	// contains filtered or unexported fields
}

LogParam ...

func LogInt ¶ added in v1.1.0

func LogInt(name string, value int) LogParam

LogInt ...

func LogInt64 ¶ added in v1.1.0

func LogInt64(name string, value int64) LogParam

LogInt64 ...

func LogMessage ¶ added in v1.1.0

func LogMessage(name string, msgBytes []byte) LogParam

LogMessage ...

func LogObject ¶ added in v1.1.0

func LogObject(name string, value interface{}) LogParam

LogObject ...

func LogString ¶ added in v1.1.0

func LogString(name, value string) LogParam

LogString ...

func LogStringWithSingleQuote ¶ added in v1.1.0

func LogStringWithSingleQuote(name, value string) LogParam

LogStringWithSingleQuote ...

func LogUint64 ¶ added in v1.1.0

func LogUint64(name string, value uint64) LogParam

LogUint64 ...

func (LogParam) GetFormat ¶ added in v1.1.0

func (l LogParam) GetFormat() string

GetFormat ...

func (LogParam) String ¶ added in v1.1.0

func (l LogParam) String() string

String ...

type Messagable ¶ added in v0.4.0

type Messagable interface {
	ToMessage() *Message
}

Messagable is a Message or something that can be converted to a Message.

type Message ¶

type Message struct {
	Header  Header
	Trailer Trailer
	Body    Body

	// ReceiveTime is the time that this message was read from the socket connection.
	ReceiveTime time.Time
	// contains filtered or unexported fields
}

Message is a FIX Message abstraction.

func NewMessage ¶

func NewMessage() *Message

NewMessage returns a newly initialized Message instance.

func (*Message) CopyInto ¶ added in v1.0.0

func (m *Message) CopyInto(to *Message)

CopyInto erases the dest messages and copies the currency message content into it.

func (*Message) IsMsgTypeOf ¶ added in v0.6.0

func (m *Message) IsMsgTypeOf(msgType string) bool

IsMsgTypeOf returns true if the Header contains MsgType (tag 35) field and its value is the specified one.

func (*Message) MsgType ¶ added in v0.6.0

func (m *Message) MsgType() (string, MessageRejectError)

MsgType returns MsgType (tag 35) field's value.

func (*Message) String ¶

func (m *Message) String() string

func (*Message) ToMessage ¶ added in v0.4.0

func (m *Message) ToMessage() *Message

ToMessage returns the message itself.

type MessageRejectError ¶

type MessageRejectError interface {
	error

	// RejectReason, tag 373 for session rejects, tag 380 for business rejects.
	RejectReason() int
	BusinessRejectRefID() string
	RefTagID() *Tag
	IsBusinessReject() bool
}

MessageRejectError is a type of error that can correlate to a message reject.

func ConditionallyRequiredFieldMissing ¶

func ConditionallyRequiredFieldMissing(tag Tag) MessageRejectError

ConditionallyRequiredFieldMissing indicates that the requested field could not be found in the FIX message.

func IncorrectDataFormatForValue ¶ added in v0.3.0

func IncorrectDataFormatForValue(tag Tag) MessageRejectError

IncorrectDataFormatForValue returns an error indicating a field that cannot be parsed as the type required.

func InvalidMessageType ¶ added in v0.3.0

func InvalidMessageType() MessageRejectError

InvalidMessageType returns an error to indicate an invalid message type.

func InvalidTagNumber ¶ added in v0.3.0

func InvalidTagNumber(tag Tag) MessageRejectError

InvalidTagNumber returns a validation error for messages with invalid tags.

func NewBusinessMessageRejectError ¶

func NewBusinessMessageRejectError(err string, rejectReason int, refTagID *Tag) MessageRejectError

NewBusinessMessageRejectError returns a MessageRejectError with the given error mesage, reject reason, and optional reftagid. Reject is treated as a business level reject.

func NewBusinessMessageRejectErrorWithRefID ¶ added in v1.0.0

func NewBusinessMessageRejectErrorWithRefID(err string, rejectReason int, businessRejectRefID string, refTagID *Tag) MessageRejectError

NewBusinessMessageRejectErrorWithRefID returns a MessageRejectError with the given error mesage, reject reason, refID, and optional reftagid. Reject is treated as a business level reject.

func NewMessageRejectError ¶

func NewMessageRejectError(err string, rejectReason int, refTagID *Tag) MessageRejectError

NewMessageRejectError returns a MessageRejectError with the given error message, reject reason, and optional reftagid.

func NewOtherBusinessRejectError ¶ added in v1.0.5

func NewOtherBusinessRejectError(err string) MessageRejectError

NewOtherBusinessRejectError returns a BusinessMessageRejectError with the given error message.

func NewOtherRejectError ¶ added in v1.0.4

func NewOtherRejectError(err string) MessageRejectError

NewOtherRejectError returns a MessageRejectError with the given error message.

func RequiredTagMissing ¶ added in v0.3.0

func RequiredTagMissing(tag Tag) MessageRejectError

RequiredTagMissing returns a validation error when a required field cannot be found in a message.

func TagNotDefinedForThisMessageType ¶ added in v0.3.0

func TagNotDefinedForThisMessageType(tag Tag) MessageRejectError

TagNotDefinedForThisMessageType returns an error for an invalid tag appearing in a message.

func TagSpecifiedWithoutAValue ¶ added in v0.3.0

func TagSpecifiedWithoutAValue(tag Tag) MessageRejectError

TagSpecifiedWithoutAValue returns a validation error for when a field has no value.

func UnsupportedMessageType ¶ added in v0.3.0

func UnsupportedMessageType() MessageRejectError

UnsupportedMessageType returns an error to indicate an unhandled message.

func ValueIsIncorrect ¶

func ValueIsIncorrect(tag Tag) MessageRejectError

ValueIsIncorrect returns an error indicating a field with value that is not valid.

type MessageRoute ¶

type MessageRoute func(msg *Message, sessionID SessionID) MessageRejectError

A MessageRoute is a function that can process a fromApp/fromAdmin callback.

type MessageRouter ¶

type MessageRouter struct {
	// contains filtered or unexported fields
}

A MessageRouter is a mutex for MessageRoutes.

func NewMessageRouter ¶

func NewMessageRouter() *MessageRouter

NewMessageRouter returns an initialized MessageRouter instance.

func (MessageRouter) AddRoute ¶

func (c MessageRouter) AddRoute(beginString string, msgType string, router MessageRoute)

AddRoute adds a route to the MessageRouter instance keyed to begin string and msgType.

func (MessageRouter) Route ¶

func (c MessageRouter) Route(msg *Message, sessionID SessionID) MessageRejectError

Route may be called from the fromApp/fromAdmin callbacks. Messages that cannot be routed will be rejected with UnsupportedMessageType.

type MessageStore ¶

type MessageStore interface {
	NextSenderMsgSeqNum() int
	NextTargetMsgSeqNum() int

	IncrNextSenderMsgSeqNum() error
	IncrNextTargetMsgSeqNum() error

	SetNextSenderMsgSeqNum(next int) error
	SetNextTargetMsgSeqNum(next int) error

	CreationTime() time.Time

	SaveMessage(seqNum int, msg []byte) error
	SaveMessageAndIncrNextSenderMsgSeqNum(seqNum int, msg []byte) error
	GetMessages(beginSeqNum, endSeqNum int) ([][]byte, error)

	Refresh() error
	Reset() error

	Close() error

	SaveMessageWithTx(messageBuildData *BuildMessageInput) (output *BuildMessageOutput, err error)
	BuildMessage(messageBuildData *BuildMessageInput) (output *BuildMessageOutput, err error)
}

The MessageStore interface provides methods to record and retrieve messages for resend purposes.

type MessageStoreFactory ¶

type MessageStoreFactory interface {
	Create(sessionID SessionID) (MessageStore, error)
}

The MessageStoreFactory interface is used by session to create a session specific message store.

func NewFileStoreFactory ¶ added in v0.2.0

func NewFileStoreFactory(settings *Settings) MessageStoreFactory

NewFileStoreFactory returns a file-based implementation of MessageStoreFactory.

func NewMemoryStoreFactory ¶

func NewMemoryStoreFactory() MessageStoreFactory

NewMemoryStoreFactory returns a MessageStoreFactory instance that created in-memory MessageStores.

func NewMongoStoreFactory ¶ added in v1.0.0

func NewMongoStoreFactory(settings *Settings) MessageStoreFactory

NewMongoStoreFactory returns a mongo-based implementation of MessageStoreFactory.

func NewMongoStoreFactoryPrefixed ¶ added in v1.0.0

func NewMongoStoreFactoryPrefixed(settings *Settings, collectionsPrefix string) MessageStoreFactory

NewMongoStoreFactoryPrefixed returns a mongo-based implementation of MessageStoreFactory, with prefix on collections.

func NewSQLStoreFactory ¶ added in v0.2.0

func NewSQLStoreFactory(settings *Settings) MessageStoreFactory

NewSQLStoreFactory returns a sql-based implementation of MessageStoreFactory.

type MsgSeqNumCursor ¶ added in v1.0.9

type MsgSeqNumCursor interface {
	NextSenderMsgSeqNum() int
	NextTargetMsgSeqNum() int

	Reset() error
}

MsgSeqNumCursor interface provides methods for referencing/resetting the SeqNum position.

type RejectLogon ¶ added in v0.5.0

type RejectLogon struct {
	Text string
}

RejectLogon indicates the application is rejecting permission to logon. Implements MessageRejectError.

func (RejectLogon) BusinessRejectRefID ¶ added in v1.0.0

func (RejectLogon) BusinessRejectRefID() string

BusinessRejectRefID implements MessageRejectError.

func (RejectLogon) Error ¶ added in v0.5.0

func (e RejectLogon) Error() string

func (RejectLogon) IsBusinessReject ¶ added in v0.5.0

func (RejectLogon) IsBusinessReject() bool

IsBusinessReject implements MessageRejectError.

func (RejectLogon) RefTagID ¶ added in v0.5.0

func (RejectLogon) RefTagID() *Tag

RefTagID implements MessageRejectError.

func (RejectLogon) RejectReason ¶ added in v0.5.0

func (RejectLogon) RejectReason() int

RejectReason implements MessageRejectError.

type RepeatingGroup ¶

type RepeatingGroup struct {
	// contains filtered or unexported fields
}

RepeatingGroup is a FIX Repeating Group type.

func NewRepeatingGroup ¶ added in v0.3.0

func NewRepeatingGroup(tag Tag, template GroupTemplate) *RepeatingGroup

NewRepeatingGroup returns an initilized RepeatingGroup instance.

func (*RepeatingGroup) Add ¶

func (f *RepeatingGroup) Add() *Group

Add appends a new group to the RepeatingGroup and returns the new Group.

func (RepeatingGroup) Clone ¶ added in v0.4.0

func (f RepeatingGroup) Clone() GroupItem

Clone makes a copy of this RepeatingGroup (tag, template).

func (RepeatingGroup) Get ¶ added in v0.3.0

func (f RepeatingGroup) Get(i int) *Group

Get returns the ith group in this RepeatingGroup.

func (RepeatingGroup) Len ¶ added in v0.3.0

func (f RepeatingGroup) Len() int

Len returns the number of Groups in this RepeatingGroup.

func (*RepeatingGroup) Read ¶ added in v0.3.0

func (f *RepeatingGroup) Read(tv []TagValue) ([]TagValue, error)

func (RepeatingGroup) Tag ¶ added in v0.3.0

func (f RepeatingGroup) Tag() Tag

Tag returns the Tag for this repeating Group.

func (RepeatingGroup) Write ¶ added in v0.3.0

func (f RepeatingGroup) Write() []TagValue

Write returns tagValues for all Items in the repeating group ordered by Group sequence and Group template order.

type SessionID ¶

type SessionID struct {
	BeginString, TargetCompID, TargetSubID, TargetLocationID, SenderCompID, SenderSubID, SenderLocationID, Qualifier string
}

SessionID is a unique identifier of a Session.

func GetAliveSessionIDs ¶ added in v1.0.1

func GetAliveSessionIDs() []SessionID

GetAliveSessionIDs This function returns loggedOn sessionID list.

func GetSessionIDs ¶ added in v1.0.3

func GetSessionIDs() []SessionID

GetSessionIDs This function returns sessionID list.

func (SessionID) IsFIXT ¶ added in v0.3.0

func (s SessionID) IsFIXT() bool

IsFIXT returns true if the SessionID has a FIXT BeginString.

func (SessionID) String ¶

func (s SessionID) String() string

type SessionSettings ¶

type SessionSettings struct {
	// contains filtered or unexported fields
}

SessionSettings maps session settings to values with typed accessors.

func NewSessionSettings ¶

func NewSessionSettings() *SessionSettings

NewSessionSettings returns a newly initialized SessionSettings instance.

func (SessionSettings) BoolSetting ¶

func (s SessionSettings) BoolSetting(setting string) (bool, error)

BoolSetting returns the requested setting parsed as a boolean. Returns an error if the setting is not set or cannot be parsed as a bool.

func (*SessionSettings) DurationSetting ¶ added in v0.3.0

func (s *SessionSettings) DurationSetting(setting string) (val time.Duration, err error)

DurationSetting returns the requested setting parsed as a time.Duration. Returns an error if the setting is not set or cannot be parsed as a time.Duration.

func (*SessionSettings) HasSetting ¶

func (s *SessionSettings) HasSetting(setting string) bool

HasSetting returns true if a setting is set, false if not.

func (*SessionSettings) Init ¶

func (s *SessionSettings) Init()

Init initializes or resets SessionSettings.

func (*SessionSettings) IntSetting ¶

func (s *SessionSettings) IntSetting(setting string) (val int, err error)

IntSetting returns the requested setting parsed as an int. Returns an errror if the setting is not set or cannot be parsed as an int.

func (*SessionSettings) Set ¶

func (s *SessionSettings) Set(setting string, val string)

Set assigns a value to a setting on SessionSettings.

func (*SessionSettings) Setting ¶

func (s *SessionSettings) Setting(setting string) (string, error)

Setting is a settings string accessor. Returns an error if the setting is missing.

type Settings ¶

type Settings struct {
	// contains filtered or unexported fields
}

The Settings type represents a collection of global and session settings.

func NewSettings ¶

func NewSettings() *Settings

NewSettings creates a Settings instance.

func ParseSettings ¶

func ParseSettings(reader io.Reader) (*Settings, error)

ParseSettings creates and initializes a Settings instance with config parsed from a Reader. Returns error if the config is has parse errors.

func (*Settings) AddSession ¶

func (s *Settings) AddSession(sessionSettings *SessionSettings) (SessionID, error)

AddSession adds Session Settings to Settings instance. Returns an error if session settings with duplicate sessionID has already been added.

func (*Settings) GlobalSettings ¶

func (s *Settings) GlobalSettings() *SessionSettings

GlobalSettings are default setting inherited by all session settings.

func (*Settings) Init ¶

func (s *Settings) Init()

Init initializes or resets a Settings instance.

func (*Settings) SessionSettings ¶

func (s *Settings) SessionSettings() map[SessionID]*SessionSettings

SessionSettings return all session settings overlaying globalsettings.

type Tag ¶

type Tag int

Tag is a typed int representing a FIX tag.

func (Tag) IsHeader ¶

func (t Tag) IsHeader() bool

IsHeader returns true if tag belongs in the message header.

func (Tag) IsTrailer ¶

func (t Tag) IsTrailer() bool

IsTrailer returns true if tag belongs in the message trailer.

type TagValue ¶ added in v0.3.0

type TagValue struct {
	// contains filtered or unexported fields
}

TagValue is a low-level FIX field abstraction.

func (TagValue) String ¶ added in v0.3.0

func (tv TagValue) String() string

type TimestampPrecision ¶ added in v1.0.0

type TimestampPrecision int

TimestampPrecision defines the precision used by FIXUTCTimestamp.

const (
	Millis TimestampPrecision = iota
	Seconds
	Micros
	Nanos
)

All TimestampPrecisions supported by FIX.

type Trailer ¶ added in v0.3.0

type Trailer struct{ FieldMap }

Trailer is the last section of a FIX message.

func (*Trailer) Init ¶ added in v0.3.0

func (t *Trailer) Init()

Init initializes the FIX message.

func (Trailer) Len ¶ added in v0.6.0

func (t Trailer) Len() int

func (Trailer) Less ¶ added in v0.6.0

func (t Trailer) Less(i, j int) bool

func (Trailer) Swap ¶ added in v0.6.0

func (t Trailer) Swap(i, j int)

type Validator ¶ added in v1.0.9

type Validator interface {
	Validate(*Message) MessageRejectError
}

Validator validates a FIX message.

func NewValidator ¶ added in v1.0.9

func NewValidator(settings ValidatorSettings, appDataDictionary, transportDataDictionary *datadictionary.DataDictionary) Validator

NewValidator creates a FIX message validator from the given data dictionaries.

type ValidatorSettings ¶ added in v1.0.9

type ValidatorSettings struct {
	CheckFieldsOutOfOrder bool
	RejectInvalidMessage  bool
}

ValidatorSettings describe validation behavior.

Directories ¶

Path Synopsis
_test
cmd
Package config declares application and session settings for QuickFIX/Go
Package config declares application and session settings for QuickFIX/Go
Package datadictionary provides support for parsing and organizing FIX Data Dictionaries
Package datadictionary provides support for parsing and organizing FIX Data Dictionaries
ioi

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL