gofair

package module
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: 9 Imported by: 0

README

gofair

Lightweight golang wrapper for Betfair API-NG

setup

In order to connect to the Betfair API you will need an App Key, SSL Certificates and a username/password.

App Key

Follow these instructions to get your app key, you can either use a delayed or live key.

SSL certificates

Follow these instructions to set up your SSL certificates. Save your .ctr and .key files to a local directory. The default directory where the library is looking for the keys is '/certs' but you can specify any other directory.

examples

A set of examples on how to use this library are available in the examples directory. You will need to supply a valid config.json in order to interact with the Exchange see examples/config_template.json for an example configuration.

streaming

gofair makes extensive use of channels for handling data returned by the Stream API. This provides the user with a reasonable amount of flexibility as you have both synchronous and asynchronous options (see examples/stream-sync and examples/stream-async).

use

config := &gofair.Config{
		"username",
		"password",
		"appKey",
		"/certs/client-2048.crt",
		"/certs/client-2048.key",
		"",
}

trading, err := gofair.NewClient(config)
if err != nil {
    panic(err)
}


fmt.Println(trading.Login())
fmt.Println(trading.KeepAlive())
fmt.Println(trading.Logout())

filter := new(gofair.MarketFilter)
event_types, err := trading.Betting.ListEventTypes(filter)

fmt.Println(event_types)

Documentation

Index

Constants

View Source
const (
	MinimumStakeSizeGBP = 1.00
)

Variables

View Source
var BetTargetTypeEnum = struct {
	BackersProfit,
	Payout BetTargetType
}{
	BackersProfit: "BACKERS_PROFIT",
	Payout:        "PAYOUT",
}
View Source
var Endpoints = struct {
	Login,
	Identity,
	Betting,
	Account,
	Navigation string
}{
	Login:      "https://identitysso-cert.betfair.it/api/",
	Identity:   "https://identitysso.betfair.com/api/",
	Betting:    "https://api.betfair.com/exchange/betting/rest/v1.0/",
	Account:    "https://api.betfair.com/exchange/account/rest/v1.0/",
	Navigation: "https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json",
}

Endpoints contains all the Betfair Exchange API endpoints.

View Source
var ExecutionReportErrorCodeEnum = struct {
	ErrorInMatcher,
	ProcessedWithErrors,
	BetActionError,
	InvalidAccountState,
	InvalidWalletStatus,
	InsufficientFunds,
	LossLimitExceeded,
	MarketSuspended,
	MarketNotOpenForBetting,
	DuplicateTransaction,
	InvalidOrder,
	InvalidMarketID,
	PermissionDenied,
	DuplicateBetIDs,
	NoActionRequired,
	ServiceUnavailable,
	RejectedByRegulator,
	NoChasing,
	RegulatorIsNotAvailable,
	TooManyInstructions,
	InvalidMarketVersion,
	InvalidProfitRatio ExecutionReportErrorCode
}{
	ErrorInMatcher:          "ERROR_IN_MATCHER",
	ProcessedWithErrors:     "PROCESSED_WITH_ERRORS",
	BetActionError:          "BET_ACTION_ERROR",
	InvalidAccountState:     "INVALID_ACCOUNT_STATE",
	InvalidWalletStatus:     "INVALID_WALLET_STATUS",
	InsufficientFunds:       "INSUFFICIENT_FUNDS",
	LossLimitExceeded:       "LOSS_LIMIT_EXCEEDED",
	MarketSuspended:         "MARKET_SUSPENDED",
	MarketNotOpenForBetting: "MARKET_NOT_OPEN_FOR_BETTING",
	DuplicateTransaction:    "DUPLICATE_TRANSACTION",
	InvalidOrder:            "INVALID_ORDER",
	InvalidMarketID:         "INVALID_MARKET_ID",
	PermissionDenied:        "PERMISSION_DENIED",
	DuplicateBetIDs:         "DUPLICATE_BETIDS",
	NoActionRequired:        "NO_ACTION_REQUIRED",
	ServiceUnavailable:      "SERVICE_UNAVAILABLE",
	RejectedByRegulator:     "REJECTED_BY_REGULATOR",
	NoChasing:               "NO_CHASING",
	RegulatorIsNotAvailable: "REGULATOR_IS_NOT_AVAILABLE",
	TooManyInstructions:     "TOO_MANY_INSTRUCTIONS",
	InvalidMarketVersion:    "INVALID_MARKET_VERSION",
	InvalidProfitRatio:      "INVALID_PROFIT_RATIO",
}

