我在尝试处理ReferenceDataRequest
. 这是我用来填写会话的所有代码。
global options
options = parseCmdLine()
sessionOptions = blpapi.SessionOptions()
sessionOptions.setServerHost(options.host)
sessionOptions.setServerPort(options.port)
session = blpapi.Session(sessionOptions)
if not session.start():
print ("Failed to start session.")
return False
if not session.openService("//blp/refdata"):
print ("Failed to open //blp/refdata")
return False
refDataService = session.getService("//blp/refdata")
request = refDataService.createRequest("ReferenceDataRequest")
request.getElement("securities").appendValue("UX1 Index")
request.getElement("fields").appendValue("FUT_DAYS_EXPIRE")
cid = session.sendRequest(request)
while(True):
ev = session.nextEvent(500)
for msg in ev:
if cid in msg.correlationIds():
# print(msg)
data = msg.getElement("securityData").getElement("fieldData")
if ev.eventType() == blpapi.Event.RESPONSE:
break
print(data)
session.stop()
我收到此错误。blpapi.exception.UnknownErrorException: Attempt access name 'fieldData' on array element 'securityData' (0x00000003)
.
这是msg
收到的样子。
ReferenceDataResponse = {
securityData[] = {
securityData = {
security = "UX1 Index"
eidData[] = {
}
fieldExceptions[] = {
}
sequenceNumber = 0
fieldData = {
FUT_DAYS_EXPIRE = 27
}
}
}
}
有没有办法解决这个问题?