streaming

package
v0.0.0-...-2914de0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LiveEndpoint        = "stream-api.betfair.com:443"
	IntegrationEndpoint = "stream-api-integration.betfair.com:443"
)
View Source
const MaxSubscriptionLimit = 200

MarketSubscriptionLimit is the max number of markets that can be subscribed to via the Betfair Stream API

Variables

View Source
var MarketDataFilterEnum = struct {
	ExBestOffersDisp,
	ExBestOffers,
	ExAllOffers,
	ExTraded,
	ExTradedVol,
	ExLTP,
	ExMarketDef,
	SPTraded,
	SPProjected MarketDataFilterFlag
}{
	ExBestOffersDisp: "EX_BEST_OFFERS_DISP",
	ExBestOffers:     "EX_BEST_OFFERS",
	ExAllOffers:      "EX_ALL_OFFERS",
	ExTraded:         "EX_TRADED",
	ExTradedVol:      "EX_TRADED_VOL",
	ExLTP:            "EX_LTP",
	ExMarketDef:      "EX_MARKET_DEF",
	SPTraded:         "SP_TRADED",
	SPProjected:      "SP_PROJECTED",
}

MarketDataFilterEnum describes the various field flags that can be passed in to the "fields" array of a MarketSubscription. see https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/Exchange+Stream+API#ExchangeStreamAPI-Marketdatafieldfiltering/MarketDataFilter

Functions

This section is empty.

Types

type AuthenticationError

type AuthenticationError struct{}

func (*AuthenticationError) Error

func (err *AuthenticationError) Error() string

type Available

type Available struct {
	Prices  ByPrice
	Reverse bool
}

func (*Available) AppendPrice

func (available *Available) AppendPrice(update []float64)

func (*Available) Clear

func (available *Available) Clear()

func (*Available) RemovePrice

func (available *Available) RemovePrice(i int)

func (*Available) Sort

func (available *Available) Sort()

func (*Available) Update

func (available *Available) Update(updates [][]float64)

func (*Available) UpdatePrice

func (available *Available) UpdatePrice(count int, update []float64)

type AvailableInterface

type AvailableInterface interface {
	Clear()
	Sort()
	UpdatePrice(int, []float64)
	AppendPrice([]float64)
	RemovePrice(int)
	Update([][]float64)
}

type AvailablePosition

type AvailablePosition struct {
	Prices  ByPosition
	Reverse bool
}

func (*AvailablePosition) AppendPrice

func (available *AvailablePosition) AppendPrice(update []float64)

func (*AvailablePosition) Clear

func (available *AvailablePosition) Clear()

func (*AvailablePosition) RemovePrice

func (available *AvailablePosition) RemovePrice(i int)

func (*AvailablePosition) Sort

func (available *AvailablePosition) Sort()

func (*AvailablePosition) Update

func (available *AvailablePosition) Update(updates [][]float64)

func (*AvailablePosition) UpdatePrice

func (available *AvailablePosition) UpdatePrice(count int, update []float64)

type ByPosition

type ByPosition []PositionPriceSize

sort.Interface for []PositionPriceSize based on position

func (ByPosition) GetLastItem

func (a ByPosition) GetLastItem() PositionPriceSize

func (ByPosition) Len

func (a ByPosition) Len() int

func (ByPosition) Less

func (a ByPosition) Less(i, j int) bool

func (ByPosition) Swap

func (a ByPosition) Swap(i, j int)

type ByPrice

type ByPrice []PriceSize

sort.Interface for []PriceSize based on price

func (ByPrice) GetLastItem

func (a ByPrice) GetLastItem() PriceSize

func (ByPrice) Len

func (a ByPrice) Len() int

func (ByPrice) Less

func (a ByPrice) Less(i, j int) bool

func (ByPrice) Swap

func (a ByPrice) Swap(i, j int)

type CachedMarkets

type CachedMarkets map[string]*MarketCache

type CachedOrders

type CachedOrders map[string]*OrderBookCache

CachedOrders maps MarketID's to Orders on the Exchange

type ConnectionError

type ConnectionError struct{}

func (*ConnectionError) Error

func (err *ConnectionError) Error() string

type EndpointError

type EndpointError struct{}

func (*EndpointError) Error

func (err *EndpointError) Error() string

type ExchangePrices

type ExchangePrices struct {
	BestAvailableToBack PositionPriceSize
	BestAvailableToLay  PositionPriceSize
	AvailableToBack     PriceSize
	AvailableToLay      PriceSize
	TradedVolume        PriceSize
}

type IMarketHandler