ExecutionReportErrorCodeEnum describes the potential errors contained within a PlaceExecutionReport.

View Source
var ExecutionReportStatusEnum = struct {
	Success, Failure, ProcessedWithErrors, Timeout ExecutionReportStatus
}{
	Success:             "SUCCESS",
	Failure:             "FAILURE",
	ProcessedWithErrors: "PROCESSED_WITH_ERRORS",
	Timeout:             "TIMEOUT",
}

ExecutionReportStatusEnum describes the outcome of placing an order.

View Source
var InstructionReportStatusEnum = struct {
	Success, Failure, Timeout InstructionReportStatus
}{
	Success: "SUCCESS",
	Failure: "FAILURE",
	Timeout: "TIMEOUT",
}

InstructionReportStatusEnum describes the outcome of a particular instruction being submitted.

View Source
var MarketStatusEnum = struct {
	Inactive, Open, Suspended, Closed MarketStatus
}{
	Inactive:  "INACTIVE",
	Open:      "OPEN",
	Suspended: "SUSPENDED",
	Closed:    "CLOSED",
}

MarketStatusEnum describes the status of the market, for example OPEN, SUSPENDED, CLOSED (settled), etc.

View Source
var MatchProjectionEnum = struct {
	NoRollup, RolledUpByPrice, RolledUpByAvgPrice MatchProjection
}{
	NoRollup:           "NO_ROLLUP",
	RolledUpByPrice:    "ROLLED_UP_BY_PRICE",
	RolledUpByAvgPrice: "ROLLED_UP_BY_AVG_PRICE",
}

MatchProjectionEnum describes the matches you want to receive in the response.

View Source
var OrderProjectionEnum = struct {
	All, Executable, ExecutionComplete OrderProjection
}{
	All:               "ALL",
	Executable:        "EXECUTABLE",
	ExecutionComplete: "EXECUTION_COMPLETE",
}

OrderProjectionEnum describes the orders you want to receive in the response.

View Source
var OrderStatusEnum = struct {
	Pending, ExecutionComplete, Executable, Expired OrderStatus
}{
	Pending:           "PENDING",
	ExecutionComplete: "EXECUTION_COMPLETE",
	Executable:        "EXECUTABLE",
	Expired:           "EXPIRED",
}

OrderStatusEnum should generally be either EXECUTABLE (an unmatched amount remains) or EXECUTION_COMPLETE (no unmatched amount remains).

View Source
var OrderTypeEnum = struct {
	Limit, LimitOnClose, MarketOnClose OrderType
}{
	Limit:         "LIMIT",
	LimitOnClose:  "LIMIT_ON_CLOSE",
	MarketOnClose: "MARKET_ON_CLOSE",
}

OrderTypeEnum describes the BSP Order type.

View Source
var PersistenceTypeEnum = struct {
	Lapse, Persist, MarketOnClose PersistenceType
}{
	Lapse:         "LAPSE",
	Persist:       "PERSIST",
	MarketOnClose: "MARKET_ON_CLOSE",
}

PersistenceTypeEnum describes what to do with the order at turn-in-play.

View Source
var PriceDataEnum = struct {
	SPAvailable, SPTraded, ExBestOffers, ExAllOffers, ExTraded PriceData
}{
	SPAvailable:  "SP_AVAILABLE",
	SPTraded:     "SP_TRADED",
	ExBestOffers: "EX_BEST_OFFERS",
	ExAllOffers:  "EX_ALL_OFFERS",
	ExTraded:     "EX_TRADED",
}

PriceDataEnum describes the basic price data you want to receive in the response.

View Source
var SideEnum = struct {
	Back, Lay Side
}{
	Back: "BACK",
	Lay:  "LAY",
}

SideEnum indicates if the bet is a Back or a Lay.

