Documentation
¶
Index ¶
- Constants
- Variables
- func CmpTime(t1 time.Time, t2 time.Time) int
- func DecodeDecimal(r ByteReader) Fixed
- func DecodeString(r ByteReader) string
- func DecodeTime(r ByteReader) time.Time
- func EncodeDecimal(w ByteWriter, d Fixed)
- func EncodeString(w ByteWriter, s string)
- func EncodeTime(w ByteWriter, time time.Time)
- func MapToFixOrdStatus(state OrderState) enum.OrdStatus
- func MapToFixSide(side Side) enum.Side
- func MinDecimal(d0 Fixed, d1 Fixed) Fixed
- func NewDecimal(s string) Fixed
- func NewDecimalF(f float64) Fixed
- func ParseInt(s string) int
- func PutUvarint(w ByteWriter, x uint64) int
- func PutVarint(w ByteWriter, x int64) int
- func ReadUvarint(r ByteReader) (uint64, error)
- func ReadVarint(r ByteReader) (int64, error)
- func ToDecimal(f Fixed) decimal.Decimal
- func ToFixed(d decimal.Decimal) Fixed
- func ToFloat(d Fixed) float64
- type Book
- type BookLevel
- type ByteReader
- type ByteWriter
- type ConnectorCallback
- type Equity
- type ExchangeConnector
- type Expiration
- type Fill
- type Generic
- type Index
- type Instrument
- type Maturity
- type Option
- type OptionLeg
- type OptionStrategy
- type Order
- type OrderID
- type OrderState
- type OrderType
- type Properties
- type Side
- type StatusBool
- type Trade
Constants ¶
View Source
const ( Call optionType = "call" Put optionType = "put" )
Variables ¶
View Source
var AlreadyConnected = errors.New("already connected")
View Source
var ConnectionFailed = errors.New("connection failed")
View Source
var DownloadFailed = errors.New("download failed")
View Source
var IMap instrumentMap
global instrument map which is fully synchronized
View Source
var InvalidConnector = errors.New("invalid connector")
View Source
var NotConnected = errors.New("not connected")
View Source
var OrderNotFound = errors.New("order not found")
View Source
var UnknownInstrument = errors.New("unknown instrument")
View Source
var UnsupportedOrderType = errors.New("unsupported order type")
Functions ¶
func DecodeDecimal ¶
func DecodeDecimal(r ByteReader) Fixed
func DecodeString ¶
func DecodeString(r ByteReader) string
func DecodeTime ¶
func DecodeTime(r ByteReader) time.Time
func EncodeDecimal ¶
func EncodeDecimal(w ByteWriter, d Fixed)
func EncodeString ¶
func EncodeString(w ByteWriter, s string)
func EncodeTime ¶
func EncodeTime(w ByteWriter, time time.Time)
func MapToFixOrdStatus ¶
func MapToFixOrdStatus(state OrderState) enum.OrdStatus
func MapToFixSide ¶
func MinDecimal ¶
func MinDecimal(d0 Fixed, d1 Fixed) Fixed
func NewDecimal ¶
func NewDecimal(s string) Fixed
func NewDecimalF ¶
func NewDecimalF(f float64) Fixed
func PutUvarint ¶
func PutUvarint(w ByteWriter, x uint64) int
PutUvarint encodes a uint64 into buf and returns the number of bytes written.
func PutVarint ¶
func PutVarint(w ByteWriter, x int64) int
PutVarint encodes an int64 into buf and returns the number of bytes written.
func ReadUvarint ¶
func ReadUvarint(r ByteReader) (uint64, error)
ReadUvarint reads an encoded unsigned integer from r and returns it as a uint64.
func ReadVarint ¶
func ReadVarint(r ByteReader) (int64, error)
ReadVarint reads an encoded signed integer from r and returns it as an int64.
Types ¶
type Book ¶
type Book struct {
Instrument Instrument
Bids []BookLevel
Asks []BookLevel
Sequence uint64
}
type ByteReader ¶
type ByteReader interface {
io.Reader
io.ByteReader
}
type ByteWriter ¶
type ByteWriter interface {
io.Writer
io.ByteWriter
}
type ConnectorCallback ¶
type ConnectorCallback interface {
OnBook(*Book)
// the following is for intra-day instrument addition, or initial startup
OnInstrument(Instrument)
// the callback will have the order locked, and will unlock when the callback returns
OnOrderStatus(*Order)
OnFill(*Fill)
OnTrade(*Trade)
}
type Equity ¶
type Equity struct {
Instrument
}
type ExchangeConnector ¶
type ExchangeConnector interface {
IsConnected() bool
Connect() error
Disconnect() error
CreateOrder(order *Order) (OrderID, error)
ModifyOrder(order OrderID, price Fixed, quantity Fixed) error
CancelOrder(order OrderID) error
Quote(instrument Instrument, bidPrice Fixed, bidQuantity Fixed, askPrice Fixed, askQuantity Fixed) error
GetExchangeCode() string
// ask exchange to create the instrument if it does not already exist, and assign a numeric instrument id
// the instruments are not persisted across exchange restarts
CreateInstrument(symbol string)
// ask exchange for configured instruments, will be emitted via onInstrument() on the callback. this call
// blocks until all instruments are received
DownloadInstruments() error
}
type Expiration ¶
type Fill ¶
type Fill struct {
Instrument Instrument
IsQuote bool
// Order will be nil on quote trade, the order is unlocked
Order *Order
ExchangeID string
Quantity Fixed
Price Fixed
Side Side
IsLegTrade bool
}
a fill on an order or quote
type Generic ¶
type Generic struct {
Instrument
}
type Index ¶
type Index struct {
Instrument
}
type Instrument ¶
func NewInstrument ¶
func NewInstrument(id int64, symbol string) Instrument
type Option ¶
type Option struct {
Instrument
Underlying Instrument
Expires Expiration
Strike decimal.Decimal
OptionType optionType
MaturityDate Maturity
}
type OptionStrategy ¶
type OptionStrategy struct {
Instrument
Expires Expiration
Maturity Maturity
Legs []OptionLeg
}
type Order ¶
type Order struct {
sync.RWMutex
Instrument
Id OrderID
ExchangeId string
Price Fixed
Side
Quantity Fixed
Remaining Fixed
OrderType
OrderState
RejectReason string
}
func LimitOrder ¶
func LimitOrder(instrument Instrument, side Side, price Fixed, quantity Fixed) *Order
func MarketOrder ¶
func MarketOrder(instrument Instrument, side Side, quantity Fixed) *Order
type OrderState ¶
type OrderState string
const ( New OrderState = "new" Booked OrderState = "booked" PartialFill OrderState = "partial" Filled OrderState = "filled" Cancelled OrderState = "cancelled" Rejected OrderState = "rejected" )
func MapFromFixOrdStatus ¶
func MapFromFixOrdStatus(ordStatus enum.OrdStatus) OrderState
type Properties ¶
type Properties interface {
GetString(key string, def string) string
SetString(key string, value string)
GetBytes(key string, def int) int
Clone() Properties
}
func NewProperties ¶
func NewProperties(file string) (Properties, error)
func NewPropertiesFromReader ¶
func NewPropertiesFromReader(r io.Reader) (Properties, error)
type StatusBool ¶
type StatusBool struct {
// contains filtered or unexported fields
}
func (*StatusBool) IsTrue ¶
func (sb *StatusBool) IsTrue() bool
func (*StatusBool) SetFalse ¶
func (sb *StatusBool) SetFalse()
func (*StatusBool) SetTrue ¶
func (sb *StatusBool) SetTrue()
func (*StatusBool) WaitForFalse ¶
func (sb *StatusBool) WaitForFalse(timeoutMS int64) bool
func (*StatusBool) WaitForTrue ¶
func (sb *StatusBool) WaitForTrue(timeoutMS int64) bool
Click to show internal directories.
Click to hide internal directories.