【问题标题】:Requesting intraday historical data via Bloomberg API in python在 python 中通过 Bloomberg API 请求盘中历史数据
【发布时间】:2019-01-15 13:33:39
【问题描述】:

我想知道是否有人能够在 python 中使用 Bloomberg API 来提取特定时间的盘中历史数据。有关于在给定时间间隔(5、10、15 分钟)内提取日内数据的线程,但我希望参考特定时间和日期(例如 01/09/19 13:33:42)并在那时提取数据.

这可以在 excel 中通过具有如下覆盖的公式来实现:

BDH("AAPL US EQUITY","BID",(DATE + TIME)-0.01,(DATE + TIME)-0.0001,"IntrRw=True","points=1","SIZE=S","TYPE=H","DTS=H","TimeZone=new York","cols=2;rows=1 ")

欣赏任何想法或想法。

我一直试图在一个简单的数据请求上使用 xbbg,只是为了弄清楚语法,但没有运气。以下是我在 excel 中运行但没有运气的日期/时间格式。尝试使用上述 excel 公式中的所有覆盖,但没有运气。

from xbbg import blp
SPXLAST = blp.bdh(tickers='SPX INDEX',flds='PX_LAST',start_date='09-26-18 
14:30:25',end_date='09-26-18 14:30:25',TimeZone='New York')
print(SPXLAST)

只能提取 EOD 数据,但不能提取特定盘中时间的数据。

【问题讨论】:

标签: python excel api bloomberg


【解决方案1】:

Python 支持 blpapi。这是一个代码sn-p:

def sendIntradayTickRequest(session, options, identity = None):
refDataService = session.getService("//blp/refdata")
request = refDataService.createRequest("IntradayTickRequest")

# only one security/eventType per request
request.set("security", "IBM US Equity")

# Add fields to request
eventTypes = request.getElement("eventTypes")
eventTypes.appendValue("TRADE")
eventTypes.appendValue("BID")
eventTypes.appendValue("ASK")
# add more tick types

# All times are in GMT
request.set("startDateTime", "2019-01-15T14:40:00")
request.set("endDateTime", "2019-01-15T14:43:00")

# options
request.set("includeConditionCodes", True)
# add more optionals

print("Sending Request:", request)
session.sendRequest(request)

【讨论】:

  • 您好 Mourad,感谢您的回复。不知道我在这里做错了什么,但这是我在运行那段代码时收到的输出: Traceback (last recent call last): File "C:\BBG API\bloomytest4.py", line 9, in request.set("security", "IBM US Equity") AttributeError: module 'request' has no attribute 'set'
  • 这只是一个sn-p,不是完整的代码。它需要首先安装 blpapi 包。接下来创建会话,打开服务等。这里是完整的代码示例gist.github.com/jfujino/5856269
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-10-06
  • 1970-01-01
  • 1970-01-01
  • 2019-07-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-11
相关资源
最近更新 更多