View Source
var TimeInForceEnum = struct {
	FillOrKill TimeInForce
}{
	FillOrKill: "FILL_OR_KILL",
}
View Source
var WeightEnum = struct {
	MaxWeight,
	MarketDescription,
	RunnerDescription,
	Event,
	EventType,
	Competition,
	RunnerMetadata,
	MarketStartTime,
	NotSet,
	SPAvailable,
	SPTraded,
	ExBestOffers,
	ExAllOffers,
	ExTraded,
	ExBestOffersAndExTraded,
	ExAllOffersAndExTraded,
	NotApplicable WeightConstant
}{
	MaxWeight:               200,
	MarketDescription:       1,
	RunnerDescription:       1,
	Event:                   0,
	EventType:               0,
	Competition:             0,
	RunnerMetadata:          1,
	MarketStartTime:         0,
	NotSet:                  2,
	SPAvailable:             3,
	SPTraded:                7,
	ExBestOffers:            5,
	ExAllOffers:             17,
	ExTraded:                17,
	ExBestOffersAndExTraded: 20,
	ExAllOffersAndExTraded:  32,
	NotApplicable:           4,
}

WeightEnum is a measure used by the Betfair Exchange API to describe the relative amount of data a particular type of request is expected to return.

Functions

This section is empty.

Types

type Account

type Account struct {
	Client *Client
}

Account object

func (*Account) GetAccountFunds

func (a *Account) GetAccountFunds() (AccountFundsResponse, error)

type AccountFundsResponse

type AccountFundsResponse struct {
	AvailableToBetBalance float64 `json:"availableToBetBalance"`
	Exposure              float64 `json:"exposure"`
	RetainedCommission    float64 `json:"retainedCommission"`
	ExposureLimit         float64 `json:"exposureLimit"`
	DiscountRate          float64 `json:"discountRate"`
	PointsBalance         int     `json:"pointsBalance"`
}

AccountFundsResponse contains data about the availability of funds.

type BetTargetType

type BetTargetType string

type Betting

type Betting struct {
	Client *Client
}

Betting object

func (*Betting) CancelOrders

func (b *Betting) CancelOrders(marketID string, cancelInstructions []CancelInstruction) (CancelExecutionReport, error)

CancelOrders allows the user to cancel all bets OR cancel all bets on a market OR fully or partially cancel particular orders on a market. Only LIMIT orders can be cancelled or partially cancelled once placed.

func (*Betting) ListCompetitions

func (b *Betting) ListCompetitions(filter MarketFilter) ([]CompetitionResult, error)

ListCompetitions returns a list of Competitions (i.e., World Cup 2013) associated with the markets selected by the MarketFilter. Currently only Football markets have an associated competition.

func (*Betting) ListCountries

func (b *Betting) ListCountries(filter MarketFilter) ([]CountryResult, error)

ListCountries returns a list of Countries associated with the markets selected by the MarketFilter.

func (*Betting) ListCurrentOrders

func (b *Betting) ListCurrentOrders(betIDs []string, marketIDs []string, orderProjection OrderProjection) (CurrentOrderSummaryReport, error)

func (*Betting) ListEventTypes

func (b *Betting) ListEventTypes(filter MarketFilter) ([]EventTypeResult, error)

ListEventTypes returns a list of Event Types (i.e. Sports) associated with the markets selected by the MarketFilter.

func (*Betting) ListEvents

func (b *Betting) ListEvents(filter MarketFilter) ([]EventResult, error)

ListEvents returns a list of Events (i.e, Reading vs. Man United) associated with the markets selected by the MarketFilter.

func (*Betting) ListMarketBook

func (b *Betting) ListMarketBook(marketIDs []string, displayOrders bool) ([]MarketBook, error)

ListMarketBook returns a list of dynamic data about markets. Dynamic data includes prices, the status of the market, the status of selections, the traded volume, and the status of any orders you have placed in the market.

func (*Betting) ListMarketCatalogue

func (b *Betting) ListMarketCatalogue(filter MarketFilter, marketProjection []string, sort string, maxResults int) ([]MarketCatalogue, error)

ListMarketCatalogue returns a list of information about published (ACTIVE/SUSPENDED) markets that does not change (or changes very rarely). You use listMarketCatalogue to retrieve the name of the market, the names of selections and other information about markets. Market Data request Limits apply to requests made to listMarketCatalogue.

func (*Betting) ListMarketProfitAndLoss

func (b *Betting) ListMarketProfitAndLoss(marketIDs []string) ([]MarketProfitAndLoss, error)

ListMarketProfitAndLoss retrieves profit and loss for a given list of OPEN markets. The values are calculated using matched bets and optionally settled bets. Only odds (MarketBettingType = ODDS) markets are implemented, markets of other types are silently ignored.

func (*Betting) ListMarketTypes

func (b *Betting) ListMarketTypes(filter MarketFilter) ([]MarketTypeResult, error)

