1

I want to draw historical last price charts using the Bloomberg Java API but I don't know which Bloomberg classes I should use.

Mike G
  • 4,232
  • 9
  • 40
  • 66
malmo
  • 484
  • 9
  • 20

1 Answers1

2

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.

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

*Disclaimer: I am the author of jBloomberg

assylias
  • 321,522
  • 82
  • 660
  • 783
  • @assylias +++ for support of Bloomberg BLPAPI (tested with 3.5.1.1), I'm Reuters and Bloomber user, local admin :-), I'll have to try your work – mKorbel Aug 27 '13 at 18:21
  • @mKorbel Thanks! I have stopped developing the library a few months ago but will start improving it again in the next month or so due to a new project (that started today!) - so there will probably be changes. It works well as is but is quite heavy on memory usage. – assylias Aug 27 '13 at 19:03
  • Hi,Is there a way to Pass the Ticker to Bloomberg terminal from our app and show a Basic Price Chart (_GP_) for that ticker on Bloomberg terminal ? – Angshuman Agarwal Jul 11 '17 at 10:52
  • @AngshumanAgarwal I suggest you ask a separate question as your comment seems unrelated to the question on this page. – assylias Jul 11 '17 at 10:55
  • Asked - https://stackoverflow.com/questions/45032672/how-to-see-price-chart-for-a-ticker-from-net-app-on-bloomberg-terminal-session – Angshuman Agarwal Jul 11 '17 at 11:06