See: Description
Interface | Description |
---|---|
BloombergSession |
A high level API to submit requests to the Bloomberg API or subscribe to real time data updates.
|
DataChangeListener |
A DataChangeListener is passed to a BloombergSession to be informed of real time changes to a combination of
securities / fields.
|
RequestBuilder<T extends RequestResult> |
An interface used to create static or historical requests: users of this API should use existing implementations of
this interface.
|
RequestResult |
An interface that represents the result returned by a Bloomberg request (historical, intraday, static or portfolio
requests).
|
ResultParser<T extends RequestResult> |
A ResultParser parses the responses received from the Bloomberg Session after having sent a request.
|
Class | Description |
---|---|
DataChangeEvent |
A DataChangeEvent gets delivered whenever a real time subscription sends a new value for a tracked data.
|
DefaultBloombergSession |
The default implementation of the BloombergSession interface.
|
HistoricalData |
A class that represents the result returned by a Bloomberg HistoricalData request.
|
HistoricalRequestBuilder |
This class enables to build a HistoricalData request while ensuring argument safety.
|
IntradayBarData |
A class that represents the result returned by a Bloomberg IntradayBarData request.
|
IntradayBarRequestBuilder |
This class enables to build an IntradayBarData historical request while ensuring argument safety.
|
IntradayTickData |
A class that represents the result returned by a Bloomberg IntradayTickData request.
|
IntradayTickRequestBuilder |
This class enables to build an IntradayTickData historical request while ensuring argument safety.
|
ReferenceData |
A class that represents the result returned by a Bloomberg ReferenceData request.
|
ReferenceRequestBuilder |
This class enables to build a ReferenceData request while ensuring argument safety.
|
SubscriptionBuilder |
A SubscriptionBuilder is used to build real time streaming subscription requests.
|
TypedObject |
Enum | Description |
---|---|
BloombergRequestType |
The names internally used by Bloomberg to identify the various types of requests - users don't need to use these
values directly.
|
BloombergServiceType |
The URIs internally used by Bloomberg to identify the various services - users don't need to use these values
directly.
|
HistoricalRequestBuilder.Days |
Defines what days are returned in historical requests (weekdays only, all days etc.).
|
HistoricalRequestBuilder.Fill |
Defines what values are returned when a field has no value on a specific date.
|
HistoricalRequestBuilder.Period |
Defines the period used for historical data requests (daily, weekly etc.).
|
HistoricalRequestBuilder.PeriodicityAdjustment |
Defines the periodicity adjustment.
|
IntradayBarField |
A list of the fields available when requesting IntradayBar data.
|
IntradayBarRequestBuilder.IntradayBarEventType |
Defines the field to be returned for historical intraday bar requests.
|
IntradayTickField |
A list of the fields available when requesting IntradayTick data.
|
IntradayTickRequestBuilder.IntradayTickEventType |
Defines the field to be returned for historical intraday tick requests.
|
RealtimeField |
A list of all supported real time fields that can be subscribed to.
|
Exception | Description |
---|---|
BloombergException |
Exception thrown to signal that an error occurred while calling the Bloomberg API.
This can happen for example if there is no Bloomberg terminal installed on the machine, if the user is not logged on, if the connection gets shutdown, if a malformed query is sent to the API etc. |
A typical use is to start a BloombergSession and to submit static or historical requests or to subscribe to real time updates. Once the session is not in use any longer, it can be stopped. Note that in the below examples, sessions are started then stopped right after a request has been sent. In practice, starting a session can be a time consuming operation and once a session has been opened, it is preferable to reuse it unless it is not going to be used for a long time.
Example: start and stop a session
BloombergSession session = new DefaultBloombergSession();
session.start();
session.stop();
Example: retrieve the last price of the S&P 500 in Yen
RequestBuilder<ReferenceData> hrb = new ReferenceRequestBuilder(
"SPX Index", "CRNCY_ADJ_PX_LAST")
.addOverride("EQY_FUND_CRNCY", "JPY");
ReferenceData result = session.submit(hrb).get();
double priceInYen = result.forSecurity("SPX Index").forField("CRNCY_ADJ_PX_LAST").asDouble();
System.out.println("SPX in Yen = " + priceInYen);
Example: retrieve historical data synchronously
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);
}
Example: retrieve 60 minutes bar for the S&P 500 over the past week
RequestBuilder<IntradayBarData> hrb = new IntradayBarRequestBuilder("SPX Index",
DateTime.now().minusDays(7),
DateTime.now())
.adjustSplits()
.fillInitialBar()
.period(1, TimeUnit.HOURS);
IntradayBarData result = session.submit(hrb).get();
Map<DateTime, TypedObject> data = result.forField(IntradayBarField.CLOSE).get();
for (Map.Entry<DateTime, TypedObject> e : data.entrySet()) {
DateTime dt = e.getKey();
double price = e.getValue().asDouble();
System.out.println("[" + dt + "] " + price);
}
Example: retrieve tick data for the S&P 500 over the past 2 hours
RequestBuilder<IntradayTickData> hrb = new IntradayTickRequestBuilder("SPX Index",
DateTime.now().minusHours(2),
DateTime.now())
.includeBrokerCodes()
.includeConditionCodes();
IntradayTickData result = session.submit(hrb).get();
Multimap<DateTime, TypedObject> data = result.forField(IntradayTickField.VALUE);
for (Map.Entry<DateTime, TypedObject> e : data.entries()) {
DateTime dt = e.getKey();
double price = e.getValue().asDouble();
System.out.println("[" + dt + "] " + price);
}
Example: subscribe to real time price updates
DataChangeListener lst = new DataChangeListener() {
@Override
public void dataChanged(DataChangeEvent e) {
System.out.println(e);
}
};
SubscriptionBuilder builder = new SubscriptionBuilder()
.addSecurity("ESA Index")
.addField(RealtimeField.LAST_PRICE)
.addField(RealtimeField.ASK)
.addField(RealtimeField.ASK_SIZE)
.addListener(lst);
session.subscribe(builder);
Thread.sleep(3000); //to allow data to start coming in
Copyright © 2013. All Rights Reserved.