ListMarketTypes returns a list of market types (i.e. MATCH_ODDS, NEXT_GOAL) associated with the markets selected by the MarketFilter. The market types are always the same, regardless of locale.

func (*Betting) ListRunnerBook

func (b *Betting) ListRunnerBook(
	marketId string,
	selectionId int,
	handicap float64,
	priceProjection PriceProjection,
	orderProjection OrderProjection,
	matchProjection MatchProjection,
	includeOverallPosition bool,
	partitionMatchedByStrategyRef bool,
	customerStrategyRefs []string,
	currencyCode string,
	locale string,
	matchedSince time.Time,
	betIds []string,
) ([]MarketBook, error)

func (*Betting) ListTimeRanges

func (b *Betting) ListTimeRanges(filter MarketFilter, granularity string) ([]TimeRangeResult, error)

ListTimeRanges returns a list of time ranges in the granularity specified in the request (i.e. 3PM to 4PM, Aug 14th to Aug 15th) associated with the markets selected by the MarketFilter.

func (*Betting) ListVenues

func (b *Betting) ListVenues(filter MarketFilter) ([]VenueResult, error)

ListVenues returns a list of Venues (i.e. Cheltenham, Ascot) associated with the markets selected by the MarketFilter. Currently, only Horse Racing markets are associated with a Venue.

func (*Betting) PlaceOrders

func (b *Betting) PlaceOrders(marketID string, placeInstructions []PlaceInstruction) (PlaceExecutionReport, error)

PlaceOrders allows new orders to be submitted into a market. Please note that additional bet sizing rules apply to bets placed into the Italian Exchange.

type CancelExecutionReport

type CancelExecutionReport struct {
	CustomerRef        string                    `json:"customerRef"`
	Status             string                    `json:"status"`
	ErrorCode          string                    `json:"errorCode"`
	MarketID           string                    `json:"marketId"`
	InstructionReports []CancelInstructionReport `json:"instructionReports"`
}

CancelExecutionReport is returned by a call to cancelOrders. (https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/cancelOrders)

type CancelInstruction

type CancelInstruction struct {
	BetID         string  `json:"betId"`
	SizeReduction float32 `json:"sizeReduction,omitempty"`
}

CancelInstruction is an Instruction to fully or partially cancel an order (only applies to LIMIT orders). The CancelInstruction report won't be returned for marketId level cancel instructions.

type CancelInstructionReport

type CancelInstructionReport struct {
	Status        string            `json:"status"`
	ErrorCode     string            `json:"errorCode"`
	Instruction   CancelInstruction `json:"instruction"`
	SizeCancelled float32           `json:"sizeCancelled"`
	CancelledDate time.Time         `json:"cancelledDate"`
}

CancelInstructionReport is a response to a CancelInstruction.

type Client

type Client struct {
	Config       *config.Config
	Session      *Session
	Certificates *tls.Certificate
	Betting      *Betting
	Account      *Account
	Streaming    *streaming.Stream
}

Client object

func NewClient

func NewClient(cfg *config.Config) (*Client, error)

NewClient creates a new Betfair client.

func (*Client) KeepAlive

func (c *Client) KeepAlive() (KeepAliveResult, error)

func (*Client) Login

func (c *Client) Login() (LoginResult, error)

func (*Client) Logout

func (c *Client) Logout() (LogoutResult, error)

Logout from the current session.

func (*Client) SessionExpired

func (c *Client) SessionExpired() bool

SessionExpired returns True if client not logged in or expired, betfair requires keep alive every 4hrs (20mins ITA)

type Competition

type Competition struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Competition describes the competition that a fixture is associated with e.g. English Premier League.

type CompetitionResult

type CompetitionResult struct {
	MarketCount       int         `json:"marketCount"`
	CompetitionRegion string      `json:"competitionRegion"`
	Competition       Competition `json:"competition"`
}

CompetitionResults is returned by a call to listCompetitions. (https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/listCompetitions)

type CountryResult

type CountryResult struct {
	MarketCount int    `json:"marketCount"`
	CountryCode string `json:"countryCode"`
}

CountryResult is returned by a call to listCountries. (https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/listCountries)

type CurrentOrderSummary

