unsubscribe.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:blpapi-web 作者: pricingmonkey 项目源码 文件源码
def doUnsubscribe(securities):
    try:
        _, sessionRestarted = openBloombergService(app.sessionForSubscriptions, "//blp/mktdata")
        if sessionRestarted:
            app.allSubscriptions = {}
        subscriptionList = blpapi.SubscriptionList()
        for security in securities:
            correlationId = blpapi.CorrelationId(sys.intern(security))
            if security in app.allSubscriptions:
                del app.allSubscriptions[security]
            subscriptionList.add(security, correlationId=correlationId)

        app.sessionForSubscriptions.unsubscribe(subscriptionList)
    except Exception as e:
        handleBrokenSession(app, e)
        traceback.print_exc()
        return respond500(e)

    response = Response(
        json.dumps({ "message": "OK"}).encode(),
        status=202,
        mimetype='application/json')
    response.headers['Access-Control-Allow-Origin'] = allowCORS(request.headers.get('Origin'))
    return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号