2

First I’d like to congratulate assylias on the amazing JBloomberg API that has saved my life and I'm asking how can I put the data that I get from the map in JTable already designed in Netbeans.

Here is the code for the historical prices:

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

How could I place the content of the Map in a JTable?

Community
  • 1
  • 1
malmo
  • 484
  • 9
  • 20

2 Answers2

3

Wrap your Map<DateTime, TypedObject> in a TableModel, as shown in EnvTableTest.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

code

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);
}
mKorbel
  • 109,525
  • 20
  • 134
  • 319
malmo
  • 484
  • 9
  • 20