type CurrentOrderSummary struct {
	BetID               string          `json:"betId"`
	MarketID            string          `json:"marketId"`
	SelectionID         int             `json:"selectionId"`
	Handicap            float64         `json:"handicap"`
	PriceSize           PriceSize       `json:"priceSize"`
	BSPLiability        float64         `json:"bspLiability"`
	Side                Side            `json:"side"`
	Status              OrderStatus     `json:"status"`
	PersistenceType     PersistenceType `json:"persistenceType"`
	OrderType           OrderType       `json:"orderType"`
	PlacedDate          time.Time       `json:"placedDate"`
	MatchedDate         time.Time       `json:"matchedDate"`
	AveragePriceMatched float64         `json:"averagePriceMatched,omitempty"`
	SizeMatched         float64         `json:"sizeMatched,omitempty"`
	SizeRemaining       float64         `json:"sizeRemaining,omitempty"`
	SizeLapsed          float64         `json:"sizeLapsed,omitempty"`
	SizeCancelled       float64         `json:"sizeCancelled,omitempty"`
	SizeVoided          float64         `json:"sizeVoided,omitempty"`
	RegulatorAuthCode   string          `json:"regulatorAuthCode,omitempty"`
	RegulatorCode       string          `json:"regulatorCode,omitempty"`
	CustomerOrderRef    string          `json:"customerOrderRef,omitempty"`
	CustomerStrategyRef string          `json:"customerOrderStrategy,omitempty"`
}

CurrentOrderSummary contains data about a current order.

type CurrentOrderSummaryReport

type CurrentOrderSummaryReport struct {
	CurrentOrders []CurrentOrderSummary `json:"currentOrders"`
	MoreAvailable bool                  `json:"moreAvailable"`
}

CurrentOrderSummaryReport is container representing search results for current orders.

type Event

type Event struct {
	ID          string `json:"id"`
	OpenDate    string `json:"openDate"`
	TimeZone    string `json:"timezone"`
	CountryCode string `json:"countryCode"`
	Name        string `json:"name"`
	Venue       string `json:"venue"`
}

Event describes an event that could be a fixture within a competition e.g. Manchester United vs. Chelsea.

type EventResult

type EventResult struct {
	MarketCount int   `json:"marketCount"`
	Event       Event `json:"event"`
}

EventResult is returned by a call to listEvents. (https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/listEvents)

type EventType

type EventType struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

EventType describes the type of event e.g. Football.

type EventTypeResult

type EventTypeResult struct {
	MarketCount int       `json:"marketCount"`
	EventType   EventType `json:"eventType"`
}

EventTypeResult is returned by a call to listEventTypes. (https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/listEventTypes)

type ExBestOffersOverrides

type ExBestOffersOverrides struct {
	BestPricesDepth          int     `json:"bestPricesDepth,omitempty"`
	RollupModel              string  `json:"rollupModel,omitempty"`
	RollupLimit              int     `json:"rollupLimit,omitempty"`
	RollupLiabilityThreshold float32 `json:"rollupLiabilityThreshold,omitempty"`
	RollupLiabilityFactor    int     `json:"rollupLiabilityFactor,omitempty"`
}

ExBestOffersOverrides contains options to alter the default representation of best offer prices.

type ExchangePrices

type ExchangePrices struct {
	AvailableToBack []PriceSize `json:"availableToBack"`
	AvailableToLay  []PriceSize `json:"availableToLay"`
	TradedVolume    []PriceSize `json:"tradedVolume"`
}

ExchangePrices contains the prices that are available on the Exchange.

type ExecutionReportErrorCode

type ExecutionReportErrorCode string

type ExecutionReportStatus

type ExecutionReportStatus string

type InstructionReportStatus

type InstructionReportStatus string

type KeepAliveResult

type KeepAliveResult struct {
	SessionToken string `json:"sessionToken"`
	Token        string `json:"token"`
	Status       string `json:"status"`
	Error        string `json:"error"`
}

type KeyLineDescription

type KeyLineDescription struct {
	KeyLine []KeyLineSelection `json:"keyLine"`
}

KeyLineDescription provides a description of a markets key line for valid market types.

type KeyLineSelection

type KeyLineSelection struct {
	SelectionID int     `json:"selectionId"`
	Handicap    float32 `json:"handicap"`
}

KeyLineSelection provides a description of a markets key line selection, comprising the selectionId and handicap of the team it is applied to.

type LimitOnCloseOrder

type LimitOnCloseOrder struct {
	Liability float32 `json:"liability,omitempty"`
	Price     float32 `json:"price,omitempty"`
}

