python - 在 Python 中使用 blpapiwrapper 通过 BDH() 检索日内数据
问题描述
我正在尝试使用 blpapiwrapper( https://github.com/alex314159/blpapiwrapper )在特定时间获取股票价格,并从中获得灵感(https://quant.stackexchange.com/questions/35126/price- at-specific-time-from-bloomberg ):
=BDH("EURGBP Curncy","Last Price","7/13/2017 3:00:00 PM","7/13/2017 3:00:01 PM","BarTp=T,BarSz=1,Fill=P")
如果我尝试重新创建它,我会得到 EOD 价格,而不是 15:40:00 到 15:40:01 之间的最后价格。在具有相同 SEDOL 和日期的 Excel 中使用相同的语法会在 15:40 给出正确的股票价格。
bloomberg = BLP()
startdate = datetime.datetime.strptime('2020-01-03 15:40:00', '%Y-%m-%d %H:%M:%S')
enddate = datetime.datetime.strptime('2020-01-03 15:40:01', '%Y-%m-%d %H:%M:%S')
bloomberg.bdh('/SEDOL1/B151P43 Equity', "Last price",startdate, enddate , "BarTp = T, BarSz = 1, Fill = P")
我试图修改 blpapiwrapper 中的 bdh() 函数,将周期更改为“INTRADAY”,并在“startDate”和“endDate”的定义中包含“%H:%M:%S”,但没有运气。
def bdh(self, strSecurity='SPX Index', strData='PX_LAST', startdate=datetime.date(2014, 1, 1),
enddate=datetime.date(2014, 1, 9), adjustmentSplit=False, periodicity='DAILY'):
request = self.refDataSvc.createRequest('HistoricalDataRequest')
request.append('securities', strSecurity)
if type(strData) == str:
strData = [strData]
for strD in strData:
request.append('fields', strD)
request.set('startDate', startdate.strftime('%Y%m%d'))
request.set('endDate', enddate.strftime('%Y%m%d'))
request.set('adjustmentSplit', 'TRUE' if adjustmentSplit else 'FALSE')
request.set('periodicitySelection', periodicity)
requestID = self.session.sendRequest(request)
对于使用 blpapiwrapper 的解决方案有什么建议吗?
解决方案
推荐阅读
- python - 如何在 Python 函数中矢量化耦合 ODE 系统?
- api - DDD 请求和活动跟踪
- python - 列表索引超出范围以从 df 列中提取文本行
- python-3.x - 使用带有 selenium 的 python 从 Google 下载图像
- django - 如何使用 rest api 和 Search Delegate 在 Flutter 中执行搜索功能?
- sql - 无法创建具有相同名称但条件不同的临时表
- google-cloud-platform - GCP:通过对等连接到 CloudSQL 实例
- xml - 在 xmltable 中使用“字符串连接”时出错
- swift - UITableView with custom cells empty
- python - plt.show(block=True) 启动黑色图