python - Google Colab 中的 blpapi 抛出 InvalidArgumentException
问题描述
试图在 Google Colab 环境中运行一个非常普通的 BDP。任何人都可以解决这个问题?
安装依赖项:
!pip install --index-url=https://bcms.bloomberg.com/pip/simple/blpapi
开始我的会议:
import blpapi
session = blpapi.Session()
session.start()
session.openService("//blp/refdata")
service = session.getService("//blp/refdata")
request = service.createRequest("ReferenceDataRequest")
request.append("securities", "USDCAD Curncy")
request.append("fields", "PX_OPEN")
session.sendRequest(request)
endReached = False
while endReached == False:
ev = session.nextEvent()
if ev.eventType() == blpapi.Event.RESPONSE or ev.eventType() == blpapi.Event.PARTIAL_RESPONSE:
for msg in ev:
print (msg)
if ev.eventType() == blpapi.Event.RESPONSE:
endReached = True
这给了我一个:
---------------------------------------------------------------------------
InvalidArgumentException Traceback (most recent call last)
<ipython-input-10-5882776bd4df> in <module>()
7
8 service = session.getService("//blp/refdata")
----> 9 request = service.createRequest("ReferenceDataRequest")
10
11 request.append("securities", "USDCAD Curncy")
2 frames
/usr/local/lib/python3.7/dist-packages/blpapi/service.py in createRequest(self, operation)
381 self.__handle,
382 operation)
--> 383 _ExceptionUtil.raiseOnError(errCode)
384 return Request(request, self.__sessions)
385
/usr/local/lib/python3.7/dist-packages/blpapi/exception.py in raiseOnError(errorCode, description)
144 """
145 if errorCode:
--> 146 _ExceptionUtil.raiseException(errorCode, description)
147
148 __copyright__ = """
/usr/local/lib/python3.7/dist-packages/blpapi/exception.py in raiseException(errorCode, description)
136 description = "Unknown"
137 errorClass = _ExceptionUtil.__getErrorClass(errorCode)
--> 138 raise errorClass(description, errorCode)
139
140 @staticmethod
InvalidArgumentException: Null service handle (0x00020002)
任何指针表示赞赏。谢谢
解决方案
推荐阅读
- javascript - 使用我的数据库中的信息创建滑块/幻灯片
- jsp - 来自查询字符串的 JSP 动态内容
- scala - 用例类字段名称作为数据框列
- python-3.x - 使用 Python 跳过大文本文件中的某些行
- ios - 在 pod 文件中添加引用后,“没有这样的模块 'FirebaseFirestore'”
- jenkins - 如何在詹金斯检查点后恢复文件
- c# - 富文本框中的重复代码点不会显示
- flutter - 如何使用 FutureBuilder 手动触发 AsyncSnapshot 错误
- fody - Fody.WeavingTask 任务因 System.TypeInitializationException 意外失败
- angular - Leaflet.js(ngx-leaflet)地图图块在Angular 8的弹出窗口中未正确加载