首先,我要祝贺the amazing JBloomberg API上的assylias已经挽救了我的生命,我问我怎样才能将我从地图中获得的数据放在已经在Netbeans中设计的JTable中。
以下是历史价格的代码:
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);
}
如何将Map的内容放在JTable中?
答案 0 :(得分:3)
将Map<DateTime, TypedObject>
换成TableModel
,如EnvTableTest
所示。
答案 1 :(得分:0)
码
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);
}