Documentation ¶
Index ¶
- Constants
- type AuthenticationMessage
- type BettingType
- type ChangeType
- type ConnectionConfig
- type ConnectionError
- type ConnectionFailedError
- type ConnectionMessage
- type ESAClient
- func (esaclient *ESAClient) Authenticate() (StatusMessage, error)
- func (esaclient *ESAClient) ChangeSettings(chanWaitTime uint32, heartbeatMS uint32, heartbeatMultiplier uint32) error
- func (esaclient *ESAClient) Connect(ctx context.Context, connConfig ConnectionConfig) error
- func (esaclient *ESAClient) Disconnect() error
- func (esaclient *ESAClient) GetMetricsHandler() http.Handler
- func (esaclient *ESAClient) GetSessionInfo() (string, string, string, uint32)
- func (esaclient *ESAClient) Heartbeat() (StatusMessage, error)
- func (esaclient *ESAClient) MarketSubscribe(msm MarketSubscriptionMessage) (StatusMessage, error)
- func (esaclient *ESAClient) OrderSubscribe(osm OrderSubscriptionMessage) (StatusMessage, error)
- func (esaclient *ESAClient) TurnOffMetrics() error
- func (esaclient *ESAClient) TurnOnMetrics() error
- type ErrorCode
- type KeyLineDefinition
- type KeyLineSelection
- type MarketChange
- type MarketChangeM
- type MarketChangeMessage
- type MarketDataFilter
- type MarketDefinition
- type MarketFilter
- type MarketSubscriptionMessage
- type Order
- type OrderChangeM
- type OrderChangeMessage
- type OrderFilter
- type OrderMarketChange
- type OrderRunnerChange
- type OrderSide
- type OrderStatus
- type OrderSubscriptionMessage
- type OrderType
- type PersistenceType
- type PolicyExponential
- type PriceData
- type PriceLadderDefinition
- type PriceLadderType
- type RaceStatus
- type RequestMessage
- type ResponseMessage
- type RunnerChange
- type RunnerDefinition
- type RunnerStatus
- type SegmentType
- type StatusCode
- type StatusMessage
- type StrategyMatchChange
- type WorkUnit
Constants ¶
const BetfairHostPreProd string = "stream-api-integration.betfair.com"
Consts
const BetfairHostProd string = "stream-api.betfair.com"
const BetfairPort uint = 443
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticationMessage ¶
type BettingType ¶
type BettingType int
const ( BettingType_Odds BettingType = iota + 1 BettingType_Line BettingType_Range BettingType_AsianHandicapDoubleLine BettingType_AsianHandicapSingleLine )
func (BettingType) MarshalJSON ¶
func (bt BettingType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (BettingType) String ¶
func (bt BettingType) String() string
func (*BettingType) UnmarshalJSON ¶
func (bt *BettingType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type ChangeType ¶
type ChangeType int
const ( ChangeType_SubImage ChangeType = iota + 1 ChangeType_ResubDelta ChangeType_Heartbeat )
func (ChangeType) MarshalJSON ¶
func (ct ChangeType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (ChangeType) String ¶
func (ct ChangeType) String() string
func (*ChangeType) UnmarshalJSON ¶
func (ct *ChangeType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type ConnectionConfig ¶
type ConnectionConfig struct { // ServerHost is the betfair FQDN/IP ServerHost string // ServerPort is the betfair server port (443) ServerPort uint // InsecureSkipVerify sets on/off the TLS cert validation InsecureSkipVerify bool // ConnectionTimeout specifies the wait time (in milliseconds) before timing out the connection ConnectionTimeout int // Retries specifies the number of retries allowed. // -1 means infinite number of retries // 0 means to never retry // Any other number greater or equal to 1 means retry X amount of times Retries int // MaximunBackoff specifies the maximun waiting time between actions (in seconds) MaximumBackoff uint // Reconnect specifies whether to retry connecting to server upon undesired disconnection Reconnect bool }
type ConnectionError ¶
ConnectionError is the error returned by Connect() when an error occurs
func (ConnectionError) Error ¶
func (e ConnectionError) Error() string
func (ConnectionError) Unwrap ¶
func (e ConnectionError) Unwrap() error
type ConnectionFailedError ¶
ConnectionFailedError is the error returned by Connect() when it can't connect to the server (should retry)
func (ConnectionFailedError) Error ¶
func (e ConnectionFailedError) Error() string
func (ConnectionFailedError) Unwrap ¶
func (e ConnectionFailedError) Unwrap() error
type ConnectionMessage ¶
type ConnectionMessage struct {
ConnectionID string `json:"connectionId"`
}
type ESAClient ¶
type ESAClient struct { // Change Streams // Public channel MCMChan chan MarketChangeM OCMChan chan OrderChangeM // contains filtered or unexported fields }
ESAClient is the client that interacts with betfair Exchange Stream API It's thread safe!
func NewESAClient ¶
NewESAClient creates a new esaclient object.
func (*ESAClient) Authenticate ¶
func (esaclient *ESAClient) Authenticate() (StatusMessage, error)
Authenticate authenticates with betfair
func (*ESAClient) ChangeSettings ¶
func (esaclient *ESAClient) ChangeSettings(chanWaitTime uint32, heartbeatMS uint32, heartbeatMultiplier uint32) error
ChangeSettings changes some setting on the esaclient.
func (*ESAClient) Connect ¶
func (esaclient *ESAClient) Connect(ctx context.Context, connConfig ConnectionConfig) error
Connect connects to the betfair server. When connected, spawn 4 goroutines: controller, reader, writer and connection tracker.
func (*ESAClient) Disconnect ¶
Disconnect disconnects from the server
func (*ESAClient) GetMetricsHandler ¶
func (*ESAClient) GetSessionInfo ¶
GetSessionInfo returns the application key, the session token, the connection ID and the current message ID counter.
func (*ESAClient) Heartbeat ¶
func (esaclient *ESAClient) Heartbeat() (StatusMessage, error)
Heartbeat sends heartbeat message
func (*ESAClient) MarketSubscribe ¶
func (esaclient *ESAClient) MarketSubscribe(msm MarketSubscriptionMessage) (StatusMessage, error)
MarketSubscribe subscribes to markets
func (*ESAClient) OrderSubscribe ¶
func (esaclient *ESAClient) OrderSubscribe(osm OrderSubscriptionMessage) (StatusMessage, error)
OrderSubscribe subscribes to orders
func (*ESAClient) TurnOffMetrics ¶
func (*ESAClient) TurnOnMetrics ¶
type ErrorCode ¶
type ErrorCode int
const ( ErrorCode_NoAppKey ErrorCode = iota + 1 ErrorCode_InvalidAppKey ErrorCode_NoSession ErrorCode_InvalidSessionInformation ErrorCode_NotAuthorized ErrorCode_InvalidInput ErrorCode_InvalidClock ErrorCode_UnexpectedError ErrorCode_Timeout ErrorCode_SubscriptionLimitExceeded ErrorCode_InvalidRequest ErrorCode_ConnectionFailed ErrorCode_MaxConnectionLimitExceeded )
func (ErrorCode) MarshalJSON ¶
MarshalJSON marshals the enum as a quoted json string
func (*ErrorCode) UnmarshalJSON ¶
UnmarshalJSON unmashals a quoted json string to the enum value
type KeyLineDefinition ¶
type KeyLineDefinition struct {
Kl []KeyLineSelection `json:"kl"`
}
type KeyLineSelection ¶
type MarketChange ¶
type MarketChange struct { RunnerChanges []RunnerChange `json:"rc,omitempty"` Image *bool `json:"img,omitempty"` TotalVolume *float64 `json:"tv"` Conflated *bool `json:"con,omitempty"` MarketDefinition *MarketDefinition `json:"marketDefinition,omitempty"` ID string `json:"id"` }
type MarketChangeM ¶
type MarketChangeM struct { ID *uint32 MarketChangeMessage }
type MarketChangeMessage ¶
type MarketChangeMessage struct { ChangeType *ChangeType `json:"ct,omitempty"` Clk string `json:"clk"` HeartbeatMs uint `json:"heartbeatMs"` PublishTime uint `json:"pt"` InitialClk string `json:"initialClk"` MarketChanges []MarketChange `json:"mc,omitempty"` ConflateMs uint `json:"conflateMs"` SegmentType *SegmentType `json:"segmentType,omitempty"` Status *uint `json:"status,omitempty"` }
type MarketDataFilter ¶
type MarketDefinition ¶
type MarketDefinition struct { Venue string `json:"venue"` RaceType string `json:"raceType"` SettledTime string `json:"settledTime"` // TODO: time.Time! Timezone string `json:"timezone"` EachWayDivisor float64 `json:"eachWayDivisor"` Regulators []string `json:"regulators"` MarketType string `json:"marketType"` MarketBaseRate float64 `json:"marketBaseRate"` NumberOfWinners uint `json:"numberOfWinners"` CountryCode string `json:"countryCode"` LineMaxUnit float64 `json:"lineMaxUnit"` InPlay *bool `json:"inPlay,omitempty"` BetDelay uint `json:"betDelay"` BSPMarket *bool `json:"bspMarket,omitempty"` BettingType BettingType `json:"bettingType"` NumberOfActiveRunners uint `json:"numberOfActiveRunners"` LineMinUnit float64 `json:"lineMinUnit"` EventID string `json:"eventId"` CrossMatching *bool `json:"crossMatching,omitempty"` RunnersVoidable *bool `json:"runnersVoidable,omitempty"` TurnInPlayEnabled *bool `json:"turnInPlayEnabled,omitempty"` PriceLadderDefinition PriceLadderDefinition `json:"priceLadderDefinition"` KeyLineDefinition KeyLineDefinition `json:"keyLineDefinition"` SuspendTime string `json:"suspendTime"` // TODO: time.Time! DiscountAllowed *bool `json:"discountAllowed,omitempty"` PersistenceEnabled *bool `json:"persistenceEnabled,omitempty"` Runners []RunnerDefinition `json:"runners"` Version uint `json:"version"` EventTypeID string `json:"eventTypeId"` Complete *bool `json:"complete,omitempty"` OpenDate string `json:"openDate"` // TODO: time.Time! MarketTime string `json:"marketTime"` // TODO: time.Time! BSPReconciled *bool `json:"bspReconciled,omitempty"` LineInterval float64 `json:"lineInterval"` Status RaceStatus `json:"status"` }
type MarketFilter ¶
type MarketFilter struct { CountryCodes []string `json:"countryCodes,omitempty"` BettingTypes []BettingType `json:"bettingTypes,omitempty"` TurnInPlayEnabled *bool `json:"turnInPlayEnabled,omitempty"` MarketTypes []string `json:"marketTypes,omitempty"` Venues []string `json:"venues,omitempty"` MarketIDs []string `json:"marketIds,omitempty"` EventTypeIDs []string `json:"eventTypeIds,omitempty"` EventIDs []string `json:"eventIds,omitempty"` BSPMarket *bool `json:"bspMarket,omitempty"` RaceTypes []string `json:"raceTypes,omitempty"` }
type MarketSubscriptionMessage ¶
type MarketSubscriptionMessage struct { SegmentationEnabled bool `json:"segmentationEnabled"` Clk string `json:"clk,omitempty"` HeartbeatMs uint `json:"heartbeatMs,omitempty"` InitialClk string `json:"initialClk,omitempty"` MarketFilter MarketFilter `json:"marketFilter"` ConflateMs uint `json:"conflateMs"` MarketDataFilter MarketDataFilter `json:"marketDataFilter"` }
type Order ¶
type Order struct { Side OrderSide `json:"side"` SizeVoided float64 `json:"sv"` PersistenceType PersistenceType `json:"pt"` OrderType OrderType `json:"ot"` Price float64 `json:"p"` SizeCancelled float64 `json:"sc"` RegulatorCode string `json:"rc"` Size float64 `json:"s"` PlacedDate uint `json:"pd"` //TODO: time.Time! RegulatorAuthCode string `json:"rac"` MatchedDate *uint `json:"md,omitempty"` //TODO: time.Time! LapsedDate *uint `json:"ld,omitempty"` //TODO: time.Time! SizeLapsed float64 `json:"sl"` AveragePriceMatched *float64 `json:"avp,omitempty"` SizeMatched float64 `json:"sm"` OrderReference *string `json:"rfo,omitempty"` ID string `json:"id"` BSP *float64 `json:"bsp,omitempty"` StrategyReference *string `json:"rfs,omitempty"` Status OrderStatus `json:"status"` SizeRemaining float64 `json:"sr"` }
type OrderChangeM ¶
type OrderChangeM struct { ID *uint32 OrderChangeMessage }
type OrderChangeMessage ¶
type OrderChangeMessage struct { ChangeType *ChangeType `json:"ct,omitempty"` Clk string `json:"clk"` HeartbeatMs uint `json:"heartbeatMs"` PublishTime uint `json:"pt"` OrderMarketChanges []OrderMarketChange `json:"oc,omitempty"` InitialClk string `json:"initialClk"` ConflateMs uint `json:"conflateMs"` SegmentType *SegmentType `json:"segmentType,omitempty"` Status *uint `json:"status,omitempty"` }
type OrderFilter ¶
type OrderMarketChange ¶
type OrderMarketChange struct { AccountID uint `json:"accountId"` OrderChanges []OrderRunnerChange `json:"orc,omitempty"` Closed *bool `json:"closed"` ID string `json:"id"` }
type OrderRunnerChange ¶
type OrderRunnerChange struct { MatchedBacks [][]float64 `json:"mb,omitempty"` StrategyMatches map[string]StrategyMatchChange `json:"smc,omitempty"` UnmatchedOrders []Order `json:"uo,omitempty"` ID uint `json:"id"` Handicap float64 `json:"hc,omitempty"` FullImage *bool `json:"fullImage,omitempty"` MatchedLays [][]float64 `json:"ml,omitempty"` }
type OrderSide ¶
type OrderSide int
func (OrderSide) MarshalJSON ¶
MarshalJSON marshals the enum as a quoted json string
func (*OrderSide) UnmarshalJSON ¶
UnmarshalJSON unmashals a quoted json string to the enum value
type OrderStatus ¶
type OrderStatus int
const ( OrderStatus_Executable OrderStatus = iota + 1 OrderStatus_ExecutableComplete )
func (OrderStatus) MarshalJSON ¶
func (os OrderStatus) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (OrderStatus) String ¶
func (os OrderStatus) String() string
func (*OrderStatus) UnmarshalJSON ¶
func (os *OrderStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type OrderSubscriptionMessage ¶
type OrderSubscriptionMessage struct { SegmentationEnabled bool `json:"segmentationEnabled"` OrderFilter OrderFilter `json:"orderFilter"` Clk string `json:"clk,omitempty"` HeartbeatMs uint `json:"heartbeatMs,omitempty"` InitialClk string `json:"initialClk,omitempty"` ConflateMs uint `json:"conflateMs"` }
type OrderType ¶
type OrderType int
func (OrderType) MarshalJSON ¶
MarshalJSON marshals the enum as a quoted json string
func (*OrderType) UnmarshalJSON ¶
UnmarshalJSON unmashals a quoted json string to the enum value
type PersistenceType ¶
type PersistenceType int
const ( PersistenceType_Lapse PersistenceType = iota + 1 PersistenceType_Persist PersistenceType_MarketOnClose )
func (PersistenceType) MarshalJSON ¶
func (pt PersistenceType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (PersistenceType) String ¶
func (pt PersistenceType) String() string
func (*PersistenceType) UnmarshalJSON ¶
func (pt *PersistenceType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type PolicyExponential ¶
type PolicyExponential struct { // Retries specifies the number of retries allowed. // -1 means infinite number of retries // 0 means to never retry // Any other number greater or equal to 1 means retry X amount of times Retries int // MaximunBackoff specifies the maximun waiting time between actions (in seconds) MaximumBackoff uint // contains filtered or unexported fields }
PolicyExponential defines an executer for the exponential retry policy.
func NewPolicyExponential ¶
func NewPolicyExponential(retries int, maximunBackoff uint, initialCount uint) PolicyExponential
NewPolicyExponential creates a new PolicyExponential. Accepts a PolicyExponential struct as the first argument and the initialCount as second. For most use cases you will want to set initialCount to zero.
func (*PolicyExponential) BackOffTime ¶
func (pee *PolicyExponential) BackOffTime() int
BackOffTime returns the time to wait (in milliseconds) until next retry. If returned value is -1 it means no more retries.
func (PolicyExponential) RetryAllowed ¶
func (pee PolicyExponential) RetryAllowed() bool
RetryAllowed returns a boolean reflecting whether it's still allowed to retry or not.
func (PolicyExponential) RetryCount ¶
func (pee PolicyExponential) RetryCount() uint
RetryCount returns the number of retry attempts so far.
func (*PolicyExponential) WaitBackOff ¶
func (pee *PolicyExponential) WaitBackOff(ctx context.Context) (bool, error)
WaitBackOff waits for a certain time until next retry. It accepts a context so the caller can cancel the waiting time and get back control. In case of a cancellation, the first returned value will be true, false otherwise. If no more retries should happen, this function will return immediately with an error.
type PriceData ¶
type PriceData int
func (PriceData) MarshalJSON ¶
MarshalJSON marshals the enum as a quoted json string
func (*PriceData) UnmarshalJSON ¶
UnmarshalJSON unmashals a quoted json string to the enum value
type PriceLadderDefinition ¶
type PriceLadderDefinition struct {
Type PriceLadderType `json:"type"`
}
type PriceLadderType ¶
type PriceLadderType int
const ( PriceLadderType_Classic PriceLadderType = iota + 1 PriceLadderType_Finest PriceLadderType_LineRange )
func (PriceLadderType) MarshalJSON ¶
func (plt PriceLadderType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (PriceLadderType) String ¶
func (plt PriceLadderType) String() string
func (*PriceLadderType) UnmarshalJSON ¶
func (plt *PriceLadderType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type RaceStatus ¶
type RaceStatus int
const ( RaceStatus_Inactive RaceStatus = iota + 1 RaceStatus_Open RaceStatus_Suspended RaceStatus_Closed )
func (RaceStatus) MarshalJSON ¶
func (rs RaceStatus) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (RaceStatus) String ¶
func (rs RaceStatus) String() string
func (*RaceStatus) UnmarshalJSON ¶
func (rs *RaceStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type RequestMessage ¶
type RequestMessage struct { Op string `json:"op"` ID *uint32 `json:"id,omitempty"` AuthenticationMessage *AuthenticationMessage MarketSubscriptionMessage *MarketSubscriptionMessage OrderSubscriptionMessage *OrderSubscriptionMessage }
func (RequestMessage) MarshalJSON ¶
func (rm RequestMessage) MarshalJSON() ([]byte, error)
MarshalJSON marshals RequestMessage struct
type ResponseMessage ¶
type ResponseMessage struct { Op string `json:"op"` ID *uint32 `json:"id,omitempty"` ConnectionMessage *ConnectionMessage StatusMessage *StatusMessage MarketChangeMessage *MarketChangeMessage OrderChangeMessage *OrderChangeMessage }
func (*ResponseMessage) UnmarshalJSON ¶
func (rm *ResponseMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals ResponseMessage struct
type RunnerChange ¶
type RunnerChange struct { TotalVolume *float64 `json:"tv,omitempty"` BATB [][]float64 `json:"batb,omitempty"` SPB [][]float64 `json:"spb,omitempty"` BDATL [][]float64 `json:"bdatl,omitempty"` TRD [][]float64 `json:"trd,omitempty"` SPF *float64 `json:"spf,omitempty"` LTP *float64 `json:"ltp,omitempty"` ATB [][]float64 `json:"atb,omitempty"` SPL [][]float64 `json:"spl,omitempty"` SPN *float64 `json:"spn,omitempty"` ATL [][]float64 `json:"atl,omitempty"` BATL [][]float64 `json:"batl,omitempty"` ID uint `json:"id,omitempty"` Handicap *float64 `json:"hc,omitempty"` BDATB [][]float64 `json:"bdatb,omitempty"` }
type RunnerDefinition ¶
type RunnerDefinition struct { SortPriority uint `json:"sortPriority"` RemovalDate string `json:"removalDate"` // TODO: time.Time! ID uint `json:"id"` Handicap *float64 `json:"hc,omitempty"` AdjustmentFactor float64 `json:"adjustmentFactor"` BSP float64 `json:"bsp"` Status RunnerStatus `json:"status"` }
type RunnerStatus ¶
type RunnerStatus int
const ( RunnerStatus_Active RunnerStatus = iota + 1 RunnerStatus_Winner RunnerStatus_Loser RunnerStatus_Removed RunnerStatus_RemovedVacant RunnerStatus_Hidden RunnerStatus_Placed )
func (RunnerStatus) MarshalJSON ¶
func (rs RunnerStatus) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (RunnerStatus) String ¶
func (rs RunnerStatus) String() string
func (*RunnerStatus) UnmarshalJSON ¶
func (rs *RunnerStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type SegmentType ¶
type SegmentType int
const ( SegmentType_SegStart SegmentType = iota + 1 SegmentType_Seg SegmentType_SegEnd )
func (SegmentType) MarshalJSON ¶
func (st SegmentType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (SegmentType) String ¶
func (st SegmentType) String() string
func (*SegmentType) UnmarshalJSON ¶
func (st *SegmentType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type StatusCode ¶
type StatusCode int
const ( StatusCode_Success StatusCode = iota + 1 StatusCode_Failure )
func (StatusCode) MarshalJSON ¶
func (sc StatusCode) MarshalJSON() ([]byte, error)
MarshalJSON marshals the enum as a quoted json string
func (StatusCode) String ¶
func (sc StatusCode) String() string
func (*StatusCode) UnmarshalJSON ¶
func (sc *StatusCode) UnmarshalJSON(data []byte) error
UnmarshalJSON unmashals a quoted json string to the enum value
type StatusMessage ¶
type StatusMessage struct { ErrorMessage string `json:"errorMessage,omitempty"` ErrorCode ErrorCode `json:"errorCode,omitempty"` ConnectionID string `json:"connectionId"` ConnectionClosed *bool `json:"connectionClosed"` StatusCode StatusCode `json:"statusCode"` }