Append new subscription to existing session in BLPAPI

185 Views Asked by At

Is there any way to append new subscription to already running session or do I need to terminate that session and then create new subscription with that new additional ticker to subscribe?

All examples from SDK have ticker predefined up front and I can't find anything if what I'm looking for is even possible.

From Python example:

def subscribe(p_identity):
    subscriptionOptions = []
    fieldList = []
    fieldList.append("SUBSCRIPTION_DATA")
    fieldList.append("LAST_PRICE")
    fieldList.append("BID")
    fieldList.append("ASK")
    fieldList.append("EID")
    fieldList.append("MKTDATA_EVENT_TYPE")
    fieldList.append("MKTDATA_EVENT_SUBTYPE")
    fieldList.append("IS_DELAYED_STREAM")
    subscriptionOptions1 = []
    cInfo = CorrelationInfo("BBG0013S8C89")
    cId = blpapi.CorrelationId(cInfo)
    g_subscriptions.add(cInfo.getTopic(), fieldList, subscriptionOptions1, cId)
    subscriptionOptions2 = []
    cInfo = CorrelationInfo("BBG0013SHH88")
    cId = blpapi.CorrelationId(cInfo)
    g_subscriptions.add(cInfo.getTopic(), fieldList, subscriptionOptions2, cId)
    subscriptionOptions3 = []
    cInfo = CorrelationInfo("JPY CURNCY")
    cId = blpapi.CorrelationId(cInfo)
    g_subscriptions.add(cInfo.getTopic(), fieldList, subscriptionOptions3, cId)
    subscriptionOptions4 = []
    cInfo = CorrelationInfo("SPX 5 C4450 INDEX")
    cId = blpapi.CorrelationId(cInfo)
    g_subscriptions.add(cInfo.getTopic(), fieldList, subscriptionOptions4, cId)
    # Subscriptions will start after authorization is successful

and then call it as

 session.subscribe(subscriptions, identity)

Create session for async events

session = blpapi.Session(session_options, eventHandler.processEvent)

where subscribe is part of processEvent and it happens before connection to authorization service

    if not session.openService("//blp/apiauth"):
        _logger.error("Failed to open //blp/apiauth")
        return
0

There are 0 best solutions below