我想使用Bloomberg Java API绘制历史最后价格图表,但我不知道应该使用哪些Bloomberg类。
答案 0 :(得分:2)
假设您使用的是Bloomberg Java API,对于历史数据,您需要使用"//blp/refdata"
服务并发送"HistoricalDataRequest"
。开发人员指南中提供了几个示例,可在the project page上找到。
或者,您可以使用更简单的jBloomberg*,因为它可以为您处理杂乱的细节。要检索历史数据,您可以按照the javadoc:
中给出的示例进行操作BloombergSession session = new DefaultBloombergSession();
session.start();
RequestBuilder<HistoricalData> hrb = new HistoricalRequestBuilder("SPX Index",
"PX_LAST", DateTime.now().minusDays(7),
DateTime.now())
.fill(HistoricalRequestBuilder.Fill.NIL_VALUE)
.days(HistoricalRequestBuilder.Days.ALL_CALENDAR_DAYS);
HistoricalData result = session.submit(hrb).get();
Map<DateTime, TypedObject> data = result.forSecurity("SPX Index").forField("PX_LAST").get();
for (Map.Entry<DateTime, TypedObject> e : data.entrySet()) {
DateTime dt = e.getKey();
double price = e.getValue().asDouble();
System.out.println("[" + dt + "] " + price);
}
*免责声明:我是jBloomberg的作者