LimitOnCloseOrder is to be used to place a new LIMIT_ON_CLOSE bet.

type LimitOrder

type LimitOrder struct {
	Size            float32         `json:"size,omitempty"`
	Price           float32         `json:"price,omitempty"`
	PersistenceType PersistenceType `json:"persistenceType,omitempty"`
	TimeInForce     TimeInForce     `json:"timeInForce,omitempty"`
	MinFillSize     float32         `json:"minFillSize,omitempty"`
	BetTargetType   BetTargetType   `json:"betTargetType,omitempty"`
	BetTargetSize   float32         `json:"betTargetSize,omitempty"`
}

LimitOrder is a simple exchange bet for immediate execution.

type LoginResult

type LoginResult struct {
	LoginStatus  string `json:"loginStatus"`
	SessionToken string `json:"sessionToken"`
}

type LogoutResult

type LogoutResult struct {
	Token   string `json:"token"`
	Product string `json:"product"`
	Status  string `json:"status"`
	Error   string `json:"error"`
}

type MarketBook

type MarketBook struct {
	MarketID              string             `json:"marketId"`
	IsMarketDataDelayed   bool               `json:"isMarketDataDelayed"`
	Status                string             `json:"status"`
	BetDelay              int                `json:"betDelay"`
	BSPReconciled         bool               `json:"bspReconciled"`
	Complete              bool               `json:"complete"`
	InPlay                bool               `json:"inplay"`
	NumberOfWinners       int                `json:"numberOfWinners"`
	NumberOfRunners       int                `json:"numberOfRunners"`
	NumberOfActiveRunners int                `json:"numberOfActiveRunners"`
	LastMatchTime         time.Time          `json:"lastMatchTime"`
	TotalMatched          float32            `json:"totalMatched"`
	TotalAvailable        float32            `json:"totalAvailable"`
	CrossMatching         bool               `json:"crossMatching"`
	RunnersVoidable       bool               `json:"runnersVoidable"`
	Version               int64              `json:"version"`
	Runners               []Runner           `json:"runners"`
	KeyLineDescription    KeyLineDescription `json:"keyLineDescription"`
}

MarketBook holds the dynamic data in a market.

type MarketCatalogue

type MarketCatalogue struct {
	MarketID                   string                     `json:"marketId"`
	MarketName                 string                     `json:"marketName"`
	TotalMatched               float32                    `json:"totalMatched"`
	MarketStartTime            time.Time                  `json:"marketStartTime"`
	Competition                Competition                `json:"competition"`
	Event                      Event                      `json:"event"`
	EventType                  EventType                  `json:"eventType"`
	MarketCatalogueDescription MarketCatalogueDescription `json:"description"`
	Runners                    []RunnerCatalogue          `json:"runners"`
}

MarketCatalogue holds the static data in a market.

type MarketCatalogueDescription

type MarketCatalogueDescription struct {
	BettingType        string    `json:"bettingType"`
	BSPMarket          bool      `json:"bspMarket"`
	DiscountAllowed    bool      `json:"discountAllowed"`
	MarketBaseRate     float32   `json:"marketBaseRate"`
	MarketTime         time.Time `json:"marketTime"`
	MarketType         string    `json:"marketType"`
	PersistenceEnabled bool      `json:"persistenceEnabled"`
	Regulator          string    `json:"regulator"`
	Rules              string    `json:"rules"`
	RulesHasDate       bool      `json:"rulesHasDate"`
	SuspendDate        time.Time `json:"suspendTime"`
	TurnInPlayEnabled  bool      `json:"turnInPlayEnabled"`
	Wallet             string    `json:"wallet"`
	EachWayDivisor     float32   `json:"eachWayDivisor"`
	Clarifications     string    `json:"clarifications"`
}

type MarketDataFilter

type MarketDataFilter struct {
	Fields       []string `json:"fields"`
	LadderLevels int64    `json:"ladderLevels"`
}

type MarketFilter

