2. Overview of the Bloomberg API
The Bloomberg API provides developers with 24x7 programmatic access to data
from the Bloomberg Data Centre for use in customer applications.
The established service provides free, unrestricted access to raw data for customers
for its financial market information.
The Bloomberg API lets you integrate streaming real-time and delayed data,
reference data, historical data, intraday data, and Bloomberg derived data into
your own custom and third-party applications.
3. What kind of data?
Infrastructure for high-performance worldwide delivery of arbitrary structured data
from multiple distributed sources
Many different services, with "market data" most heavily used
Prices, trades, volumes, etc. delivered directly from exchanges
Real-time subscriptions to live data
Query interface to database of historical data
4. Features of the Bloomberg API
Interfaces in C, C++, Java, .NET, Perl, and Python
Linux, Windows, Solaris, Mac OS X
Full set of example applications—easy starting point
http://openbloomberg.com/open-api/
Lightweight Interfaces
32- and 64-bit Programming Support
Pure Java Implementation: The Java API is implemented entirely in Java. Bloomberg
did not use JNI to wrap either our existing C library or the new C++ library.
5. Real-time prices in Python
session = blpapi.Session()
session.start()
subscriptions = blpapi.SubscriptionList()
subscriptions.add("IBM US Equity", "LAST_PRICE,BID,ASK", "", blpapi::CorrelationId(1))
session.subscribe(subscriptions)
while (True):
event = session.nextEvent()
for msg in event:
print("IBM: ", msg)
6. Application Structure
The Bloomberg API object model contains a small number of key objects which
applications use to request, receive and interpret data.
Session: An application creates a Session object to manage its connection with the
Bloomberg infrastructure.
Service: Using the Session object, an application creates a Service object and then
‘opens’ each Bloomberg service that it will use.
Request: The client can make individual requests for data.
Subscription: the client can start a subscription with the service for on-going data
updates.
Event: Programmatically, the customer application obtains Event objects for the
Session and then extracts from those Event objects one or more Message objects
containing the Bloomberg data.
8. Using the Request/Response
Paradigm - 1
public static void main(String[] args) throws Exception {
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.setServerHost("localhost"); // default value
sessionOptions.setServerPort(8194); // default value
Session session = new Session(sessionOptions);
if (!session.start()) {
System.out.println("Could not start session.");
System.exit(1);
}
if (!session.openService("//blp/refdata")) {
System.out.println("Could not open service " +
"//blp/refdata");
System.exit(1);
}
9. Using the Request/Response
Paradigm - 2
CorrelationID requestID = new CorrelationID(1);
Service refDataSvc = session.getService("//blp/refdata");
Request request =
refDataSvc.createRequest("ReferenceDataRequest");
request.append("securities", "IBM US Equity");
request.append("fields", "PX_LAST");
session.sendRequest(request, requestID);
boolean continueToLoop = true;
10. Using the Request/Response
Paradigm - 3
while (continueToLoop) {
Event event = session.nextEvent();
switch (event.eventType().intValue()) {
case Event.EventType.Constants.RESPONSE: // final event
continueToLoop = false; // fall through
case Event.EventType.Constants.PARTIAL_RESPONSE:
handleResponseEvent(event);
break;
default:
handleOtherEvent(event);
break;
}
}
}
11. Services
Core: Reference Data Service "//blp/refdata"
Market Data Service "//blp/mktdata"
Additional: Custom VWAP Service "//blp/mktvwap"
Market Bar Subscription Service "//blp/mktbar"
API Field Information Service "//blp/apiflds"
Page Data Service "//blp/pagedata"
Technical Analysis Service "//blp/tasvc"
API Authorization "//blp/apiauth"
13. Publishing
The Bloomberg API allows customer applications to publish data as well as consume
it. Customer data can be published for distribution within the customer’s enterprise,
contributed to the Bloomberg infrastructure, distributed to others, or used for
warehousing.
Publishing applications might simply broadcast data or they can be “interactive”,
responding to feedback from the infrastructure about the currently active
subscriptions from data consumers.
14. Simple Broadcast
Creating a session.
Obtaining authorization.
Creating the topic.
Publishing events for the topic to the designated service.
15. Interactive Publication
Creating a session.
Obtaining authorization.
Registering for subscription start and stop messages.
Handling subscription start and stop events, which add and remove topics to the
active publication set.
Creating a topic.
Publishing events for the active topics of the designated service.