使用彭博API绘制历史最后价格走势图 [英] draw historical last price chart using bloomberg API
问题描述
我想用彭博社的Java API来绘制历史最后的价格图表,但我不知道是哪个班彭博我应该使用。
I want to draw historical last price charts using the Bloomberg Java API but I don't know which Bloomberg classes I should use.
推荐答案
假设你使用的是彭博社的Java API,历史数据,你需要使用// BLP / refdata
服务和发送HistoricalDataRequest
。几个例子给开发者指南中,可在项目页面。
Assuming you are using the Bloomberg Java API, for historical data you need to use the "//blp/refdata"
service and send a "HistoricalDataRequest"
. Several examples are given in the Developer's guide, available on the project page.
另外,你可以使用 jBloomberg * 它更容易使用,因为它处理繁琐的细节为你。要检索历史数据,您可以按照的Javadoc :
Alternatively, you can use jBloomberg* which is simpler to use because it handles the messy details for you. To retrieve historical data, you can follow the example given in 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的作者
*Disclaimer: I am the author of jBloomberg
这篇关于使用彭博API绘制历史最后价格走势图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!