type MarketFilter struct {
	TextQuery          string           `json:"textQuery,omitempty"`
	EventTypeIds       []string         `json:"eventTypeIds,omitempty"`
	MarketCountries    []string         `json:"marketCountries,omitempty"`
	MarketIds          []string         `json:"marketIds,omitempty"`
	EventIds           []string         `json:"eventIds,omitempty"`
	CompetitionIds     []string         `json:"competitionIds,omitempty"`
	BSPOnly            bool             `json:"bspOnly,omitempty"`
	TurnInPlayEnabled  bool             `json:"turnInPLayEnabled,omitempty"`
	InPlayOnly         bool             `json:"inPlayOnly,omitempty"`
	MarketBettingTypes []string         `json:"marketBettingTypes,omitempty"`
	MarketTypeCodes    []string         `json:"marketTypeCodes,omitempty"`
	MarketStartTime    *TimeRangeFilter `json:"marketStartTime,omitempty"`
	WithOrders         string           `json:"withOrders,omitempty"`
}

MarketFilter is the filter to select desired markets. All markets that match the criteria in the filter are selected.

type MarketOnCloseOrder

type MarketOnCloseOrder struct {
	Liability float32 `json:"liability,omitempty"`
}

MarketCloseOrder is to be used to place a MARKET_ON_CLOSE bet.

type MarketProfitAndLoss

type MarketProfitAndLoss struct {
	MarketID          string                `json:"marketId"`
	CommissionApplied float32               `json:"commissionApplied"`
	ProfitAndLosses   []RunnerProfitAndLoss `json:"profitAndLosses"`
}

MarketProfitAndLoss contains changes in winnings depending on the performance of selections associated with a given market.

type MarketStatus

type MarketStatus string

type MarketTypeResult

type MarketTypeResult struct {
	MarketCount int    `json:"marketCount"`
	MarketType  string `json:"marketType"`
}

MarketTypeResult is returned by a call to listMarketTypes. (https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/listMarketTypes)

type Match

type Match struct {
	BetID     string    `json:"betId"`
	MatchID   string    `json:"matchId"`
	Side      Side      `json:"side"`
	Price     float32   `json:"price"`
	Size      float32   `json:"size"`
	MatchDate time.Time `json:"matchDate"`
}

Match contains data for an individual bet or rollup by price or avg price. Rollup depends on the requested MatchProjection.

type MatchProjection

type MatchProjection string

type Order

type Order struct {
	BetID               string    `json:"betId"`
	OrderType           string    `json:"orderType"`
	Status              string    `json:"status"`
	PersistenceType     string    `json:"persistenceType"`
	Side                string    `json:"side"`
	Price               float32   `json:"price"`
	Size                float32   `json:"size"`
	BSPLiability        float32   `json:"bspLiability"`
	PlacedDate          time.Time `json:"placedDate"`
	AvgPriceMatched     float32   `json:"avgPriceMatched"`
	SizeMatched         float32   `json:"sizeMatched"`
	SizeRemaining       float32   `json:"sizeRemaining"`
	SizeLapsed          float32   `json:"sizeLapsed"`
	SizeCancelled       float32   `json:"sizeCancelled"`
	SizeVoided          float32   `json:"sizeVoided"`
	CustomerOrderRef    string    `json:"customerOrderRef"`
	CustomerStrategyRef string    `json:"customerStrategyRef"`
}

Order contains a range of information associated with placing an Order on the Exchange.

type OrderProjection

type OrderProjection string

type OrderStatus

type OrderStatus string

type OrderType

type OrderType string

type PersistenceType

type PersistenceType string

type PlaceExecutionReport

type PlaceExecutionReport struct {
	CustomerRef        string                   `json:"customerRef"`
	Status             ExecutionReportStatus    `json:"status"`
	ErrorCode          ExecutionReportErrorCode `json:"errorCode"`
	MarketID           string                   `json:"marketId"`
	InstructionReports []PlaceInstructionReport `json:"instructionReports"`
}

PlaceExecutionReport is returned by a call to placeOrders. (https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/placeOrders)

type PlaceInstruction

type PlaceInstruction struct {
	OrderType          OrderType           `json:"orderType,omitempty"`
	SelectionID        int                 `json:"selectionId,omitempty"`
	Handicap           float32             `json:"handicap"`
	Side               Side                `json:"side,omitempty"`
	LimitOrder         LimitOrder          `json:"limitOrder,omitempty"`
	LimitOnCloseOrder  *LimitOnCloseOrder  `json:"limitOnCloseOrder,omitempty"`
	MarketOnCloseOrder *MarketOnCloseOrder `json:"marketOnCloseOrder,omitempty"`
	CustomerOrderRef   string              `json:"customerOrderRef,omitempty"`
}

PlaceInstruction contains data required to place a new order.

