Python Bloomberg API 请求没有 return 结果
Python Bloomberg API request does not return result
我正在尝试安装 Bloomberg API。我已按照所有说明进行操作,并且可以 运行 编码而不会产生任何错误。但是它没有产生任何有用的输出,这让我觉得安装出了问题。我已经试了四天了,我的头在敲键盘!希望有人遇到过这个并能给我提供线索。
我正在使用 "IntradayTickExample",可在此处获得:
https://github.com/msitt/blpapi-python/blob/master/examples/IntradayTickExample.py
输出如下所示:
IntradayTickExample
Connecting to localhost:8194
12OCT2018_16:37:35.207 7780:22292 WARN blpapi_platformcontroller.cpp:347
blpapi.session.platformcontroller.{1} Connectivity restored.
Sending Request: IntradayTickRequest = {
security = "IBM US Equity"
eventTypes[] = {
TRADE
}
startDateTime = 2008-08-11T15:30:00.000
endDateTime = 2008-08-11T15:35:00.000
}
Processing Response
IntradayTickResponse = {
tickData = {
eidData[] = {
}
tickData[] = {
}
}
}
TIME TYPE VALUE SIZE CC
---- ---- ----- ---- --
------------------
(program exited with code: 0)
有什么想法吗?
Bloomberg 将您可以下载的报价历史记录数量限制为最近 10 天。 运行 与您链接到的内容类似的示例将 return 数据提供正确的 运行ge(运行 截至 2018-10-24 ).
import blpapi
HOST = "localhost"
PORT = 8194
def main():
sessionOptions = blpapi.SessionOptions()
sessionOptions.setServerHost(HOST)
sessionOptions.setServerPort(PORT)
session = blpapi.Session(sessionOptions)
if not session.start():
print("Failed to start session.")
return
session.openService("//blp/refdata")
refDataService = session.getService("//blp/refdata")
request1 = refDataService.createRequest("IntradayTickRequest")
request1.set("security", "IBM US Equity")
request1.getElement("eventTypes").appendValue("TRADE")
request1.set("startDateTime", "2008-08-11T15:30:00.000")
request1.set("endDateTime", "2008-08-11T15:35:00.000")
request2 = refDataService.createRequest("IntradayTickRequest")
request2.set("security", "IBM US Equity")
request2.getElement("eventTypes").appendValue("TRADE")
request2.set("startDateTime", "2018-10-23T15:30:00.000")
request2.set("endDateTime", "2018-10-23T15:30:01.000")
session.sendRequest(request1)
session.sendRequest(request2)
while True:
ev = session.nextEvent(500)
if ev.eventType() == blpapi.Event.TIMEOUT:
break
for msg in ev:
print(msg)
运行 这你可以看到数据是在第二个例子中获得的,因为日期 运行ge 设置得当。
main()
SessionConnectionUp = {
server = "localhost:8194"
}
SessionStarted = {
initialEndpoints[] = {
initialEndpoints = {
address = "localhost:8194"
}
}
}
ServiceOpened = {
serviceName = "//blp/refdata"
}
IntradayTickResponse = {
tickData = {
eidData[] = {
}
tickData[] = {
}
}
}
IntradayTickResponse = {
tickData = {
eidData[] = {
}
tickData[] = {
tickData = {
time = 2018-10-23T15:30:00.000+00:00
type = TRADE
value = 129.510000
size = 100
}
tickData = {
time = 2018-10-23T15:30:00.000+00:00
type = TRADE
value = 129.510000
size = 300
}
tickData = {
time = 2018-10-23T15:30:00.000+00:00
type = TRADE
value = 129.525000
size = 100
}
tickData = {
time = 2018-10-23T15:30:01.000+00:00
type = TRADE
value = 129.510000
size = 100
}
tickData = {
time = 2018-10-23T15:30:01.000+00:00
type = TRADE
value = 129.510000
size = 100
}
tickData = {
time = 2018-10-23T15:30:01.000+00:00
type = TRADE
value = 129.510000
size = 200
}
}
}
}
我正在尝试安装 Bloomberg API。我已按照所有说明进行操作,并且可以 运行 编码而不会产生任何错误。但是它没有产生任何有用的输出,这让我觉得安装出了问题。我已经试了四天了,我的头在敲键盘!希望有人遇到过这个并能给我提供线索。
我正在使用 "IntradayTickExample",可在此处获得:
https://github.com/msitt/blpapi-python/blob/master/examples/IntradayTickExample.py
输出如下所示:
IntradayTickExample
Connecting to localhost:8194
12OCT2018_16:37:35.207 7780:22292 WARN blpapi_platformcontroller.cpp:347
blpapi.session.platformcontroller.{1} Connectivity restored.
Sending Request: IntradayTickRequest = {
security = "IBM US Equity"
eventTypes[] = {
TRADE
}
startDateTime = 2008-08-11T15:30:00.000
endDateTime = 2008-08-11T15:35:00.000
}
Processing Response
IntradayTickResponse = {
tickData = {
eidData[] = {
}
tickData[] = {
}
}
}
TIME TYPE VALUE SIZE CC
---- ---- ----- ---- --
------------------
(program exited with code: 0)
有什么想法吗?
Bloomberg 将您可以下载的报价历史记录数量限制为最近 10 天。 运行 与您链接到的内容类似的示例将 return 数据提供正确的 运行ge(运行 截至 2018-10-24 ).
import blpapi
HOST = "localhost"
PORT = 8194
def main():
sessionOptions = blpapi.SessionOptions()
sessionOptions.setServerHost(HOST)
sessionOptions.setServerPort(PORT)
session = blpapi.Session(sessionOptions)
if not session.start():
print("Failed to start session.")
return
session.openService("//blp/refdata")
refDataService = session.getService("//blp/refdata")
request1 = refDataService.createRequest("IntradayTickRequest")
request1.set("security", "IBM US Equity")
request1.getElement("eventTypes").appendValue("TRADE")
request1.set("startDateTime", "2008-08-11T15:30:00.000")
request1.set("endDateTime", "2008-08-11T15:35:00.000")
request2 = refDataService.createRequest("IntradayTickRequest")
request2.set("security", "IBM US Equity")
request2.getElement("eventTypes").appendValue("TRADE")
request2.set("startDateTime", "2018-10-23T15:30:00.000")
request2.set("endDateTime", "2018-10-23T15:30:01.000")
session.sendRequest(request1)
session.sendRequest(request2)
while True:
ev = session.nextEvent(500)
if ev.eventType() == blpapi.Event.TIMEOUT:
break
for msg in ev:
print(msg)
运行 这你可以看到数据是在第二个例子中获得的,因为日期 运行ge 设置得当。
main()
SessionConnectionUp = {
server = "localhost:8194"
}
SessionStarted = {
initialEndpoints[] = {
initialEndpoints = {
address = "localhost:8194"
}
}
}
ServiceOpened = {
serviceName = "//blp/refdata"
}
IntradayTickResponse = {
tickData = {
eidData[] = {
}
tickData[] = {
}
}
}
IntradayTickResponse = {
tickData = {
eidData[] = {
}
tickData[] = {
tickData = {
time = 2018-10-23T15:30:00.000+00:00
type = TRADE
value = 129.510000
size = 100
}
tickData = {
time = 2018-10-23T15:30:00.000+00:00
type = TRADE
value = 129.510000
size = 300
}
tickData = {
time = 2018-10-23T15:30:00.000+00:00
type = TRADE
value = 129.525000
size = 100
}
tickData = {
time = 2018-10-23T15:30:01.000+00:00
type = TRADE
value = 129.510000
size = 100
}
tickData = {
time = 2018-10-23T15:30:01.000+00:00
type = TRADE
value = 129.510000
size = 100
}
tickData = {
time = 2018-10-23T15:30:01.000+00:00
type = TRADE
value = 129.510000
size = 200
}
}
}
}