Betfair

Provides an API integration for the Betfair spots betting exchange.

Data

Data Types

class SubscriptionStatus ( value , names = None , * , module = None , qualname = None , type = None , start = 1 , boundary = None )

Bases: Enum

Represents a Betfair subscription status.

class InstrumentSearch ( instruments , ts_event , ts_init )

Bases: Data

Represents a Betfair instrument search.

classmethod fully_qualified_name ( type cls ) str

Return the fully qualified name for the Data class.

Returns :

str

References

https://www.python.org/dev/peps/pep-3155/

ts_event

The UNIX timestamp (nanoseconds) when the data event occurred.

Returns :

uint64_t

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns :

uint64_t

class BSPOrderBookDelta

Bases: OrderBookDelta

Represents a Betfair BSP order book delta.

static from_dict ( dict values ) OrderBookDelta

Return an order book delta from the given dict values.

Parameters :

values ( dict [ str , object ] ) – The values for initialization.

Returns :

OrderBookDelta

static to_dict ( OrderBookDelta obj )

Return a dictionary representation of this object.

Returns :

dict[str, object]

action

The order book delta action { ADD , UPDATED , DELETE , CLEAR }.

Returns :

BookAction

book_type

The order book type (L1_TBBO, L2_MBP, L3_MBO).

Returns :

BookType

classmethod fully_qualified_name ( type cls ) str

Return the fully qualified name for the Data class.

Returns :

str

References

https://www.python.org/dev/peps/pep-3155/

instrument_id

The instrument ID for the order book.

Returns :

InstrumentId

order

The order to apply.

Returns :

Order

ts_event

The UNIX timestamp (nanoseconds) when the data event occurred.

Returns :

uint64_t

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns :

uint64_t

update_id

The update ID.

Returns :

uint64

class BetfairTicker ( instrument_id : InstrumentId , ts_event : int , ts_init : int , last_traded_price : Price = None , traded_volume : Quantity = None )

Bases: Ticker

Represents a Betfair ticker.

static from_dict ( dict values ) Ticker

Return a ticker from the given dict values.

Parameters :

values ( dict [ str , object ] ) – The values for initialization.

Returns :

Ticker

classmethod fully_qualified_name ( type cls ) str

Return the fully qualified name for the Data class.

Returns :

str

References

https://www.python.org/dev/peps/pep-3155/

instrument_id

The ticker instrument ID.

Returns :

InstrumentId

static to_dict ( Ticker obj )

Return a dictionary representation of this object.

Returns :

dict[str, object]

ts_event

The UNIX timestamp (nanoseconds) when the data event occurred.

Returns :

uint64_t

ts_init

The UNIX timestamp (nanoseconds) when the object was initialized.

Returns :

uint64_t

Execution

Factories

Parsing

Providers

Sockets

class BetfairStreamClient ( client : BetfairClient , logger_adapter : LoggerAdapter , message_handler , loop : Optional [ AbstractEventLoop ] = None , host : Optional [ str ] = None , port : Optional [ int ] = None , crlf : Optional [ bytes ] = None , encoding : Optional [ str ] = None )

Bases: SocketClient

Provides a streaming client for Betfair .

async connect ( self )
async disconnect ( self )
host

The host for the socket client.

Returns :

str

is_connected

If the socket is connected.

Returns :

bool

port

The port for the socket client.

Returns :

int

async post_connection ( self )

The actions to perform post-connection. i.e. sending further connection messages.

async reconnect ( self )
async send ( self , bytes raw )
ssl

If the socket client is using SSL.

Returns :

bool

async start ( self )
stop ( self )
class BetfairOrderStreamClient ( client : BetfairClient , logger : Logger , message_handler , partition_matched_by_strategy_ref : bool = True , include_overall_position : Optional [ str ] = None , customer_strategy_refs : Optional [ str ] = None , ** kwargs )

Bases: BetfairStreamClient

Provides an order stream client for Betfair .

async post_connection ( self )

The actions to perform post-connection. i.e. sending further connection messages.

async connect ( self )
async disconnect ( self )
host

The host for the socket client.

Returns :

str

is_connected

If the socket is connected.

Returns :

bool

port

The port for the socket client.

Returns :

int

async reconnect ( self )
async send ( self , bytes raw )
ssl

If the socket client is using SSL.

Returns :

bool

async start ( self )
stop ( self )
class BetfairMarketStreamClient ( client : BetfairClient , logger : Logger , message_handler : Callable , ** kwargs )

Bases: BetfairStreamClient

Provides a Betfair market stream client.

async post_connection ( self )

The actions to perform post-connection. i.e. sending further connection messages.

async connect ( self )
async disconnect ( self )
host

The host for the socket client.

Returns :

str

is_connected

If the socket is connected.

Returns :

bool

port

The port for the socket client.

Returns :

int

async reconnect ( self )
async send ( self , bytes raw )
ssl

If the socket client is using SSL.

Returns :

bool

async start ( self )
stop ( self )

Utility