blpapi.SubscriptionList

class blpapi.SubscriptionList

A list of subscriptions.

Contains a list of subscriptions used when subscribing and unsubscribing.

A SubscriptionList is used when calling Session.subscribe(), Session.resubscribe() and Session.unsubscribe(). The entries can be constructed in a variety of ways.

The two important elements when creating a subscription are:

  • Subscription string: A subscription string represents a topic whose updates user is interested in.

  • CorrelationId: the unique identifier to tag all data associated with this subscription.

The following table describes how various operations use the above elements:

OPERATION

SUBSCRIPTION STRING

CORRELATION ID

subscribe

Used to specify the
topic to subscribe to.
Identifier for the
subscription. If
uninitialized
correlationid was
specified an internally
generated correlationId
will be set for the
subscription.

resubscribe

Used to specify the new
topic to which the
subscription should be
modified to.
Identifier of the
subscription which
needs to be modified.

unsubscribe

NOT USED

Identifier of the
subscription which
needs to be canceled.
__init__()

Create an empty SubscriptionList.

add(topic, fields=None, options=None, correlationId=None)

Add the specified topic to this SubscriptionList.

Parameters
  • topic (str) – The topic to subscribe to

  • fields (str or [str]) – List of fields to subscribe to

  • options (str or [str] or dict) – List of options

  • correlationId (CorrelationId) – Correlation id to associate with the subscription

Add the specified topic, with the optionally specified fields and the options to this SubscriptionList, associating the optionally specified correlationId with it. The fields must be represented as a comma separated string or a list of strings, options - as an ampersand separated string or list of strings or a name -> value dictionary.

Note

In case of unsubscribe, you can pass empty string or None for topic.

addResolved(subscriptionString, correlationId=None)
Parameters
  • subscriptionString (str) – Fully-resolved subscription string

  • correlationId (CorrelationId) – Correlation id to associate with the subscription

Add the specified subscriptionString to this SubscriptionList object, associating the specified correlationId with it. The subscription string may include options. The behavior of this function, and of functions operating on this SubscriptionList object, is undefined unless subscriptionString is a fully-resolved subscription string; clients that cannot provide fully-resolved subscription strings should use add() instead.

Note

It is at the discretion of each function operating on a SubscriptionList whether to perform resolution on this subscription.

append(other)

Append a copy of the specified SubscriptionList to this list.

Parameters

other (SubscriptionList) – List to append to this one

clear()

Remove all entries from this object.

correlationIdAt(index)
Parameters

index (int) – Index of the entry in the list

Returns

Correlation id of the indexth entry.

Return type

CorrelationId

Raises

Exception – If index >= size().

destroy()

Destroy the handle using stored dtor

isResolvedTopicAt(index)
Parameters

index (int) – Index of the entry in the list

Returns

True if the indexth entry in this SubscriptionList object was created using addResolved() and False if it was created using add(). An exception is thrown if index >= size().

Return type

bool

size()
Returns

The number of subscriptions in this object.

Return type

int

topicStringAt(index)
Parameters

index (int) – Index of the entry in the list

Returns

The full topic string at the specified index.

Return type

str

Raises

Exception – If index >= size().