【问题标题】:Getting ASK price on Bloomberg using Python API使用 Python API 在 Bloomberg 上获取 ASK 价格
【发布时间】:2016-05-30 20:18:35
【问题描述】:

我正在尝试使用 Excel 的 DataNitro 从 Bloomberg 获取 ASK 价格。

我从 excel 中调用这个函数:

main()

def main():
    options = parseCmdLine()

    # Fill SessionOptions
    sessionOptions = blpapi.SessionOptions()
    sessionOptions.setServerHost(options.host)
    sessionOptions.setServerPort(options.port)


    # Create a Session
    session = blpapi.Session(sessionOptions)

    # Start a Session
    if not session.start():

        return "Failed to start session."

    try:
        # Open service to get historical data from
        if not session.openService("//blp/refdata"):

            return "Failed to open //blp/refdata"

        sendIntradayBarRequest(session, options)

        # wait for events from session.
        askPrice=eventLoop(session)
        return "Ask Price: %s " % (askPrice)

    finally:
        # Stop the session
        session.stop()

在 Excel 上:
return "要价:%s" % (askPrice)
它总是在我从

调用函数的单元格上显示“Python 超时”

但是,当我将返回更改为打印时,它会在 Python shell 上正确显示价格
print "要价:%s" % (askPrice)

彭博方面的问题是我必须与他们联系的会话还是我必须修复的实际代码?有什么建议吗?

【问题讨论】:

  • askPrice 本质上可能是递归的吗?也许python在将其转换为字符串时陷入递归循环,但不会引发递归错误,因为代码是在C中处理的......

标签: python excel-2010 bloomberg datanitro blpapi


【解决方案1】:

返回价格需要多长时间? DataNitro UDF 在 3 秒后超时,以防止长时间运行的函数冻结 Excel。您可以在 DataNitro 的设置中修改超时时间。

【讨论】:

  • 我什至将超时时间更改为 30 秒,但仍然无法正常工作。当我在 Python shell 上运行时,它通常很快
  • 这似乎更适合评论而不是答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-07-01
  • 1970-01-01
  • 2014-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-04
相关资源
最近更新 更多