type PlaceInstructionReport

type PlaceInstructionReport struct {
	Status              InstructionReportStatus `json:"status"`
	ErrorCode           string                  `json:"errorCode"`
	OrderStatus         OrderStatus             `json:"orderStatus"`
	Instruction         PlaceInstruction        `json:"instruction"`
	BetID               string                  `json:"betId"`
	PlacedDate          time.Time               `json:"placedDate"`
	AveragePriceMatched float32                 `json:"averagePriceMatched"`
	SizeMatched         float32                 `json:"sizeMatched"`
}

PlaceInstructionReport is a response to a PlaceInstruction.

type PriceData

type PriceData string

type PriceProjection

type PriceProjection struct {
	PriceData             []PriceData           `json:"priceData,omitempty"`
	ExBestOffersOverrides ExBestOffersOverrides `json:"exBestOffersOverrides,omitempty"`
	Virtualise            bool                  `json:"virtualise"`
	RollOverStakes        bool                  `json:"rolloverStakes"`
}

PriceProjection allows the user to specify selection criteria for returning price data.

type PriceSize

type PriceSize struct {
	Price float32 `json:"price"`
	Size  float32 `json:"size"`
}

PriceSize contains the Order Price (e.g. 1.51) and the Size of the Order (the amount staked).

type Runner

type Runner struct {
	SelectionID       int                `json:"selectionId"`
	Handicap          float32            `json:"handicap"`
	Status            string             `json:"status"`
	AdjustmentFactor  float32            `json:"adjustmentFactor"`
	LastPriceTraded   float32            `json:"lastPriceTraded"`
	TotalMatched      float32            `json:"totalMatched"`
	RemovalDate       time.Time          `json:"removalDate"`
	StartingPrices    StartingPrices     `json:"sp"`
	ExchangePrices    ExchangePrices     `json:"ex"`
	Orders            []Order            `json:"orders"`
	Matches           []Match            `json:"matches"`
	MatchesByStrategy map[string][]Match `json:"matchesByStrategy"`
}

Runner contains dynamic data about a runner for a given market.

type RunnerCatalogue

type RunnerCatalogue struct {
	SelectionID  int     `json:"selectionId"`
	RunnerName   string  `json:"runnerName"`
	SortPriority int     `json:"sortPriority"`
	Handicap     float32 `json:"handicap"`
}

RunnerCatalogue contains information about a runner for a given market.

type RunnerProfitAndLoss

type RunnerProfitAndLoss struct {
	SelectionID int     `json:"selectionId"`
	IfWin       float32 `json:"ifWin"`
	IfLose      float32 `json:"ifLose"`
	IfPlace     float32 `json:"ifPlace"`
}

RunnerProfitAndLoss contains potential changes in winnings in the event of a particular selection winning, losing or placing.

type Session

type Session struct {
	SessionToken string
	LoginTime    time.Time
}

type Side

type Side string

Side is the type associated with strings contained in the Side struct.

type StartingPrices

type StartingPrices struct {
	NearPrice         float32     `json:"nearPrice"`
	FarPrice          float32     `json:"farPrice"`
	BackStakeTaken    []PriceSize `json:"backStakeTaken"`
	LayLiabilityTaken []PriceSize `json:"layLiabilityTaken"`
	ActualSP          float32     `json:"actualSP"`
}

StartingPrices contains the Betfair Starting Prices (BSP) for a given runner.

type TimeInForce

type TimeInForce string

type TimeRange

type TimeRange struct {
	From time.Time `json:"from"`
	To   time.Time `json:"to"`
}

TimeRange specifies a period of time by providing 'to' and 'from' values.

type TimeRangeFilter

type TimeRangeFilter struct {
	From string `json:"from,omitempty"`
	To   string `json:"to,omitempty"`
}

type TimeRangeResult

type TimeRangeResult struct {
	MarketCount int       `json:"marketCount"`
	TimeRange   TimeRange `json:"timeRange"`
}

TimeRangeResult is returned by a call to listTimeRanges. (https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/listTimeRanges)

type VenueResult

type VenueResult struct {
	MarketCount int    `json:"marketCount"`
	Venue       string `json:"venue"`
}

VenueResult is returned by a call to listVenues. (https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/listVenues)

type WeightConstant

type WeightConstant int

WeightConstant should be the type specified for const values relating to request limit calculations https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/Market+Data+Request+Limits

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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