2013-08-27 132 views
2

首先,我想祝賀the amazing JBloomberg API上的assylias已拯救了我的生活,並且我問如何將我從JTable中的地圖獲取的數據放入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); 
} 

我怎麼可能把地圖的JTable中的內容?

回答

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); 
}