如何解决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)
任何指针都表示赞赏。谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。