type IMarketHandler interface {
	OnSubscribe(ChangeMessage models.MarketChangeMessage)
	OnResubscribe(ChangeMessage models.MarketChangeMessage)
	OnHeartbeat(ChangeMessage models.MarketChangeMessage)
	OnUpdate(ChangeMessage models.MarketChangeMessage)
}

type IOrderHandler

type IOrderHandler interface {
	OnSubscribe(ChangeMessage models.OrderChangeMessage)
	OnResubscribe(ChangeMessage models.OrderChangeMessage)
	OnHeartbeat(ChangeMessage models.OrderChangeMessage)
	OnUpdate(ChangeMessage models.OrderChangeMessage)
}

type MarketBook

type MarketBook struct {
	PublishTime           int64
	MarketID              string
	Status                string
	BetDelay              int32
	BspReconciled         bool
	Complete              bool
	InPlay                bool
	NumberOfWinners       int32
	NumberOfRunners       int
	NumberOfActiveRunners int32
	TotalMatched          float64
	CrossMatching         bool
	RunnersVoidable       bool
	Version               int64
	Runners               []Runner
}

type MarketCache

type MarketCache struct {
	PublishTime      *int64
	MarketID         string
	TradedVolume     *float64
	MarketDefinition *models.MarketDefinition
	Runners          map[int64]RunnerCache
}

func (*MarketCache) GetRunnerDefinition

func (cache *MarketCache) GetRunnerDefinition(selectionId int64) models.RunnerDefinition

func (*MarketCache) Snap

func (cache *MarketCache) Snap() MarketBook

func (*MarketCache) UpdateCache

func (cache *MarketCache) UpdateCache(changeMessage *models.MarketChangeMessage, marketChange *models.MarketChange)

type MarketDataFilterFlag

type MarketDataFilterFlag string

type MarketSubscriptionResponse

type MarketSubscriptionResponse struct {
	SubscribedMarketIDs []string
}

type NoConnectionError

type NoConnectionError struct{}

func (*NoConnectionError) Error

func (err *NoConnectionError) Error() string

type OrderBookCache

type OrderBookCache struct {
	MarketID        string
	LastPublishTime int64
	Runners         map[int64]*models.OrderRunnerChange
	Closed          bool
}

func (*OrderBookCache) Snap

func (cache *OrderBookCache) Snap() *OrderBookCache

type PositionPriceSize

type PositionPriceSize struct {
	Position float64
	Price    float64
	Size     float64
}

type PriceSize

type PriceSize struct {
	Price float64
	Size  float64
}

type Runner

type Runner struct {
	SelectionID      int64
	Handicap         float64
	Status           string
	AdjustmentFactor float64
	LastPriceTraded  float64
	TotalMatched     float64
	RemovalDate      strfmt.DateTime
	EX               ExchangePrices
}

type RunnerCache

type RunnerCache struct {
	SelectionId                int64
	LastTradedPrice            *float64
	TradedVolume               *float64
	StartingPriceNear          *float64
	StartingPriceFar           *float64
	Traded                     *Available
	AvailableToBack            *Available
	AvailableToLay             *Available
	StartingPriceBack          *Available
	StartingPriceLay           *Available
	BestAvailableToBack        *AvailablePosition
	BestAvailableToLay         *AvailablePosition
	BestDisplayAvailableToBack *AvailablePosition
	BestDisplayAvailableToLay  *AvailablePosition
}

func (*RunnerCache) Snap

func (cache *RunnerCache) Snap(definition models.RunnerDefinition) Runner

func (*RunnerCache) UpdateCache

func (cache *RunnerCache) UpdateCache(change *models.RunnerChange)

type Stream

type Stream struct {
	MarketCache CachedMarkets
	OrderCache  CachedOrders
	Channels    *StreamChannels
	// contains filtered or unexported fields
}

func NewStream

func NewStream(certs *tls.Certificate, appKey string) (*Stream, error)

NewStream generates a Stream object which can be subsequently used to connect to an Exchange Stream endpoint

func (*Stream) Start

func (stream *Stream) Start(endpoint string, sessionToken string) error

Start performs the Connection and Authentication steps and initializes the read/write goroutines

func (*Stream) Stop

func (stream *Stream) Stop()

Stop tears down the underlying TLS session to the Streaming endpoint

func (*Stream) SubscribeToMarkets

func (stream *Stream) SubscribeToMarkets(marketFilter *models.MarketFilter, marketDataFilter *models.MarketDataFilter)

func (*Stream) SubscribeToOrders

func (stream *Stream) SubscribeToOrders()

type StreamChannels

type StreamChannels struct {

	// Incoming Responses
	Err          chan error
	MarketUpdate chan MarketBook
	OrderUpdate  chan OrderBookCache
	Status       chan models.StatusMessage
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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