Skip to main content
Version: latest

Betfair

Provides an API integration for the Betfair spots betting exchange.

Client

Common

Config

Data

Data Types

class SubscriptionStatus

Bases: Enum

Represents a Betfair subscription status.

UNSUBSCRIBED = 0

PENDING_STARTUP = 1

RUNNING = 2

SUBSCRIBED = 3

class BSPOrderBookDelta

Bases: OrderBookDelta

static from_batch(batch: RecordBatch) → list[BSPOrderBookDelta]

static to_batch(self: BSPOrderBookDelta) → RecordBatch

classmethod schema() → Schema

action

BookAction

Return the deltas book action {ADD, UPDATE, DELETE, CLEAR}

  • Return type: BookAction
  • Type: OrderBookDelta.action

static capsule_from_list(list items)

static clear(InstrumentId instrument_id, uint64_t sequence, uint64_t ts_event, uint64_t ts_init)

Return an order book delta which acts as an initial CLEAR.

flags

uint8_t

Return the flags for the delta.

  • Return type: uint8_t
  • Type: OrderBookDelta.flags

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.
  • Return type: OrderBookDelta

static from_pyo3(pyo3_delta) → OrderBookDelta

Return a legacy Cython order book delta converted from the given pyo3 Rust object.

  • Parameters: pyo3_delta (nautilus_pyo3.OrderBookDelta) – The pyo3 Rust order book delta to convert from.
  • Return type: OrderBookDelta

static from_pyo3_list(list pyo3_deltas) → list[OrderBookDelta]

Return legacy Cython order book deltas converted from the given pyo3 Rust objects.

  • Parameters: pyo3_deltas (list *[*nautilus_pyo3.OrderBookDelta ]) – The pyo3 Rust order book deltas to convert from.
  • Return type: list[OrderBookDelta]

static from_raw(InstrumentId instrument_id, BookAction action, OrderSide side, int64_t price_raw, uint8_t price_prec, uint64_t size_raw, uint8_t size_prec, uint64_t order_id, uint8_t flags, uint64_t sequence, uint64_t ts_event, uint64_t ts_init) → OrderBookDelta

Return an order book delta from the given raw values.

  • Parameters:
    • instrument_id (InstrumentId) – The trade instrument ID.
    • action (BookAction {ADD, UPDATE, DELETE, CLEAR}) – The order book delta action.
    • side (OrderSide {BUY, SELL}) – The order side.
    • price_raw (int64_t) – The order raw price (as a scaled fixed-point integer).
    • price_prec (uint8_t) – The order price precision.
    • size_raw (uint64_t) – The order raw size (as a scaled fixed-point integer).
    • size_prec (uint8_t) – The order size precision.
    • order_id (uint64_t) – The order ID.
    • flags (uint8_t) – The record flags bit field, indicating event end and data information. A value of zero indicates no flags.
    • sequence (uint64_t) – The unique sequence number for the update. If no sequence number provided in the source data then use a value of zero.
    • ts_event (uint64_t) – UNIX timestamp (nanoseconds) when the tick event occurred.
    • ts_init (uint64_t) – UNIX timestamp (nanoseconds) when the data object was initialized.
  • Return type: OrderBookDelta

classmethod fully_qualified_name(cls) → str

Return the fully qualified name for the Data class.

  • Return type: str

instrument_id

InstrumentId

Return the deltas book instrument ID.

  • Return type: InstrumentId
  • Type: OrderBookDelta.instrument_id

is_add

BookAction

If the deltas book action is an ADD.

  • Return type: bool
  • Type: OrderBookDelta.is_add

is_clear

BookAction

If the deltas book action is a CLEAR.

  • Return type: bool
  • Type: OrderBookDelta.is_clear

is_delete

BookAction

If the deltas book action is a DELETE.

  • Return type: bool
  • Type: OrderBookDelta.is_delete

classmethod is_signal(cls, unicode name=u'') → bool

Determine if the current class is a signal type, optionally checking for a specific signal name.

  • Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal.
  • Returns: True if the class name matches the signal type or the specific signal name, otherwise False.
  • Return type: bool

is_update

BookAction

If the deltas book action is an UPDATE.

  • Return type: bool
  • Type: OrderBookDelta.is_update

static list_from_capsule(capsule) → list[OrderBookDelta]

order

BookOrder | None

Return the deltas book order for the action.

  • Return type: BookOrder
  • Type: OrderBookDelta.order

sequence

uint64_t

Return the sequence number for the delta.

  • Return type: uint64_t
  • Type: OrderBookDelta.sequence

static to_dict(OrderBookDelta obj)

Return a dictionary representation of this object.

  • Return type: dict[str, object]

static to_pyo3_list(list deltas) → list[nautilus_pyo3.OrderBookDelta]

Return pyo3 Rust order book deltas converted from the given legacy Cython objects.

  • Parameters: pyo3_deltas (list [OrderBookDelta ]) – The pyo3 Rust order book deltas to convert from.
  • Return type: list[nautilus_pyo3.OrderBookDelta]

ts_event

int

UNIX timestamp (nanoseconds) when the data event occurred.

  • Return type: int
  • Type: OrderBookDelta.ts_event

ts_init

int

UNIX timestamp (nanoseconds) when the object was initialized.

  • Return type: int
  • Type: OrderBookDelta.ts_init

class BetfairTicker

Bases: Data

Represents a Betfair ticker.

property ts_event : int

UNIX timestamp (nanoseconds) when the data event occurred.

  • Return type: int

property ts_init : int

UNIX timestamp (nanoseconds) when the object was initialized.

  • Return type: int

classmethod schema()

classmethod from_dict(values: dict)

static to_dict(self: BetfairTicker)

classmethod fully_qualified_name(cls) → str

Return the fully qualified name for the Data class.

  • Return type: str

classmethod is_signal(cls, unicode name=u'') → bool

Determine if the current class is a signal type, optionally checking for a specific signal name.

  • Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal.
  • Returns: True if the class name matches the signal type or the specific signal name, otherwise False.
  • Return type: bool

class BetfairStartingPrice

Bases: Data

Represents the realised Betfair Starting Price.

property ts_event : int

UNIX timestamp (nanoseconds) when the data event occurred.

  • Return type: int

property ts_init : int

UNIX timestamp (nanoseconds) when the object was initialized.

  • Return type: int

classmethod schema()

classmethod from_dict(values: dict)

static to_dict(self)

classmethod fully_qualified_name(cls) → str

Return the fully qualified name for the Data class.

  • Return type: str

classmethod is_signal(cls, unicode name=u'') → bool

Determine if the current class is a signal type, optionally checking for a specific signal name.

  • Parameters: name (str , optional) – The specific signal name to check. If name not provided or if an empty string is passed, the method checks whether the class name indicates a general signal type. If name is provided, the method checks if the class name corresponds to that specific signal.
  • Returns: True if the class name matches the signal type or the specific signal name, otherwise False.
  • Return type: bool

Execution

Factories

OrderBook

Providers

Sockets