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

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.

Return type

int

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

  • correlationId (Optional[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.

Return type

int

append(other)

Append a copy of the specified SubscriptionList to this list.

Parameters

other – List to append to this one

clear()

Remove all entries from this object.

Return type

int

correlationIdAt(index)
Parameters

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

Return type

CorrelationId

Returns

Correlation id of the indexth entry.

Raises

Exception – If index >= size().

destroy()

Destroy the handle using stored dtor

Return type

None

isResolvedTopicAt(index)
Parameters

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

Return type

bool

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().

size()
Return type

int

Returns

The number of subscriptions in this object.

topicStringAt(index)
Parameters

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

Return type

str

Returns

The full topic string at the specified index.

Raises

Exception – If index >= size().