Blpapi Developers Guide 2.54
Blpapi Developers Guide 2.54
Blpapi Developers Guide 2.54
Version 3.x
Developers Guide
Table of Contents
Preface: About this Document .................................................................................................. 9
Purpose................................................................................................................................... 9
Audience ................................................................................................................................. 9
Document History ................................................................................................................... 9
Customer Support Information .............................................................................................. 10
1 Introduction to the Bloomberg API ..................................................................................... 12
1.1 Overview of the Bloomberg API ..................................................................................... 12
1.1.1 Features ................................................................................................................ 13
1.1.2 The Bloomberg Platform ....................................................................................... 15
1.1.3 B-PIPE .................................................................................................................. 16
1.1.4 The Desktop API and Server API.......................................................................... 17
1.2 APITypical Application Structure................................................................................... 20
1.3 Overview of this Guide ................................................................................................... 21
2 Sample Programs in Two Paradigms.................................................................................. 22
2.1 Overview ........................................................................................................................ 22
2.2 The Two Paradigms ....................................................................................................... 23
2.2.1 Request/Response................................................................................................ 23
2.2.2 Subscription .......................................................................................................... 24
2.3 Using the Request/Response Paradigm ........................................................................ 24
2.4 Using the Subscription Paradigm................................................................................... 28
3 Sessions and Services ......................................................................................................... 31
3.1 Sessions ........................................................................................................................ 31
3.2 Services ......................................................................................................................... 31
3.3 Event Handling.............................................................................................................. 31
3.3.1 Synchronous Event Handling................................................................................ 33
3.3.2 Asynchronous Event Handling .............................................................................. 34
3.4 Multiple Sessions ........................................................................................................... 38
4 Requests and Responses .................................................................................................... 39
4.1 The Programming Example ........................................................................................... 39
4.2 Elements ........................................................................................................................ 40
4.3 Request Details.............................................................................................................. 40
4.4 Response Details ........................................................................................................... 42
5 Subscriptions ........................................................................................................................ 47
5.1 Starting a Subscription ................................................................................................... 47
Table of Contents
Table of Contents
7 Core Services........................................................................................................................ 77
7.1 Common Concepts ........................................................................................................ 77
7.1.1 Security/Securities ................................................................................................ 77
7.1.2 Pricing Source....................................................................................................... 78
7.1.3 Fields .................................................................................................................... 79
7.1.4 Overrides .............................................................................................................. 79
7.1.5 Relative Dates....................................................................................................... 80
7.2 Reference Data Service................................................................................................. 81
7.2.1 Reference Data Request and Response Overview .............................................. 82
7.2.2 Historical Data Request ........................................................................................ 83
7.2.3 Intraday Tick Request ........................................................................................... 84
7.2.4 Intraday Bar Services............................................................................................ 85
7.2.5 Portfolio Data Request.......................................................................................... 86
7.2.6 BEQS Request...................................................................................................... 86
7.3 Market Data Service ...................................................................................................... 87
7.4 Custom VWAP Service.................................................................................................. 88
7.5 Market Bar Subscription Service ................................................................................... 88
7.6 API Field Information Service ........................................................................................ 90
7.6.1 Field Information Request..................................................................................... 90
7.6.2 Field Search Request ........................................................................................... 91
7.6.3 Categorized Field Search Request ....................................................................... 91
7.7 Page Data Service......................................................................................................... 93
7.8 Technical Analysis Service ............................................................................................ 96
7.8.1 Historical End of Day study request...................................................................... 96
7.8.2 Intraday bar study request .................................................................................... 98
7.8.3 Real time study request ...................................................................................... 100
7.9 API Authorization ......................................................................................................... 101
7.10 Instruments Service ................................................................................................... 101
7.10.1 Security Lookup Request.................................................................................. 101
7.10.2 Curve Lookup Request ..................................................................................... 102
7.10.3 Government Lookup Request ........................................................................... 102
7.10.4 Response Behaviors......................................................................................... 103
7.10.5 Code Example .................................................................................................. 105
8 Publishing ........................................................................................................................... 106
8.1 Overview...................................................................................................................... 106
8.2 The Programming Examples ....................................................................................... 106
Table of Contents
IntradayTickRequest: Sequence
................................................................ 171
Table of Contents
Table of Contents
................................................................ 246
......................................................................... 253
.................................................................................... 274
.............................................................................................. 278
................................................................... 281
Table of Contents
Table of Contents
Audience
This document is intended for developers who use the Bloomberg API.
Document History
Version
Date
Description of Changes
2.0
11/05/09
2.41
10/03/12
2.42
11/14/12
2.43
12/21/12
2.44
01/04/13
2.45
01/14/13
2.46
01/29/13
2.47
03/21/13
2.48
06/05/13
2.49
07/10/13
2.50
01/21/14
2.51
04/16/14
2.5
04/17/14
2.53
05/12/14
2.54
06/30/14
Firm Name
Issue description
Error messages
Contact information
+1-212-617-4390
Europe:
+44-20-3216-4380
Japan:
+81-3 3201-2780
Hong Kong:
+852-2293-1238
Singapore:
+65 6212-1180
Australia:
+612-9777-7210
If you are a Server API user, please have your ASID number and ASID Serial Number ready
when requesting support. You can find this information in the bin/clientid.txt file (located
in the root directory that you specified as part of the Server API installation procedure).
10
Non-Urgent Support
Submit a non-urgent request at:
https://software.bloomberg.com/BPIPE/sub1/dlwp/b?action=PostQuery
Sales Support
Call your Bloomberg sales representative.
11
12
1.1.1 Features
Feature
Details
Java
C++
.Net
The Java, .Net and C++ object models are identical, while the C
interface provides a C-style version of the object model. You are
able to effortlessly port applications among these languages as
the needs of your applications change.
Lightweight Interfaces
Field Level
Subscriptions
You are now able to request updates for only the fields of
interest to your application, rather than receiving all trade and
quote fields when you establish a subscription.
This reduces the overhead of processing unwanted data within
both the API and your application, and also reduces network
bandwidth consumption between Bloomberg and its customers.
For example, if quotes are of no interest to an application,
processing and bandwidth consumption can be cut by as much
as 90%.
13
Feature
Details
Summary events
Interval-based
Subscriptions
No Request Size
Restrictions
14
Feature
Details
Thread-Safe
All language bindings for the new API are now fully thread-safe.
Applications can safely process responses and make requests
simultaneously from multiple threads of execution.
The Java, C/C++ and .NET API all work on both 32- and 64-bit
platforms.
Pure Java
Implementation
Simplified
Permissioning Model
B-PIPE
Server API
Desktop API
15
1.1.3 B-PIPE
B-PIPE leverages the Bloomberg distribution platform and managed entitlements system. BPIPE allows clients to connect applications providing solutions that work with client
proprietary and 3rd party applications. B-PIPE provides the tools to permission data to
entitled users only. Client applications will use the Bloomberg entitlements system to ensure
distribution of data only to appropriately entitled users (see Figure 1-2).
16
17
18
19
20
Using the Session object, an application creates a Service object and then opens each
Bloomberg service that it will use. For example, Bloomberg provides streaming market data
and reference data as services.
There are two programming paradigms that can be used with the Service object. The client
can make individual requests for data (via a Request object) or the client can start a
subscription with the service (managed via a Subscription object) for ongoing data
updates. A customer application may be written to handle both paradigms. Whichever
paradigm or paradigms are used, the Bloomberg infrastructure replies with events (received
at the client as Event objects) which the client must handle asynchronously.
Programmatically, the customer application obtains Event objects for the Session and then
extracts from each Event object one or more Message objects containing the Bloomberg
data.
First a small but complete example program is presented to illustrate the most
common features of the Bloomberg API. See Sample Programs in Two Paradigms
on page 22.
This is followed by detailed descriptions of the key scenarios in using the Bloomberg
API: creating a session; opening services; sending requests and processing their
responses; and subscribing to streaming data and processing the results. See
Sessions and Services on page 31, Requests and Responses on page 39, and
Subscriptions on page 47.
21
The creation and startup of a Session object which the application uses to specify
the data it wants and then receive that data.
Data from the Bloomberg infrastructure is organized into various services. The
application "opens" the service that can provide the needed data (e.g., reference
data, current market data).
The application asks the service for specific information of interest. For example,
the last price for a specific security.
Data from the service will arrive in one or more asynchronously delivered Event objects. If
an application has several outstanding requests for different data, the data arriving from
these multiple requests may be interleaved with each other; however, data related to a
specific request always arrives in order.
Note: To assist applications in matching incoming data to requests, the Bloomberg
API allows applications to provide a CorrelationID object with each request.
Subsequently, the Bloomberg infrastructure uses that identifier to tag the events
sent in response. On receipt of the Event object, the client can use the identifier it
supplied to match events to requests.
Even if an application (such as the examples in this chapter) makes only a single request for
data, the application must also be prepared to handle status events from the service in
addition to the requested data.
22
The following display provides an outline of the organization used in these examples.
import classes
public class Example1 {
private static void handleDataEvent(Event event) throws Exception
{
}
private static handleOtherEvent(Event event) throws Exception
{
}
public static void main(String[] args) throws Exception
{
create and start Session
use Session to open service
ask service for data
(provide id for service to label replies)
loop waiting for data; pass replies to event handlers
}
}
The additional details needed to create a working example are provided below.
2.2.1 Request/Response
In this case, data is requested by issuing a Request and is returned in a sequence
consisting of zero or more Events of type PARTIAL_RESPONSE followed by exactly one
Event of type RESPONSE. The final RESPONSE indicates that the Request has been
completed.
23
In general, applications written to this paradigm will perform extra processing after receiving
the final RESPONSE from a Request.
2.2.2 Subscription
In this case a Subscription is created which results in a stream of updates being delivered
in Events of type SUBSCRIPTION_DATA until the Subscription is explicitly cancelled by
the application.
24
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;
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;
}
}
}
A Session is created and started; then that Session is used to open a service
named "//blp/refdata", a service that provides data according to the Request/
Response paradigm.
In this example, the values explicitly set for host and port correspond to the default
values for Session; supply the values for your installation. If the default values
suffice then Session construction can be simplified to:
Session session = new Session();
The Session is used to obtain refDataSvc, a handle for the service, which is
used to obtain an empty Request object for the "ReferenceDataRequest"
operation.
The empty request object is customized to the data needed for this application: the
security of interest is "IBM US Equity", the Bloomberg field of interest is
"PX_LAST" (last price).
The request is sent to the service along with requestID, an application specified
CorrelationID. (The value chosen is not important for this example.)
The application enters a loop that makes a blocking request for nextEvent from
the Session. Each Event is handled according to its type.
25
Event objects of any other type are handled by a different user defined
handler, handleOtherEvent.
In this application, the event handlers simply output some information about the received
events.
private static void handleResponseEvent(Event event) throws Exception
{
System.out.println("EventType =" + event.eventType());
MessageIterator iter = event.messageIterator();
while (iter.hasNext()) {
Message message = iter.next();
System.out.println("correlationID=" +
message.correlationID());
System.out.println("messageType =" +
message.messageType());
message.print(System.out);
}
}
Each Event has a type and possibly some associated Messages which can be
obtained via the MessageIterator obtained from the Event.
Each Message from these response events shows the same CorrelationID
that was specified when the Request was sent. Additionally, each Message has
a type.
Finally, there is a print method to output the details of the Message in a default
format.
26
However, this response to our query is not the only output from this program. This
application also receives Events of type neither PARTIAL_RESPONSE nor RESPONSE.
EventType=SESSION_STATUS
correlationID=null
messageType=SessionStarted
SessionStarted = {
}
EventType=SERVICE_STATUS
correlationID=Internal: 1
messageType=ServiceOpened
ServiceOpened = {
}
This output comes from the event handling function called from the default case of the
switch statement. The events reported here are returned in response to the applications
starting of a session and opening of a service.
private static void handleOtherEvent(Event event) throws Exception
{
System.out.println("EventType=" + event.eventType());
MessageIterator iter = event.messageIterator();
while (iter.hasNext()) {
Message message = iter.next();
System.out.println("correlationID=" +
message.correlationID());
System.out.println("messageType=" + message.messageType());
message.print(System.out);
if (Event.EventType.Constants.SESSION_STATUS ==
event.eventType().intValue()
&& "SessionTerminated" ==
message.messageType().toString()){
System.out.println("Terminating: " +
message.messageType());
System.exit(1);
}
}
}
Some messages (e.g., system messages) may not have a CorrelationID. The
handler must be able to handle such cases.
Note: The SERVICE_STATUS correlation ID has type Internal because it was
automatically generated. The RESPONSE correlation ID that was explicitly specified
by the application is typed User.
There may be events that do not arise from application request; for example, an
unexpected session shutdown.
27
The service opened by this application has been changed from "//blp/refdata"
(reference data) a service that follows the request/response paradigm to
"//blp/mktdata" (market data), a service that follows the subscription paradigm.
The request/response example had application logic to detect the final event of the
request and then break out of the event-wait-loop. Here, there is no final event. A
subscription will continue to send update events until cancelled (not done in this
example) or until the session shut down (handled, as we did before, in the
handleOtherEvent method).
28
Despite these many similarities, the output from the subscription is considerably different
from that of the request/response. Examine the output for a random event in the sequence:
EventType=SUBSCRIPTION_DATA
updateCount = 54
correlationID = User: 2
messageType
= MarketDataEvents
MarketDataEvents = {
LAST_PRICE = 85.71
VOLUME = 18969874
LAST_TRADE = 85.71
LAST_ALL_SESSIONS = 85.71
EQY_TURNOVER_REALTIME = 1.6440605281984758E9
ALL_PRICE_SIZE = 100
ALL_PRICE = 85.71
SIZE_LAST_TRADE_TDY = 100
RT_PX_CHG_NET_1D = -4.29
RT_PX_CHG_PCT_1D = -4.767
VOLUME_TDY = 18969874
LAST_PRICE_TDY = 85.71
LAST2_PRICE = 85.719
LAST_DIR = -1
LAST2_DIR = 1
SIZE_LAST_TRADE = 100
TIME = 19:06:30.000+00:00
TRADE_SIZE_ALL_SESSIONS_RT = 100
EVENT_TIME = 19:06:30.000+00:00
EID = 14005
IS_DELAYED_STREAM = false
}
29
Clearly, this subscription event provides much data in addition to LAST_PRICE, the
specifically requested field (shown in bold above). A later example will demonstrate how a
customer application can extract and use the value of interest.
Note: The Bloomberg infrastructure is at liberty to package additional fields in the
data returned to a client; however, the client cannot validly expect any data except
the requested fields. This sample output shows that the requested field is the first
data out of message; that is happenstance and cannot be assumed.
The output of the otherEventHandler method also shows differences from the first
example.
EventType=SESSION_STATUS
correlationID=null
messageType=SessionStarted
SessionStarted = {
}
EventType=SERVICE_STATUS
correlationID=Internal: 1
messageType=ServiceOpened
ServiceOpened = {
}
EventType=SUBSCRIPTION_STATUS
correlationID=User: 2
messageType=SubscriptionStarted
SubscriptionStarted = {
}
In addition to the events for the start of session and opening of a service, which were seen in
the request/response example, we also see here an event signaling that a subscription has
been initiated. The empty SubscriptionStarted message indicates successful
starting of the subscription; otherwise, there would have been error information. The value of
the CorrelationID informs the customer application which subscription (of possibly
many subscription requests) has been successfully started.
30
3.2 Services
All Bloomberg data provided by the Bloomberg API is accessed through a "service" which
provides a schema to define the format of requests to the service and the events returned
from that service. The customer application's interface to a Bloomberg service is a
Service object.
Accessing a Service is a two step process.
Obtain the Service object using the getService method of the Session
object.
In both stages above, the service is identified by its "name", an ASCII string formatted as
"//namespace/service"; for example, "//blp/refdata".
Once a service has been successfully opened, it remains available for the lifetime of that
Session object.
31
Alternatively, one can supply an EventHandler object when creating a Session. In this
case, the user-defined processEvent method in the supplied EventHandler will be
called by the Bloomberg API when an Event is available. The signature for
processEvent method is:
public void processEvent(Event event, Session session)
// Note: no exceptions are thrown
The calls to the processEvent method will be executed by a thread owned by the
Bloomberg API, thereby making the customer application multi-threaded; consequently
customer applications must, in this case, ensure that data structures and code accessed from
both its main thread and from the thread running the EventHandler object are threadsafe.
The two choices for event handling are mutually exclusive:
32
33
The status for starting the asynchronous session will be received as an event and checked in
the handler. Also, there is no exit from main; logic in the event handler will determine when
the process should be terminated.
The MyEventHandler class is in this example a non-public class (it is used only by
main) implementing the EventHandler interface. The class also defines dumpEvent, a
"helper" function.
class MyEventHandler implements EventHandler {
void dumpEvent(Event event){
Output event type.
For each message, output the type and correlation ID.
}
public void processEvent(Event event, Session session) {
Details below.
}
}
34
35
case Event.EventType.Constants.SESSION_STATUS: {
MessageIterator iter = event.messageIterator();
while (iter.hasNext()) {
Message message = iter.next();
if (message.messageType().equals("SessionStarted")) {
try {
session.openServiceAsync("//blp/refdata",
new CorrelationID(99));
} catch (Exception e) {
System.err.println(
"Could not open //blp/refdata for async");
System.exit(1);
}
} else {
Handle error.
}
}
break;
}
On receipt of a SERVICE_STATUS type event, the messages are searched for one
indicating that the openServiceAsync call was successful: the message type must be
"ServiceOpened" and the correlation ID must match the value assigned when the request
was sent.
36
If the service was successfully opened, we can create, initialize and send a request as has
been shown in earlier examples. The only difference is that the call to sendRequest must
be guarded against the transmission of exceptions, not a concern until now.
case Event.EventType.Constants.SERVICE_STATUS: {
MessageIterator iter = event.messageIterator();
while (iter.hasNext()) {
Message message = iter.next();
if (message.correlationID().value() == 99
&& message.messageType().equals("ServiceOpened")) {
//Construct and issue a Request
Service service = session.getService("//blp/refdata");
Request request =
service.createRequest("ReferenceDataRequest");
request.append("securities", "IBM US Equity");
request.append("fields", "LAST_PRICE");
try {
session.sendRequest(request, new CorrelationID(86));
} catch (Exception e) {
System.err.println("Could not send request");
System.exit(1);
}
} else {
Handle other message types, if expected.
}
}
break;
}
The handling of events containing the requested data is quite similar to the examples already
seen. One difference is that, in this example, on the final event, we terminate the process
from the event handler, not from main.
37
case Event.EventType.Constants.PARTIAL_RESPONSE: {
dumpEvent(event); // Handle Partial Response
break;
}
case Event.EventType.Constants.RESPONSE: {
dumpEvent(event); // Handle final response
// Example complete; shut-down.
try {
session.stop(Session.StopOption.ASYNC);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("terminate process from handler");
System.exit(0);
break;
}
Finally, for completeness, there is a default case to handle events of unexpected types.
default: {
System.err.println("unexpected Event");
dumpEvent(event);
System.exit(1);
break;
}
38
}
private static void handleOtherEvent(Event event) throws Exception {
}
public static void main(String[] args) throws Exception {
create session; start session; open service
create and initialize request
send request
loop until final response is received
}
}
Our focus will be on the creation and initialization of the request in main and, later, on the
extraction of data from the response in the user-defined handleResponseEvent method.
39
4.2 Elements
The services provided by the Bloomberg API collectively accept a great variety of different
types of requests which, in turn, often take many different parameters and options. The data
returned in response is correspondingly diverse in type and organization. Consequently,
requests and responses are composed of Element objects: instances of a class with great
flexibility in representing data.
Firstly, an Element object can contain a single instance of a primitive type such as
an integer or a string. Secondly, Element objects can also be combined into
hierarchical types by the mechanism of SEQUENCE or CHOICE.
arbitrary levels.
The Element class also provides introspective methods (in addition to the introspective
methods provided by the Java language) which allow the programmatic discovery of the
structure of an Element object and any constituent Element objects. However, that level
of generality is required in few applications. Most applications can be written to a known
structure for request and response, as defined in the schema for a service. Should an
applications structural assumptions prove incorrect (e.g., service schemas can be
redefined), then an Exception is generated at run-time.
Note: Incompatible changes to the schema of a Bloomberg core service are very
rare. In fact, so far there have been none. Should such changes ever be necessary,
they will be phased in and announced with ample warning.
40
Given the handle to the service, here named refDataSvc, a Request can be created for
the request type named "ReferenceDataRequest".
As described in the schema, this request consists of three Element objects named
"securities", "fields", and "overrides", each initially empty. These elements
represent arrays of strings so their values can be set by appending strings to them specifying
the securities and fields required, respectively.
request.getElement("securities").appendValue("AAPL US Equity");
request.getElement("securities").appendValue("IBM US Equity");
request.getElement("securities").appendValue("BLAHBLAH US Equity");
request.getElement("fields").appendValue("PX_LAST"); // Last Price
request.getElement("fields").appendValue("DS002");
// Description
request.getElement("fields").appendValue("VWAP_VOLUME");
// Volume used to calculate the Volume Weighted Average Price (VWAP)
The request is now ready to be sent. Note that one of the securities was deliberately set to
an invalid value; later, we will examine the error returned for that item.
Note: This usage pattern of appending values of arrays of Elements occurs so
frequently that the Request class provides convenience methods that are more
concise (but also obscure the Element sub-structure):
request.append("securities", "AAPL US Equity");
request.append("securities", "IBM US Equity");
request.append("securities", "BLAHBLAH US Equity");
request.append("fields", "PX_LAST");
request.append("fields", "DS002");
request.append("fields", "VWAP_VOLUME");
41
The rest of main, specifically the event-loop for the response, is essentially the same as that
used in earlier examples. The main function is shown in its entirety below;
public static void main(String[] args) throws Exception {
Session session = new Session();
session.start();
session.openService("//blp/refdata");
Service refDataSvc = session.getService("//blp/refdata");
Request request = refDataSvc.createRequest("ReferenceDataRequest");
request.getElement("securities").appendValue("AAPL US Equity");
request.getElement("securities").appendValue("IBM US Equity");
request.getElement("securities").appendValue("BLAHBLAH US Equity");
request.getElement("fields").appendValue("PX_LAST"); // Last Price
request.getElement("fields").appendValue("DS002");
// Description
request.getElement("fields").appendValue("VWAP_VOLUME");
// Volume used to calculate Volume Weighted Average Price (VWAP)
session.sendRequest(request, new CorrelationID(1));
boolean continueToLoop = true;
while (continueToLoop) {
Event event = session.nextEvent();
switch (event.eventType().intValue()) {
case Event.EventType.Constants.RESPONSE:
// final response
continueToLoop = false;
// fall through
case Event.EventType.Constants.PARTIAL_RESPONSE:
handleResponseEvent(event);
break;
default:
handleOtherEvent(event);
break;
}
}
}
42
schema, but is also conveniently viewed, as we have done earlier, by printing the response in
the response event handler code.
ReferenceDataResponse (choice) = {
securityData[] = {
securityData = {
security = AAPL US Equity
sequenceNumber = 0
fieldData = {
PX_LAST = 173.025
DS002 = APPLE INC
VWAP_VOLUME = 3.0033325E7
}
}
}
}
The fact that the element named "ReferenceDataResponse" is an array allows each
response event to receive data for several of the requested securities. The Bloomberg API
may return a series of Message objects (each containing a separate
"ReferenceDataResponse") within a series of Event objects in response to a request.
However, each security requested will appear in only one array entry in only one Message
object.
Each element of the "securityData" array is a SEQUENCE that is also named
"securityData". Each "securityData" SEQUENCE contains an assortment of data
including values for the fields specified in the request. The reply corresponding to the
invalidly named security, "BLAHBLAH US Equity", shows that the number and types of
fields in a response can vary between entries.
ReferenceDataResponse (choice) = {
securityData[] = {
securityData = {
security = BLAHBLAH US Equity
securityError = {
source = 100::bbdbs1
code = 15
category = BAD_SEC
message = Unknown/Invalid security [nid:100]
subcategory = INVALID_SECURITY
}
sequenceNumber = 2
fieldData = {
}
}
}
}
This response message has an Element not previously seen, named "securityError".
This Element provides details to explain why data could not be provided for this security.
Note that sending one unknown security did not invalidate the entire request.
4 Requests and Responses
43
Just printing the response in the default format is educational but to perform any real work
with the response the values must be extracted from the received message and assigned
elsewhere for use. The following event handler shows how to navigate the Element
structure of the "ReferenceDataResponse".
The asElement method of Message provides a handle for navigating the contents of the
Message objects using Element methods. If an Element object is an array (e.g.,
securityDataArray) then the numValues method provides the number of items in the
array.
Note: The Element class also provides similarly named method, numElements
(not used in this example), which returns the number of Element objects in a
SEQUENCE.
44
+
+
+
+
+
security);
sequenceNumber);
px_last);
ds002);
vwap_volume);
}
}
}
}
When stepping through the securityData array, the requested Bloomberg fields are
accessed by the name and type (e.g., getElementAsFloat64,
getElementAsInt32) as specified in the schema. Once values have been assigned to
45
local variables they can be used as needed. In this simple example, they are merely output
individually in a distinctive format. The program output is shown below.
*
*
*
*
*
security
=AAPL US Equity
sequenceNumber=0
px_last
=173.025
ds002
=APPLE INC
vwap_volume
=3.0033325E7
*
*
*
*
*
security
=IBM US Equity
sequenceNumber=1
px_last
=126.46
ds002
=INTL BUSINESS MACHINES CORP
vwap_volume
=2885962.0
* security
=BLAHBLAH US Equity
securityError = {
source = 100::bbdbs1
code = 15
category = BAD_SEC
message = Unknown/Invalid security [nid:100]
subcategory = INVALID_SECURITY
}
46
5 Subscriptions
Subscriptions are ideal for data that changes frequently and/or at unpredictable intervals.
Instead of repeatedly polling for the current value your application gets the latest value as
soon as it is available without wasting time and bandwidth when there has been no change.
This chapter contains more details on how you can start, modify, and stop subscriptions as
well as what to expect as the result of a subscription and how to handle those results. This
chapter uses examples from the "//blp/mktdata" service.
Currently, the Bloomberg API services that provide a subscription service are market data
and Custom VWAP. In the future, the Bloomberg API may support delivering information
other than market data through a subscription service.
The service name (for example, "//blp/mktdata"). If you do not specify the
service name the defaultSubscriptionService of the SessionOptions
object is used.
The topic. In the case of "//blp/mktdata" the topic value consists of an optional
symbology identifier followed by an instrument identifier. For example, "/cusip/
097023105" and "/sedol1/2108601" include the symbology identifier
whereas "IBM US Equity" omits the symbology identifier. If you do not specify
the symbology identifier then the defaultTopicPrefix of the
SessionOptions object is used.
Note: The topic's form may be different for different subscription services.
The options. These are qualifiers that can affect the content delivered. Examples in
"//blp/mktdata" include specifying which fields an application requires or
specifying an interval for conflated data.
The correlation ID. Data for each subscription is tagged with a correlation ID
(represented as a CorrelationID object) which must be unique to the session.
The customer application can specify that value when the subscription is created. If
the customer application does not specify a correlation ID, the Bloomberg
infrastructure will supply a suitable value; however, in practice, the internally
generated correlation ID is rarely used. Most customer applications assign
meaningful correlation ids that allow the mapping of incoming data to the originating
request or subscription.
You can represent any subscription as a single string that includes the service name, topic
and options. For example:
//blp/mktdata/cusip/
097023105?fields=LAST_PRICE,LAST_TRADE_ACTUAL" represents a
subscription using the market data service to an instrument (BA) specified by CUSIP
5 Subscriptions
47
The Bloomberg API provides methods which accept the subscription specification as a single
string as well as methods in which the different elements of the subscription are specified as
separate parameters. Subscriptions are typically manipulated in groups so the Bloomberg
API provides methods that operate on a list of subscriptions. This example shows
subscription creation by several of these methods.
SubscriptionList subscriptions
= new SubscriptionList();
CorrelationID
subscriptionID_IBM = new CorrelationId(10);
subscriptions.add(new Subscription("IBM US Equity",
"LAST_TRADE",
subscriptionID_IBM)));
subscriptions.add(new Subscription("/ticker/GOOG US Equity",
"BID,ASK,LAST_PRICE",
new CorrelationID(20)));
subscriptions.add(new Subscription("MSFT US Equity",
"LAST_PRICE",
"interval=.5",
new CorrelationID(30)));
subscriptions.add(new Subscription(
"/cusip/097023105?fields=LAST_PRICE&interval=5.0", //BA US Equity
new CorrelationID(40)));
session.subscribe(subscriptions);
5 Subscriptions
48
CorrelationID. For example, the user-defined "dump" method used previous examples
shows:
eventType=SUBSCRIPTION_STATUS
messageType=SubscriptionStarted
CorrelationID=User: 10
SubscriptionStarted = {
}
messageType=SubscriptionStarted
CorrelationID=User: 20
SubscriptionStarted = {
}
messageType=SubscriptionStarted
CorrelationID=User: 30
SubscriptionStarted = {
}
messageType=SubscriptionStarted
CorrelationID=User: 40
SubscriptionStarted = {
}
In case of an error, there is an Event to report the subscriptions that failed. For example, if
the specification for MSFT (correlation ID 30) above was mistyped (MSFTT) we would get the
event:
eventType=SUBSCRIPTION_STATUS
messageType=SubscriptionFailure
CorrelationID=User: 30
SubscriptionFailure = {
reason = {
source = BBDB@p111
errorCode = 2
category = BAD_SEC
description = Invalid security
}
}
5 Subscriptions
49
See Core Services on page 77 for more details on the "//blp/mktdata" service.
eventType=SUBSCRIPTION_DATA
messageType=MarketDataEvents
CorrelationID=User: 10
MarketDataEvents = {
IND_BID_FLAG = false
IND_ASK_FLAG = false
IS_DELAYED_STREAM = true
TIME = 14:34:44.000+00:00
VOLUME = 7589155
RT_OPEN_INTEREST = 8339549
RT_PX_CHG_PCT_1D = -0.32
VOLUME_TDY = 7589155
LAST_PRICE = 118.15
HIGH = 118.7
LOW = 116.6
LAST_TRADE = 118.15
OPEN = 117.5
PREV_SES_LAST_PRICE = 118.53
EQY_TURNOVER_REALTIME = 8.93027456E8
RT_PX_CHG_NET_1D = -0.379999
OPEN_TDY = 117.5
LAST_PRICE_TDY = 118.15
HIGH_TDY = 118.7
LOW_TDY = 116.6
RT_API_MACHINE = p240
API_MACHINE = p240
RT_PRICING_SOURCE = US
EXCH_CODE_LAST = D
EXCH_CODE_BID = O
SES_START = 09:30:00.000+00:00
SES_END = 16:30:00.000+00:00
}
5 Subscriptions
50
created earlier with the correlation ID of subscriptionID_IBM we can use the following
code fragment:
The client receives an Event object indicating successful re-subscription (or not) before
receipt of any data from that subscription.
Note: The behavior is undefined if the topic of the subscription (e.g., the security
itself) is changed.
5 Subscriptions
51
5 Subscriptions
52
5 Subscriptions
53
Authentication
Who is the consumer?
Authorization
What data is the consumer entitled to see?
Permissioning
The process of enforcing data distribution to only entitled consumer.
54
User mode
When user mode permissioning is used, an Identity is passed as a parameter when
sending a request. This means that all data returned will be already permissioned for that
Identity, but is only for distribution to that particular user or application represented by the
Identity.
Content based
When content based permissioning is used, the entitlement identifiers (EIDs) of incoming
pieces of data is taken and the data is only distributed to users whose Identity contains
the same EIDs as the data.
An application requires only one Identity object per session per Bloomberg user.
This means that your application is not required to authorize the user each time the
user makes a request for data.
55
2.
A Bloomberg user's authorization remains valid until that user logs out from
Bloomberg Professional service and logs in from another host. At that time, your
application will receive an event of type AUTHORIZATION_STATUS, containing a
message of type AuthorizationRevoked.
This is the only time that an Identity must be re-established.
Simply logging out or logging back in from the same host will not invalidate a user's
authorization.
3.
4.
If any entitlements change for the user, the existing Identity object is
automaticaly updated by Bloombergs infrastructure and SDK.
Failure to follow these guidelines may result in exceeding the maximum concurrently active
authorizations limit for a user or application, thereby resulting in further authorizations failing
with error code MAX_AUTHORIZATIONS_EXCEEDED.
Identities can be explicitly cancelled by calling session.cancel on the correlation ID of the
authorisation request that populated them.
56
57
58
<Java>
int uuid = ; // Obtain UUID for user of interest.
String ipAddress = ; // Obtain IP address for user of interest.
Create and start 'session'.
if (!session.openService("//blp/apiauth"))
{
System.out.println("Could not open service " + "//blp/apiauth");
System.exit(1);
}
Service apiAuthSvc = session.getService("//blp/apiauth");
Request authorizationRequest = apiAuthSvc.createAuthorizationRequest();
authorizationRequest.set("uuid", uuid);
authorizationRequest.set("ipAddress", ipAddress);
Identity identity = session.createIdentity();
CorrelationID authorizationRequestID = new CorrelationID(10);
session.sendAuthorizationRequest(authorizationRequest, identity,
authorizationRequestID);
System.out.println("sent Authorization Request using ipAddress");
// Wait for 'AuthorizationSuccess' message which indicates
// that 'identity' can be used.
59
60
Successful authorization loads identity with information (i.e., entitlement data) later used
in the Permissioning phase.
However, if incorrect data is given, say an incorrect IP address, the output is:
61
62
Figure 6-3 shows the procedure for the user authorization system. It is important to note that
the "authentication" section of the diagram MUST be performed on the user's desktop
machine. The "authorization" section can be performed on the server-side application or on
the user's desktop, depending on the application.
For an application authorization system, the OS_LOGIN or DIRECTORY_SERVICE request
is replaced with one for the Application Name as defined on EMRS and this can be run on
any machine.
For a combined application and user authorization system both the user authentication and
the application authentication occurs in a single call and this must be run on the user desktop
machine.
6.4.1 Authentication
The first stage of authentication is creating an Authentication Options string. This is attached
to the SessionOptions object and thus passed into the session when it is created.
For a User
A user's identity can be authenticated by the user's Window's logon identity or a value from
the Active Directory (e.g., email address) associated with the login. The correct
authentication value for each user is made known to the Bloomberg Data Center using the
EMRS<GO> function.
The client application specifies this choice using the setAuthenticationOptions method of the
SessionOptions class. Note that neither option requires the user to input or even be aware of
the value that is used for authentication.
The two options are OS_LOGON and DIRECTORY_SERVICE.
An example of their use is as follows:
const char *authenticationOptions = "AuthenticationType=OS_LOGON"
const char *authenticationOptions = "AuthenticationType=DIRECTORY_SERVICE;
DirSvcProperty=mail";
"mail" is the property name to lookup under Active Directory rather than the value itself. The
libraries will obtain the value from Active Directory using this property name for the currently
logged in user.
A code example demonstrating the use of these can be found below in Token Generation.
For an Application
An application "authenticates" in much the same way as a user. However, instead of using
Active Directory or a Logon, an application name is used as defined in EMRS <GO>.
Rather than using OS_LOGON and DIRECTORY_SERVICE with the
AuthenticationType parameter of the authentication options string, we introduce two
new parameters; AuthenticationMode and ApplicationAuthentication.
63
The above code snippet can be inserted in the following code example to generate a token
for an application registered on EMRS as "TestApplication".
After the token is generated, it should then be used to generate an Identity in the same
way that a user has an identity created using a token.
64
Typically this will be used for authorizing specific users for specific applications and will return
the intersection of the entitlements of the application and the user.
65
<C++>
// ManagedBpipeAuthorization.cpp
66
The token is a long alphanumeric string that has a limited lifespan for validity and needs to be
used in an Authorization request before it expires.
6.5 Authorization
For B-PIPE Authorization, the client application must set as an attribute of the Authorization
request the token obtained during Authentication. Then, as in the other cases, an
"AuthorizationFailure" message indicates failure (with details) and an "AuthorizationSuccess"
message indicates that the identity has been set with the user's or application's entitlements.
The Identity is then used in the same way as it would be in Permissioning in Server API.
Please note that for an application that has been named in EMRS, all requests for data must
have the Identity passed with it, so that only the securities that the application is entitled
for are accessible rather than everything associated with the B-PIPE.
67
<C++>
authentication stage
const char *authorizationServicePath = "//blp/apiauth";
if (!session.openService(authorizationServicePath))
{
std::cerr << "Failed to open "
<< authorizationServicePath
<< std::endl;
return 1;
}
Service authorizationService =
session.getService(authorizationServicePath);
Identity identity = session.createIdentity();
Request authorizationRequest =
authorizationService.createAuthorizationRequest();
authorizationRequest.set("token", token.c_str());
CorrelationId authorizationRequestId(98);
EventQueue authorizationEventQueue;
session.sendAuthorizationRequest(authorizationRequest,
&identity,
authorizationRequestId,
&authorizationEventQueue);
Event authorizationEvent = authorizationEventQueue.nextEvent();
for (MessageIterator messageIterator(authorizationEvent);
messageIterator.next(); )
{
Message message = messageIterator.message();
if (AUTHORIZATION_FAILURE == message.messageType())
std::cerr << "Failed authorization" << std::endl;
return 1;
}
assert(AUTHORIZATION_SUCCESS == message.messageType());
break;
}
rest of client application
68
6.6 Permissioning
6.6.1 Entitlements
Entitlement Identifiers (EIDs) are numeric values associated with data provided by
Bloomberg. The following table contains some EID examples:
Table 1:
EID
Description
Source
Examples
14005
NASDAQ Level 1
NASDAQ
MSFT UQ Equity,
BGN
Bloomberg Generic
CT2@BGN Govt
23599
U.S. Treasures
Merrill Lynch
CT2@ML Govt
14014, 14076c
London Stock
Exchange Level 1 & 2
LSE
VOD LN Equity
INTC UQ Equitya
a. In the example above, MSFT UQ Equity and INTC UQ Equity are both NASDAQ Level 1, and have
the same EID.
b. There can be cases where there are no entitlements associated with the associated instrument. In
such cases the data is to be considered free for all BBA users. Bloomberg Generic Pricing has no
EID and is therefore, free for all Bloomberg users.
c. In the example above, we show that separate EIDs are used to represent London Stock Exchange
Level 1 and Level 2.
The user's EIDs (in the first row, above) are returned in the AuthorizationResponse and are
held in an "Identity". Each Message contained in a SUBSCRIPTION_DATA,
PARTIAL_RESPONSE or RESPONSE Event may contain an EID field.
Note that for reference data, EIDs are currently assigned at the instrument level, not at the
field level. However, for subscription data, EIDs are currently assigned at the instrument and
field level.
The following code fragments show how the entitlements loaded into the Identity during
the authorization stage and can be used to check a user's eligibility to receive given data.
69
First, the data request must be modified to request that entitlement identifiers be included
with the returned data. For example:
<Java>
70
Then, the handler for the resulting events can be modified to use the identity acquired during
authorization:
<Java>
private static void handleResponseEvent(Event event, Identity identity)
throws IOException
{
MessageIterator iter = event.messageIterator();
while (iter.hasNext())
{
Message message = iter.next();
Element ReferenceDataResponse = message.asElement();
if (ReferenceDataResponse.hasElement("responseError"))
{
handle error
}
Element securityDataArray =
ReferenceDataResponse.getElement("securityData");
int numItems = securityDataArray.numValues();
for (int i = 0; i < numItems; ++i)
{
Element securityData =
securityDataArray.getValueAsElement(i);
String security =
securityData.getElementAsString("security");
int sequenceNumber =
securityData.getElementAsInt32("sequenceNumber");
if (securityData.hasElement("securityError"))
{
handle error
}
ArrayList missingEntitlements = new ArrayList();
Element neededEntitlements =
securityData.hasElement("eidData")
? securityData.getElement("eidData")
: null;
if (null == neededEntitlements)
{
forward data to the user
}
else if (identity.hasEntitlements(neededEntitlements,
message.service(),
missingEntitlements))
{
forward data to the user
}
else
{
71
In this example, data is forwarded to a user who has the entitlements for the security, or if the
security has no entitlements.
72
For example,
<Java>
create and open 'session'
Service refDataSvc = session.getService("//blp/refdata");
Request request = refDataSvc.createRequest("ReferenceDataRequest");
request.append("securities", "VOD LN Equity");
request.append("fields", "PX_LAST");
request.append("fields", "DS002");
request.append("fields", "VWAP_VOLUME");
request.set("returnEids", true);
When the response arrives, the customer application must check that EID against the
entitlements of a user before actually delivering the data to that user. A user's entitlements
can be checked by using the hasEntitlements method of the Identity object.
<Java>
Extract 'securityData' from response message
ArrayList missingEntitlements = new ArrayList();
Element neededEntitlements =
securityData.hasElement("eidData")
? securityData.getElement("eidData")
: null;
if (null == neededEntitlements)
{
forward data to the user
}
else if (identity.hasEntitlements(neededEntitlements,
message.service(),
missingEntitlements))
{
forward data to the user
}
else
{
do not forward data to the user
}
Of course, using this strategy, some requests may be satisfied and other rejected.
73
6.7.1 Single-User
Single-User applications are Desktop applications that take a user identity which has been
authorized using the USER_AND_APPLICATION authorization mode. This is used in a User
Mode style and results are passed directly back to the specific user.
6.7.2 Multi-User
Multi-User applications are typically Client-Server (N-tier, etc.) architectures and can either
follow the user mode or content-based permissioning models. User Identities would be again
created using the USER_AND_APPLICATION authorization mode (which also checks to see
if the user is entitled to use that application according to records on EMRS).
The application could then either send the user identities with separate requests and
correlation IDs to get data for individual users, or it can use its own Identity (created just
for the application) to request data (the application Identity is the parameter to the
request or subscription function). EIDs could be extracted from the returned data and thus
can be used in a Server-mode style by distributing to entitled users.
74
In the C API this involved using the bb_connect_server_user call which set the entire
application as tied to that user. All requests would be processed using that user's
entitlements and settings.
.NET used configuration files (or XmlNode objects) with the ServerApiLicense node to
determine the credentials of the user on whose behalf the application was to connect. After
MarketDataAdapter.Startup() was called, all requests would have been serviced as that user.
V3 avoids the issue of having to dedicate the entire program to a single user and instead
allows multiple users in the same application by using Identities as parameters to requests
and subscriptions. The same distribution restrictions as pre-V3 still apply; data downloaded
on behalf of a single user cannot be distributed to another user.
6.8.2 All-or-None
All-or-none permissioning simply compared the set of entitlements of a user against the set of
entitlements of the server. If the user had all of the entitlements of the server then that user
was permitted to receive any data from the server without further checks.
Pre-V3 provided calls to check this.
The C API used the bb_get_authorization function to check this. If any EIDs were returned
then that user did not match the Server on those EIDs and thus would have to be denied
access to all data from the server application.
The .NET API used the LicenseManager.GetRestrictions call. If it returned EIDs then the
user had to be denied access to all data.
V3 removes support for all-or-none systems as these are not considered to be flexible
enough. In addition problems were caused by entitlements sometimes being applied to users
non-homogenously.
75
76
7 Core Services
There are two core and five additional services for accessing Bloomberg data. Each API
service operates with either the subscription or request/response paradigm through following
well-defined schema. The schema defines the request and request options, with detailed
information in Appendix A Schemas. This chapter provides an overview of each of these
services.
Core:
Reference Data Service
"//blp/refdata"
"//blp/mktdata"
Additional:
Custom VWAP Service
"//blp/mktvwap"
"//blp/mktbar"
"//blp/apiflds"
"//blp/pagedata"
"//blp/tasvc"
API Authorization
"//blp/apiauth"
Important Notes:
1.
Each Bloomberg data product using the Bloomberg API may vary in the services
available and also the entirety of the service available. Please see the specific
product overview to determine which services are available.
2.
7 Core Services
77
Syntax
A security must conform to the following syntax:
/[Topic Prefix]/SYMBOLOGY[@Pricing Source][Exchange]
cusip
wpk
isin
buid
sedol1
sedol2
sicovam
common
bsid
svm
cins
cats
bbgid
The default format for a security is the Bloomberg ticker format, for example,
"IBM US Equity". This format consists of:
SYMBOLOGY [Exchange] <Yellow Key>
[Exchange] is optional and is a two character mnemonic for the exchange where
the security is traded. If you do not specify [Exchange] then the default value for the
user or for the Server API process will be used.
<Yellow Key> is the text equivalent of one of the Bloomberg yellow function keys.
Govt
Corp
Mtge
M-Mkt
Muni
Pfd
Equity
Comdty
Index
Curncy
Client
Case Sensitivity
The API will adjust the yellow key (Equity, Cmdty, Index...) to be in the correct format
despite the case that is used. An example is that it will adjust "equity" to "Equity".
The ticker and source are case sensitive and will need to be specified in the correct
casing for it to resolve. The only exception is if all characters are specified in lower
case in which the API will always change to upper case for both the ticker and
source. Hence "vod ln" and "VOD LN" are the same and will both be successful,
however "vOD lN" will not resolve."
7 Core Services
78
If you wish to specify which pricing source should be used append @ followed by the pricing
source to the security, for example, "/cusip/912828GM6@BGN" or "MSFT@ETPX US Equity".
Note for securities in the Curncy Yellow Key use a space instead of @ to separate the security
from the pricing source, for example, "GBPUSD BAAM Curncy".
Corporate, Government, and Preferred securities. To find what pricing sources are available
for a security, load the security then type PCS<GO> on your Bloomberg. This will also tell you
what your preferences for pricing source are for that class of securities. If a pricing is not
listed on this screen, then it is not available through the Bloomberg API.
7.1.3 Fields
Some requests (for example, ReferenceDataRequest or HistoricalDataRequest) as well
as subscriptions require you to specify which fields from the Bloomberg data model you wish
to receive. When using the Reference Data Service you can specify fields using either the
field mnemonic or the CALCRT ID. Returned values have the same name (field mnemonic or
CALCRT ID) specified in the request. However, when creating subscriptions you will only
receive the mnemonic, even if you are passing the CALCRT ID. Therefore, you will want to
use the mnemonic for subscriptions.
You can retrieve information about available fields programmatically using the Bloomberg API
Field Information Service ("//blp/apiflds") or you can use FLDS<GO> on your
BLOOMBERG PROFESSIONAL service.
7.1.4 Overrides
You can use overrides to change the basis on which Bloomberg calculates a derived field.
You can use this facility to perform "what if?" analysis. For example, override the bid price of
a bond (PX_BID) and request the bid yield to maturity (YLD_YTM_BID) based on the value you
supplied for the bid price.
You can retrieve information about which fields react when a particular field is overridden
programmatically by using the Bloomberg API Field Information Service, "//blp/apiflds",
or you can use FLDS<GO> on your BLOOMBERG PROFESSIONAL service.
You can specify up to 100 overrides in a single request. The overrides are specified in the
request as an array of name/value pairs.
The value you supply is always represented as a string. If the override field requires:
A date, then the format is <YYYY><MM><DD>, where <YYYY> is a 4-digit year, <MM> is
a 2-digit month and <DD> is a 2-digit day. Therefore, August 4, 2010 would be
specified as 20100804.
A decimal value, then you must always use a "." (period) character as the decimal
separator regardless of any preferences you may have set in your operating system.
7 Core Services
79
Syntax
The syntax of the Relative Date is:
[A][+/-nCU]
where [A] is the Anchor Date (details below) and [+/-nCU] is the Offset from the Anchor
Date (details below). Both parts are optional and the date is the result of applying the
specified Offset to the specified Anchor.
In the Offset, +/- defines the direction of the offset, n is a non-negative integer multiplier, C is
a Calendar Type, and U is a Period Unit. The integer multiplier in the Offset is optional
Anchor
You may specify the Anchor portion in any of the following formats
The symbol ED is only valid in a start date and represents the supplied end date
anchor.
The symbol SD is only valid in an end date and represents the supplied start date
anchor.
<C><U><n><YYYY>, where:
<C> represents the calendar type, which can be either C (calendar) or F (fiscal).
<U> represents the period unit, which can be either Q (quarterly), S (semiannually) or Y (yearly).
<n> represents a valid integer value for the specified period unit. So, for
Quarterly, <n> must be either 1, 2, 3, or 4. For Semi-annually, <n> must be
<YYYY> represents the year. The valid range is from 1900 to 9999.
Offset
If you supply an offset it must always be in the form <+|->[n]<C><U>, where:
The first character is always a plus (+) or minus (-) sign to indicate the direction of
the offset from the Anchor date.
7 Core Services
80
For Actual or Calendar types the fourth character, <U> is either D (daily), W
(weekly), M (monthly), Q (quarterly), S (semi-annually), or Y (yearly).
For Fiscal calendar types the fourth character, <U>, is either Q (quarterly), S
(semi-annually) or Y (yearly).
If you use the Actual calendar type, the offset is applied precisely with no "rounding". For
example, +2AW from a Tuesday will result in the Tuesday two weeks hence. +1AM from the
16th will result in the 16th of the following month.
If you use the Calendar or Fiscal calendar types, the resulting date is rounded down to the
last active date of the previous period. For example, +1CW from a Tuesday will result in the
Friday of the same week, +1CM from the 16th will result in the last active day of that month,
+CM from the 16th will result in the last active day of the previous month.
If the multiplier is not specified and defaults to 0 the resulting date will be the same as the
Anchor if the Actual calendar type is used. If the Anchor is Calendar or Fiscal calendar type
then the resulting date will be the end of the prior period.
Examples
20080409-1AM represents 9 March 2008 - exactly one month previous to the anchor.
20080409-1CM represents 29 February 2008 - the end of the month prior to 9 March
2008.
A start date of 20080409-3CM and an end date of 20080409-CM will provide a range
that covers the three calendar months prior to the anchor date of 9 April 2008 (that
is, January, February and March).
-3CQ evaluated on 23 June 2008 represents 29 June 2007 (because 30 June 2007
was a Saturday).
A start date of 20080409-2AQ and an end date of SD+1AD represents a range from 9
October 2007 to 10 April 2008 (Note that the SD refers only to the Anchor part of the
start date not the result after adding the offset to the Anchor).
7 Core Services
81
Response Overview
A PARTIAL_RESPONSE or RESPONSE message will be returned. For large requests, a
PARTIAL_RESPONSE will be provided returning part of the information. A RESPONSE
7 Core Services
82
message indicates the request has been fully served. Further information is available in
Appendix A Schemas. This example shows how to process a ReferenceDataResponse:.
private void processReferenceDataResponse(Message msg) throws Exception
{
Element securityDataArray = msg.getElement("securityData");
for (int i = 0; i < securityDataArray.numValues(); ++i) {
Element securityData = securityDataArray.getValueAsElement(i);
System.out.println(securityData.getElementAsString("security"));
Element fieldData = securityData.getElement("fieldData");
for (int j = 0; j < fieldData.numElements(); ++j) {
Element field = fieldData.getElementAt(j);
System.out.println(field.name() + " = " +
field.getValueAsString());
}
System.out.println("\n");
}
}
7 Core Services
83
Response Overview
A successful HistoricalDataResponse holds information on a single security. It contains a
HistoricalDataTable with one HistoricalDataRow for each interval returned.
private void processHistoricalDataResponse(Message msg) throws
Exception {
Element securityData
= msg.getElement("securityData");
Element fieldDataArray = securityData.getElement("fieldData");
for (int j = 0; j < fieldDataArray.numValues(); ++j) {
Element fieldData = fieldDataArray.getValueAsElement(j);
for (int k = 0; k < fieldData.numElements(); ++k) {
Element field = fieldData.getElementAt(k);
System.out.println("\t" + field.name() + " = "
+ field.getValueAsString());
}
}
}
Response Overview
A successful IntradayTickResponse will contain an array of IntradayTickData providing
information on each tick in the specified time range. The time taken to respond to this request
7 Core Services
84
is influenced by the date and time range of your request and the level of market activity
during that period.
private void processIntradayTickResponse(Message msg) throws Exception
{
Element data
= msg.getElement("tickData").getElement("tickData");
int
numItems = data.numValues();
for (int i = 0; i < numItems; ++i) {
Element item = data.getValueAsElement(i);
Datetime time = item.getElementAsDate("time");
String
type = item.getElementAsString("type");
double
value = item.getElementAsFloat64("value");
int
size = item.getElementAsInt32("size");
String
cc;
if (item.hasElement("conditionCodes")) {
cc = item.getElementAsString("conditionCodes");
}
Process values
}
}
7 Core Services
85
Response Overview
A successful IntradayBarResponse will contain an array of BarTickData each of which
contains open, high, low, close, number of events and volume values. Further information is
available in Appendix A Schemas. This example shows how to interpret an
IntradayBarResponse.
private void processIntradayBarResponse(Message msg) throws Exception {
Element data
= msg.getElement("barData").getElement("barTickData");
int
numBars = data.numValues();
for (int i
Element
Datetime
double
double
double
double
int
long
Process
}
The user's portfolio is identified by its Portfolio ID, which can be found on the upper
right hand corner of the toolbar on the portfolio's PRTU<GO> page. This information
can also be accessed historically by using the REFERENCE_DATE override field
and supplying the date in 'YYYYMMDD' format. .
Response Overview
A PARTIAL_RESPONSE or RESPONSE message will be returned. For large requests a
PARTIAL_RESPONSE will be provided returning part of the information. A RESPONSE
message indicates the request has been fully served. Further information is available in
Appendix A Schemas.
7 Core Services
86
Response Overview
A PARTIAL_RESPONSE or RESPONSE message will be returned. For large requests a
PARTIAL_RESPONSE will be provided returning part of the information. A RESPONSE
message indicates the request has been fully served. Further information is available in
Appendix A Schemas.
Response Overview
Once a subscription is established, the stream will supply messages in
SUBSCRIPTION_DATA events. The initial message returned, known as a "SUMMARY"
message, will contain a value for all the fields specified in the subscription. Subsequent
messages may contain values for some or all of the requested Bloomberg fields. It is possible
that a message contains none of the requested Bloomberg fields as the messages are only
filtered based on the fields they could contain rather than the fields they actually contain and
many fields in the streaming events are optional. The Bloomberg API will ensure all
messages that contain any of the fields you have explicitly subscribed for are pushed to your
application. Finally the stream may return additional fields in these messages, for which were
not included in the subscription. These additional fields are not filtered for the purpose of
speed, and their inclusion is subject to change at any time.
Some of the fields that are returned also have a null state. For example the fields BID and
ASK have values of type float and usually give positive values that you can use to populate
your own caches. However there are times when these fields will be set to a null value. In the
case of BID and ASK fields this is usually interpreted as an instruction to clear the values in
your caches. Therefore it is important to test to see if the field is null before you try and
retrieve a value from it.
This example shows how to subscribe for streaming data.
Assume that session already exists and the "//blp/mktdata" service has
been successfully opened.
7 Core Services
87
Response Behavior
The response will return a message containing a selection of VWAP fields.
low
value
open
close
volume
high
number of ticks
datetime
The major advantage of the service is for clients wishing to retrieve HIGH/LOW prices for a
specified time interval in streaming format. A subscription to a market bar requires the
service to be explicitly specified in the topic.
Topic String:
"//BLP/MKTBAR/SYMBOLOGY/SECURITY?START_TIME=st&END_TIME=et&BAR_SIZE=bz"
For example:
"//blp/mktbar/ticker/VOD LN Equity?start_time=9:30&bar_size=10"
7 Core Services
88
MKTBAR service is based on TRADE ticks only. Hence, the subscription topic string should
have the option fields=LAST_PRICE. The following code snippet shows a subscription to
market bars: .
Assume that the blp/mktbar service has already been opened successfully.
SubscriptionList d_subscriptions = new SubscriptionList();
d_subscriptions.add(new Subscription(
"//blp/mktbar/TICKERX/IBM US Equity",
"last_price",
"bar_size=5&start_time=13:30&end_time=20:00",
new CorrelationID("IBM US Equity")));
d_session.subscribe(d_subscriptions);
Response Behavior
Successful subscription to MKTBAR service will result in the following types of messages
being sent to subscriber:
MarketBarStart
MarketBarUpdate
MarketBarIntervalEnd
MarketBarEnd
MarketBarStart is generated upon every new bar; therefore the frequency of this event
will depend upon the bar_size setting and the fact that security is active at the time. A
MarketBarStart event will return all fields of the bar with values filled in since the start if
the bar until subscription time. (See A.4 Market Bar Subscription on page 198.)
Subsequently, on every TRADE update a MarketBarUpdate will be sent.
MarketBarUpdate will only include fields that have updated since the bar start or last
update. Fields that always update are VALUE, VOLUME, NUMBER_OF_TICKS, and
CLOSE.
MarketBarIntervalEnd is sent at the end of each bar and will always precede next
MarketBarStart. This message only contains TIME and DATE.
NOTE:
MarketBarEnd only occurs when the last market bar has been received, i.e., the end_time
has been reached. This message only contains TIME and DATE.
Please note there is no initial summary returned for streaming intraday bars for start date
earlier then now. Reference data intraday bar request before a subscription will be required to
get an initial snapshot if needed.
When a market bar subscription is set to return delayed data, the market bar start message
will not be returned until the delayed period has passed.
7 Core Services
89
7 Core Services
90
Response Behavior
A successful FieldResponse will contain an array of FieldData. The FieldData contains
the field's unique id and information about the field. This example shows how to process a
single FieldResponse.
private void processFieldResponse(Message msg) throws Exception {
Element fieldDataArray = msg.getElement("fieldData");
for (int i = 0; i < fieldDataArray.numValues(); ++i) {
Element fieldData = fieldDataArray.getValueAsElement(i);
Element fieldInfo = fieldData.getElement("fieldInfo");
System.out.println(
fieldData.getElementAsString("id") + " " +
fieldInfo.getElementAsString("mnemonic") + " (" +
fieldInfo.getElementAsString("description") + ") " +
fieldInfo.getElementAsString("datatype"));
}
}
Response Behavior
A FieldSearchRequest returns a FieldResponse just as a FieldInfoRequest does.
7 Core Services
91
Response Behavior
A successful CategorizedFieldResponse will contain an array of CategoryData that
contains a flattened representation of the matching fields arranged by the category tree. This
example shows how to process a single CategorizedFieldResponse.
private void processCategorizedFieldResponse(Message msg) throws
Exception {
Element categoryArray = msg.getElement("category");
for (int i = 0; i < categoryArray.numValues(); ++i) {
Element categoryData = categoryArray.getValueAsElement(i);
System.out.println(
"Category:" + categoryData.getElementAsString("categoryName"));
Element fieldDataArray = categoryData.getElement("fieldData");
for (int j = 0; j < fieldDataArray.numValues(); ++j) {
Element fieldData = fieldDataArray.getValueAsElement(i);
Element fieldInfo = fieldData.getElement("fieldInfo");
System.out.println(
fieldData.getElementAsString("id") + " " +
fieldInfo.getElementAsString("mnemonic") + " (" +
fieldInfo.getElementAsString("description") + ") " +
fieldInfo.getElementAsString("datatype"));
}
}
}
}
7 Core Services
92
0708/012/0001
where:
0708 is the GPGX number
012 is the monitor number
0001 is the page number
An array of strings is used to specify the rows on the page that are of interest. These can be
specified as individual rows, multiple rows separated by commas, or ranges of rows, as
follows:
String
Rows Specified
"1
"1,2,3
"1,6-10,15,16"
The following example shows how to create a subscription, and demonstrates how the
subscription fields are used to pass the rows the user wants to subscribe to.
String topic = "0708/012/0001"
List<string> fields = new List<string>();
fields.Add("15-18");
// subscribing to rows 15 to 18
subscriptions.Add(new Subscription("//blp/pagedata/" + topic,
fields,
null,
new CorrelationID(topic)));
Response Behaviour
Once a subscription has been created, and the subscription status messages have been
processed, two event types might be received:
PageUpdate
A PageUpdate event contains a current view of the entire page. It provides the dimensions of
the page, followed by a rowUpdate element for each row on the page. A full page update will
7 Core Services
93
be received first (all the rows on the page), regardless of the requested rows, and acts as an
initial paint of the page, prior to receiving ongoing updates.
PageUpdate = {
numRows = 23
numCols = 80
rowUpdate[] = {
rowUpdate = {
rowNum = 1
spanUpdate[] = {
spanUpdate = {
startCol = 1
length = 80
text =
attr[] = {
}
fgColor = DARKBLUE
bgColor = WHITE
}
}
}
.
.
.
rowUpdate = {
rowNum = 23
spanUpdate[] = {
spanUpdate = {
startCol = 1
length = 80
text =
attr[] = {
}
fgColor = WHITE
bgColor = DARKBLUE
}
}
}
}
}
RowUpdate
A RowUpdate event consists of a row number, and one or more spanUpdate elements. Each
spanUpdate element describes the location and size of the data (startCol, length), the data
itself (text), any attributes associated with that piece of data, and the foreground and
background colors. The RowUpdate event is structured in exactly the same way as the
rowUpdate element of the PageUpdate event.
7 Core Services
94
RowUpdate = {
rowNum = 15
spanUpdate[] = {
spanUpdate = {
startCol = 61
length = 1
text = 9
attr[] = {
}
fgColor = WHITE
bgColor = DARKBLUE
}
}
}
BLINK
DOUBLEWIDTH
INTENSIFY
POINTANDCLICK
REVERSE
UNDERLINE
AMBER
LIGHTBLUE
BLACK
LIGHTGREEN
DARKBLUE
ORANGE
DARKGREEN
PINK
DEEPBLUE
RED
FLASHINGBLUE
VIOLET
FLASHINGRED
WHITE
GRAY
YELLOW
7 Core Services
95
Description
Historical End of Day
Intraday
Real-time
7 Core Services
96
monthly, bi-annually and annually. Each Historical study request can submit only a single
instrument.
Service tasvcService = session.GetService("//blp/tasvc");
Request request = tasvcService.CreateRequest("studyRequest");
// set security name
request.GetElement("priceSource").
GetElement("securityName").SetValue("IBM US Equity");
// set historical price data
request.GetElement("priceSource").
GetElement("dataRange").SetChoice("historical");
Element historicalEle = request.GetElement("priceSource").
GetElement("dataRange").GetElement("historical");
historicalEle.GetElement("startDate").SetValue("20100501"); // set
study start date
historicalEle.GetElement("endDate").SetValue("20100528"); // set study
end date
// DMI study example - set study attributes
request.GetElement("studyAttributes").SetChoice("dmiStudyAttributes");
Element dmiStudyEle = request.GetElement("studyAttributes").
GetElement("dmiStudyAttributes");
dmiStudyEle.GetElement("period").SetValue(15); // DMI study interval
// set historical data price sources for study
dmiStudyEle.GetElement("priceSourceLow").SetValue("PX_LOW");
dmiStudyEle.GetElement("priceSourceClose").SetValue("PX_LAST");
Response Behaviour
A successful studyResponse holds information on the requested security. It contains a
studyDataTable with one studyDataRow for each interval returned.
7 Core Services
97
7 Core Services
98
Response Behaviour
A successful studyResponse holds information on the requested security. It contains a
studyDataTable with one studyDataRow for each bar interval returned.
7 Core Services
99
7 Core Services
100
Response Behaviour
Once a subscription is established, the stream will supply messages in
SUBSCRIPTION_DATA events. In addition to the study field subscribed, you may receive
additional study fields in these messages which were not subscribed. These additional fields
are not filtered for the purpose of speed and their inclusion is subject to change at any time.
Response Behaviour
The response message indicates a pass or fail.
Request
Operation
InstrumentListRequest Operation
CurveListRequest Operation
GovtListRequest Operation
7 Core Services
101
The following code snippet demonstrates how to make a security lookup request and
assumes that a session already exists and that the "//blp/instruments" service has been
successfully opened.
Service secfService = session.getService("//blp/instruments");
Request request = secfService.createRequest("instrumentListRequest");
request.asElement().setElement("query", "IBM");
request.asElement().setElement("yellowKeyFilter", "YK_FILTER_CORP");
request.asElement().setElement("languageOverride", "LANG_OVERRIDE_NONE");
request.asElement().setElement("maxResults", 10);
sendRequest(request, session);
7 Core Services
102
The following code snippet demonstrates how to make a government lookup request and
assumes that a session already exists and that the "//blp/instruments" service has been
successfully opened.
Service govtService = session.getService("//blp/instruments");
Request request = govtService.createRequest("govtListRequest");
request.asElement().setElement("partialMatch", true);
request.asElement().setElement("query", "T*");
request.asElement().setElement("ticker", "LANG_OVERRIDE_NONE");
request.asElement().setElement("maxResults", 10);
sendRequest(request, session);
7 Core Services
103
7 Core Services
104
7 Core Services
105
8 Publishing
8.1 Overview
The Bloomberg API allows customer applications to publish data as well as consume it.
Customer data can be published for distribution within the customers 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. This chapter will illustrate both paradigms.
Creating a session.
Obtaining authorization.
Session.
8 Publishing
106
// BroadcastOneTopic.cpp
int main()
{
SessionOptions sessionOptions;
sessionOptions.setServerHost("platform");
sessionOptions.setServerPort(8195);
sessionOptions.setAuthenticationOptions("AuthenticationType=OS_LOGON");
MyEventHandler myEventHandler;
ProviderSession session(sessionOptions, &myEventHandler, 0);
if (!session.start()) {
std::cerr <<"Failed to start session." << std::endl;
return 1;
}
}
The event handler plays no significant role in this example and will not be examined.
8.3.2 Authorization
The authorization stage, if successful, provides a valid Identity object which is required
for later operations. Authorization is done by the "//blp/apiauth" service on receipt of
an authorization request.
See for Authorization and Permissioning Systems on page 54 details.
8 Publishing
107
Name TOKEN("token");
Name TOKEN_SUCCESS("TokenGenerationSuccess");
Name TOKEN_FAILURE("TokenGenerationFailure");
Name AUTHORIZATION_SUCCESS("AuthorizationSuccess");
EventQueue tokenEventQueue;
session.generateToken(CorrelationId(), &tokenEventQueue);
std::string token;
Event event = tokenEventQueue.nextEvent();
if (event.eventType() == Event::TOKEN_STATUS) {
MessageIterator iter(event);
while (iter.next()) {
Message msg = iter.message();
msg.print(std::cout);
if (msg.messageType() == TOKEN_SUCCESS) {
token = msg.getElementAsString(TOKEN);
}
else if (msg.messageType() == TOKEN_FAILURE) {
break;
}
}
}
if (token.length() == 0) {
std::cout << "Failed to get token" << std::endl;
}
session.openService("//blp/apiauth");
Service authService = session.getService("//blp/apiauth");
Request authRequest = authService.createAuthorizationRequest();
authRequest.set(TOKEN, token.c_str());
EventQueue authQueue;
Identity providerIdentity = session.createIdentity();
session.sendAuthorizationRequest(
authRequest, &providerIdentity, CorrelationId(), &authQueue);
8 Publishing
108
8 Publishing
109
const std::string myService = "//blp/test";
const std::string myTopic = "testtopic";
TopicList topicList;
topicList.add((myService + "/ticker/" + myTopic).c_str(),
CorrelationId((long long)1));
session.createTopics(
&topicList,
ProviderSession::AUTO_REGISTER_SERVICES,
providerIdentity);
Topic topic;
for (size_t i = 0; i < topicList.size(); ++i) {
if (topicList.statusAt(i) == TopicList::CREATED) {
topic = session.getTopic(topicList.messageAt(i));
}
}
8.3.4 Publishing
In this example, data is published by sending events to the designated service,
"//blp/test". Event objects are obtained from the service and populated with the topic
and the application specific data. In this simple example, each event contains a single data
message; however, in general, each event can contain multiple messages.
In this simple example, the data is just an integer value that is incremented and published
every ten seconds.
8 Publishing
110
Name messageType ("MyMessageType");
Name fieldType ("MyFieldType");
Service service = session.getService(myService.c_str());
for (int value = 1; true; ++value, sleep(10)) {
Event event = service.createPublishEvent();
EventFormatter eventFormatter(event);
eventFormatter.appendMessage(messageType, topic);
eventFormatter.setElement(fieldName, value);
session.publish(event);
}
session.stop();
return 0;
}
Note: The standard C library 'sleep' function is used above. The argument specifies the
number of seconds to sleep.
Creating a session.
Obtaining authorization.
Handling subscription start and stop events, which add and remove topics to the
active publication set.
Creating a topic.
The details for creating a session, obtaining a provider identity, and authorization are the
same as in the earlier example; they will not be detailed again.
This design requires the management of a collection of "active" topics for publication. That
collection will be populated (and depopulated) by event handling threads and accessed for
8 Publishing
111
periodic publication by the main thread. A map will be used to store pairs of topic/CUSIP
pairs (keyed on topic). The topics are provided in the start and stop messages, and CUSIPs
are obtained by requesting resolution of the received topics.
The multiple threads of this application must not concurrently access the collection; STL
containers are not thread-safe in that respect. Since there is only one "reading" thread in this
application, a simple mutex suffices. A pthread mutex was chosen because it is familiar to
many readers.
// InteractivePublisher.cpp
int main(int argc, char **argv)
{
Publications activePublications;
pthread_mutex_t activePublicationsMutex;
pthread_mutex_init(&activePublicationsMutex, NULL);
MyEventHandler myEventHandler(&activePublications,
&activePublicationsMutex);
SessionOptions sessionOptions;
sessionOptions.setServerHost("192.168.9.155");
sessionOptions.setServerPort(8195);
//sessionOptions.setAuthenticationOptions("AuthenticationType=OS_LOGON");
sessionOptions.setAuthenticationOptions("AuthenticationMode=APPLICATION_ONLY;
ApplicationAuthenticationType=APPNAME_AND_KEY;ApplicationName=blp:APP_BBOX");
ProviderSession session(sessionOptions, &myEventHandler, 0);
if (!session.start()) {
std::cerr << "Failed to start session." << std::endl;
return -1;
}
As we will see later, the event handler is designed to hold pointers to the collection of active
topics and to the mutex that manages access to that collection.
8.4.1 Registration
On completion of service registration, the application can expect subscription start and
subscription stop messages in the context of subscription status events.
8 Publishing
112
8 Publishing
113
8 Publishing
114
8.4.3 Publication
The publication loop in this example is, in many ways, similar to that used in the first example.
There is a value that is incremented every ten seconds and is used to create an event for
publication.
8 Publishing
115
Note: The standard C library 'sleep' function is used above. The argument specifies the
number of seconds to sleep.
However, there are some differences (highlighted above):
Rather than a single fixed topic, publication is made for all of the topics in the
collection of active publications.
Note that the mutex is acquired before iterating over that collection.
There is at most one published event per cycle. Each event may have multiple
messages, each with data for a specific topic.
Although sending an empty event would not be harmful, if the collection of active
publications is empty, no event is published for that cycle.
The published data might vary by topic. Details of the myValueFor function are
not important and, therefore, not shown.
8 Publishing
116
9 B-Pipe
9.1 Overview
In addition to the core set of services available to licensed users of the Desktop API and
Server API products, there is an additional set of services that are offered only to B-Pipe
users. The primary purpose of this section is to provide the depth of knowledge required to
understanding and utilizing these services in your Bloomberg API application.
They are as follows:
For information on the core set of services available to B-Pipe users, please see Core
Services on page 77.
Important Notice
Field filtering is available as a configuration option, which means that B-Pipe clients have the
option to change their configurations so that only the fields specified in a subscription are
returned. As a result, clients should be able to recognize significant bandwidth savings on
their Client LAN.
Contact Bloomberg support to have this feature enabled on your Bloomberg Appliance.
117
Many times exchanges consider order book (level 2) information a separate product from its
level 1 data and charge additional fees for access to it. In these cases the level 2 data will
have a different EID than the level 1 data. Order books have three characteristics that define
them: The number of rows in the book (window size), the type of the order book and the
method used to update the book.
There are two types of order books, Market-By-Order (MBO) and Market-By-Level (MBL). An
exchange may provide only MBL data, only MBO data or both MBO and MBL data. There are
three order book update methods, Replace-By-Level (RBL), Add-Mod-Delete (AMD) and
Replace-By-Broker (RBB).
Mnemonic
Description
For further information regarding making a subscription, please read the Subscriptions on
page 47.
Keep in mind that this method of obtaining market depth through the //blp/mktdata service is
limited to receiving only aggregated Market By Level data for up to 10 levels. This service
doesn't allow you to obtain "Market By Order" (MBO) data. Also, the //blp/mktdata service
doesn't provide you with information such as the book type or the action performed on that
position.
Therefore, if you wish to receive more than 10 levels of market depth by level (MBL) or any
market depth by order (MBO) levels, then you will be required to use the //blp/mktdepth
9 B-Pipe
118
service. Subscribing to this comprehensive service will not only supply you with the order
book in its entirety, but also provide you with the book type, action performed, etc.
Code Examples
You will find two separate examples in the B-Pipe SDK for C++, Java and .NET. They are as
follows:
MarketDepthSubscriptionExample
This example demonstrates how to make a simple Market Depth subscription for
one, or more, securities and display all of the messages to std::cout.
MarketDepthSubscriptionSnapshotExample
This example demonstrates how to build and update an order and level book. It is
comprised of a LevelBook and OrderBook class, which handle the Market Depth By
Level and By Order messages, respectively, based upon the returned
MD_TABLE_CMD_RT value, and then the main classes which perform the
subscription, general message handling and output tasks.
Market-by-Level (MBL)
MBL order books show only one row for each price. If multiple brokers have bids or asks in at
the same price the size of all the brokers orders will be summed and be displayed. Optionally,
the number of brokers at that level may also be provided.
The type of an order book is independent of the method used to maintain the order book.
9 B-Pipe
119
Add-Mod-Del (AMD)
The second order book method is Add-Mod-Delete (AMD). It is used for both MBO and MBL
types of order books. The AMD method is much more efficient in sending updates to order
books. Instead of addressing each row in the book individually only the changes to the book
are sent. This means that client applications must manage any related updates resulting from
an Add or Delete event.
For instance, when a new price is inserted at a specific row, the only message sent is the
insert. It is the application's responsibility to adjust the position of all the rows that have been
shifted down. Likewise, when a row is deleted, it is the application's responsibility to shift all
the prices that were below it up. Of course any new price at the bottom of the book requires a
separate "Insert", but this is much more efficient than resending the whole book.
The downside of the AMD method is that it depends on receiving and correctly processing
every update to keep the book accurate. With the RBL method a missed message will result
in the specific row being wrong. But this condition is corrected the next time that row is
updated.
Because a single AMD message can affect a single row, one missed message can result in
the order book being wrong for the rest of the day or until a recap is sent. Because of this,
AMD messages are sent using sequence numbers. If the application detects a gap in the
sequence numbers it can recover from the error by re-requesting the entire order book. In
other words, resubscribe to the book. If the gap is detected as a result of an issue within the
Bloomberg Data Center, Bloomberg will send down an order recap. This form of gap
dectection is covered in a later section.
9 B-Pipe
120
Replace-by-Broker (RBB)
The third order book method is Replace-By-Broker (RBB). Because it addresses specific
broker entries, it is used only for MBO order books. It is a mix of the RBL and AMD methods.
It is similar to the RBL method in that each broker's entry is individually addressed. It is
similar to the AMD method in that a single update affects the entire book. However, unlike the
AMD method, a missed message results in an order book that is wrong only until the next
update for that broker.
Both the RBL and AMD methods specify specific row numbers to identify each entry. The
RBB method does not use row numbers. Instead the broker code is used to identify the entry.
How RBB order books are sorted is left up to the feed handler. The general rule is to use the
price as the primary sort key. The secondary sort key can either be the sequence the orders
at the same price were received or an alphabetic listing of all the brokers at the same price.
Key Field
Format
Example
Bloomberg Symbol
//blp/mktdepth/bsym/source/symbol
//blp/mktdepth/bsym/LN/VOD?type=MBL
//blp/mktdepth/bsym/US/AAPL?type=MBO
Ticker
//blp/mktdepth/ticker/symbol
//blp/mktdepth/ticker/ESM2 Index?type=MBL
BSID
//blp/mktdepth/bsid/bsid
//blp/mktdepth/bsid/399432473346?type=MBO
Bloomberg Unique ID
//blp/mktdepth/buid/source/identifier
//blp/mktdepth/buid/US/EQ0010080100001000?type=MBL
SEDOL
//blp/mktdepth/sedol/source/identifier
//blp/mktdepth/sedol/US/2005973?type=MBL
CUSIP
//blp/mktdepth/cusip/source/identifier
//blp/mktdepth/cusip/US/459200101?type=MBL
ISIN
//blp/mktdepth/isin/source/identifier
//blp/mktdepth/isin/US/US4592001014?type=MBL
Parsekeyable
//blp/mktdepth/bpkbl/identifier
//blp/mktdepth/bpkbl/QCZ1 Index?type=MBL
Bloomberg Global ID
//blp/mktdepth/bbgid /source/bbgid
//blp/mktdepth/bbgid/UP/BBG000BH2658?type=MBO
The following code snippet demonstrates how to subscribe for streaming (MBL) market depth
data and assumes that a session already exists and that the "//blp/mktdepth" service has
been successfully opened.
const char *security = "//blp/mktdepth/isin/US/US4592001014?type=MBL";
SubscriptionList subscriptions;
subscriptions.add(security, CorrelationId((char *)security));
session.susbcribe (subscriptions);
Figure 9-1: C++ code snippet: Subscribing for streaming (MBL) market depth data
9 B-Pipe
121
Response Overview
The Market Depth response will be a series of SUBSCRIPTION_DATA events, which you will
already be familiar with if you have developed Bloomberg API applications using any of the
other streaming services, such as //blp/mktdata or //blp/mktvwap.
A SUBSCRIPTION_DATA event message will be of type MarketDepthUpdates, and within
each message there will be a MKTDEPTH_EVENT_TYPE and
MKTDEPTH_EVENT_SUBTYPE field, along with, possibly, an array of MBO_TABLE_ASK/
MBO_TABLE_BID items (for MBO subscription) or MBL_TABLE_ASK/MBL_TABLE_BID (for
MBL subscriptions).
The MKTDEPTH_EVENT_TYPE will indicate whether the message is Market by Level
(value= MARKET_BY_LEVEL) or Market by Order (value = MARKET_BY_ORDER). Here
are the possible values for each MKTDEPTH_EVENT_SUBTYPE:
MKTDEPTH_EVENT_SUBTYPE
Notes
TABLE_INITPAINT
BID
ASK
BID_RETRANS
ASK_RETRANS
Within each TABLE_INITPAINT message you will find one MD_TABLE_CMD_RT field/value
pairing for the entire initial paint and then individual MD_TABLE_CMD_RT field/value pairings
for each MBL_TABLE_ASK/MBO_TABLE_ASK/ MBL_TABLE_BID/MBO_TABLE_ BID that
may be present. Thereafter, you will see on MD_TABLE_CMD field/value pairing for each BID
or ASK MKTDEPTH_EVENT_SUBTYPE tick update.
9 B-Pipe
122
The possible string values, which indicate what action should be taken in response to the
market depth event, are listed in the table below.
Name
Value
Description
UNASSIGNED
ADD
Add an entry to the order book. When you add this order in the
market depth table, you should shift all orders at the market depth
position in the event and market depth orders or levels inferior to
event passed to one position inferior. For example, if a new order
is added to position one of the market depth table, then the
previous order at position one is shifted to position two. The order
at position two is shifted to position three and so on until you get to
the market depth window size. If the ADD results in Bid or ASK
sides to have more levels than the value configured in
MB[LO]_WINDOW_SIZE, the last level in the corresponding side
should be dropped. It will be up to you to cache
MB[LO]_WINDOW_SIZE from the Initial paint event to handle this
scenario.
DEL
Delete this event from the market depth cache. The delete should
occur at the position passed in the market depth event. When
cached market event at the position passed in the delete is
removed, all position inferior should have their positions shifted by
one. For example, if position one is deleted from a market by
order or market by price event, the position two becomes one,
position three becomes two, etc.
DELALL
Delete all events from the cache. This is a market depth flush
usually passed at the start or end of trading or when a trading halt
occurs.
DELBETTER
Delete this order and any superior orders. The order ID at the next
inferior position is now the best order. This differs from the EXEC
command in that it deletes the current order, where the EXEC
command modifies the current order.
DELSIDE
EXEC
MOD
REPLACE
10
9 B-Pipe
123
Name
Value
Description
REPLACE_BY_BROKER
11
This table command is used for top of file feeds where the action
is to replace by the broker mnemonic. The recipient needs to find
the broker in their cache and replace the quote with the one in the
market depth event. If that broker is not present, it should be
added to the cache. If the price and size for a broker is set to 0,
the broker should be deleted from the cache.
CLEARALL
12
Clears the entire orderbook for the specified side. This market
depth table command is issued by Bloomberg when market depth
recovery is occurring. This table command has the same effect
on the cache as DELETEALL which means all order or levels
should be cleared from the cache. During LVC recovery you will
generally see 2 CLEARALLs - 1 for Bid side and 1 for Ask side.
Should the client of market depth need to process a recovery of
market depth differently, this table command allows the user to
differentiate from the source/exchange produced DELETEALL.
CLEARALL messages may occur without accompanying
RETRANS labels in the event of data loss within Bloomberg
network or upon the receipt of the first tick of a new trading day.
Hence, upon the receipt of a CLEARALL, you should clear your
book and prepare to receive the subsequent recover ADD
messages.
REPLACE_CLEAR
13
The other important enumeration value is found in the Book Type (MD_BOOK_TYPE) field
and is only included in the initial paint message. Here is a complete table covers all three
book types and their possible table command enumeration values.
9 B-Pipe
124
Book Type
(MD_BOOK_TYPE)
MBO[L]-AMD
ADD
MBO[L]-RBL
REPLACE
CLEARALL, REPLACE,
REPLACE_CLEAR
MBO-RBB
REPLACE_BY_BROKER
CLEARALL, REPLACE_BY_BROKER,
REPLACE_CLEAR
The following code snippet demonstrates how to handle and print out a MarketDepth
subscription to std::cout. This C++ snippet is based on the aforementioned
"MarketDepthSubscriptionExample" C++ SDK example. For a more complete example that
demonstrates how to handle and build an order/level book, please reference the
aforementioned "MarketDepthSubscriptionSnaphotExample" example in either the Java,
C++ or .NET SDK.
bool processEvent(const Event &event, Session *session)
{
try {
switch (event.eventType())
{
case Event::SUBSCRIPTION_DATA:
{
char timeBuffer[64];
getTimeStamp(timeBuffer, sizeof(timeBuffer));
std::cout << "Processing SUBSCRIPTION_DATA" << std::endl;
MessageIterator msgIter(event);
while (msgIter.next()) {
Message msg = msgIter.message();
std::string *topic = reinterpret_cast<std::string*>(
msg.correlationId().asPointer());
std::cout << timeBuffer << ": " << topic->c_str() << " - " ;
msg.print(std::cout);
}
break;
}
case Event::SUBSCRIPTION_STATUS:
return processSubscriptionStatus(event);
break;
default:
return processMiscEvents(event);
break;
}
} catch (Exception &e) {
std::cout << "Library Exception !!! " << e.description().c_str() << std::endl;
}
return false;
}
9 B-Pipe
125
You will notice that the above code checks the EventType being returned and looks for
SUBSCRIPTION_DATA. Please note that the processSubscriptionStatus() and
processMiscEvents() functions were not shown for brevity. You will also notice that the event
handler for the tick updates is identical to that of a //blp/mktdata subscription, for instance.
FRAGMENT_START
FRAGMENT_INTERMEDIATE
FRAGMENT_END
if (subType == TABLE_INITPAINT) {
if (msg.fragmentType() == BloombergLP::blpapi::Message::Fragment::FRAGMENT_START ||
msg.fragmentType() == BloombergLP::blpapi::Message::Fragment::FRAGMENT_NONE) {
if (msg.hasElement(MBO_WINDOW_SIZE, true) ){
d_orderBooks[Side::ASKSIDE].window_size = (unsigned int)
msg.getElementAsInt64(MBO_WINDOW_SIZE);
d_orderBooks[Side::BIDSIDE].window_size =
d_orderBooks[Side::ASKSIDE].window_size;
}
d_orderBooks[Side::ASKSIDE].book_type = msg.getElementAsString(MD_BOOK_TYPE);
d_orderBooks[Side::BIDSIDE].book_type = d_orderBooks[Side::ASKSIDE].book_type;
// clear cache
d_orderBooks[Side::ASKSIDE].doClearAll();
d_orderBooks[Side::BIDSIDE].doClearAll();
}
}
9 B-Pipe
126
9 B-Pipe
127
9 B-Pipe
128
MBO_TABLE_BID[] = {
MBO_TABLE_BID = {
MBO_BID_POSITION_RT = 1
MBO_BID_RT = 11.3100004196167
MBO_BID_BROKER_RT = " 79"
MBO_BID_COND_CODE_RT = ""
MBO_ORDER_ID_RT = "32353235000075f8004f"
MBO_BID_SIZE_RT = 1400
MBO_TIME_RT = 2012-05-25T19:46:59.000+00:00
MD_TABLE_CMD_RT = ADD
}
MBO_TABLE_BID = {
MBO_BID_POSITION_RT = 2
MBO_BID_RT = 11.3100004196167
MBO_BID_BROKER_RT = " 79"
MBO_BID_COND_CODE_RT = ""
MBO_ORDER_ID_RT = "323532350000761a004f"
MBO_BID_SIZE_RT = 500
MBO_TIME_RT = 2012-05-25T19:47:33.000+00:00
MD_TABLE_CMD_RT = ADD
}
(more)
}
Processing SUBSCRIPTION_DATA
MarketDepthUpdates = {
MKTDEPTH_EVENT_TYPE = MARKET_BY_ORDER
MKTDEPTH_EVENT_SUBTYPE = ASK
EID = 14184
MD_TABLE_CMD_RT = DEL
MBO_SEQNUM_RT = 199951
MBO_ASK_POSITION_RT = 7
MBO_ASK_RT = 11.3199996948242
MBO_ASK_BROKER_RT = " 79"
MBO_ASK_COND_CODE_RT = ""
MBO_ORDER_ID_RT = "323532350000774e004f"
MBO_ASK_SIZE_RT = 500
MBO_TIME_RT = 2012-05-25T19:53:55.000+00:00
MBL_TABLE_ASK[] = {
}
MBL_TABLE_BID[] = {
}
MBO_TABLE_ASK[] = {
}
MBO_TABLE_BID[] = {
}
}
9 B-Pipe
129
Processing SUBSCRIPTION_DATA
/bsym/CT/RIM - MarketDepthUpdates = {
MKTDEPTH_EVENT_TYPE = MARKET_BY_ORDER
MKTDEPTH_EVENT_SUBTYPE = TABLE_INITPAINT
ID_BB_SEC_NUM_SRC = 502511690826
FEED_SOURCE = "CT"
EID = 14184
MD_TABLE_CMD_RT = ADD
MD_BOOK_TYPE = MBO-AMD
MBO_WINDOW_SIZE = 200
MBL_TABLE_ASK[] = {
}
MBL_TABLE_BID[] = {
}
MBO_TABLE_ASK[] = {
MBO_TABLE_ASK = {
MBO_ASK_POSITION_RT = 200
MBO_ASK_RT = 12
MBO_ASK_BROKER_RT = " 80"
MBO_ASK_COND_CODE_RT = ""
MBO_ORDER_ID_RT = "3235313500000c390050"
MBO_ASK_SIZE_RT = 100
MBO_TIME_RT = 2012-05-25T15:20:49.000+00:00
MD_TABLE_CMD_RT = ADD
}
}
MBO_TABLE_BID[] = {
}
}
Notes:
The first message above is the initial paint (as indicated by the TABLE_INITPAINT event subtype (i.e., MKTDEPTH_EVENT_SUBTYPE)) and indicates that it is a Market-By-Order
message, as indicated by the MARKET_BY_ORDER event type (i.e.,
MKTDEPTH_EVENT_TYPE). Within the initial paint message, you will find a table of asks
and bids. In this case, it is an MBO request, so the table will be of MBO bids and asks
(indicated by MBO_TABLE_BID[] and MBO_TABLE_ASK[] array items). When you receive
an initial paint message, you should clear your book prior to populating with the table of Asks
and Bids.
Because this is an AMD (Add-Mod-Del) MBO Book Type, the MD_TABLE_CMD_RT field in
the initial paint is ADD. The valid table commands for subsequent AMD type message
updates are ADD, MOD, DELETE and CLEARALL.
9 B-Pipe
130
9 B-Pipe
131
MBO_TABLE_BID[] = {
MBO_TABLE_BID = {
MBO_BID_RT = 514.900146484375
MBO_BID_BROKER_RT = "ADAM"
MBO_BID_BROKER_MODE_RT = OPEN
MBO_BID_COND_CODE_RT = ""
MBO_BID_COND_CODE_SRC_RT = ""
MBO_BID_LSRC_RT = "UQ"
MBO_BID_SIZE_RT = 100
MBO_TIME_RT = 2012-05-25T13:44:01.000+00:00
MD_TABLE_CMD_RT = REPLACE_BY_BROKER
}
MBO_TABLE_BID = {
MBO_BID_RT = 560.60009765625
MBO_BID_BROKER_RT = "ARCX"
MBO_BID_BROKER_MODE_RT = OPEN
MBO_BID_COND_CODE_RT = ""
MBO_BID_COND_CODE_SRC_RT = ""
MBO_BID_LSRC_RT = "UP"
MBO_BID_SIZE_RT = 200
MBO_TIME_RT = 2012-05-25T19:24:13.000+00:00
MD_TABLE_CMD_RT = REPLACE_BY_BROKER
}
(more)
}
}
Processing SUBSCRIPTION_DATA
MarketDepthUpdates = {
MKTDEPTH_EVENT_TYPE = MARKET_BY_ORDER
MKTDEPTH_EVENT_SUBTYPE = BID
EID = 14023
MD_TABLE_CMD_RT = REPLACE_BY_BROKER
MBO_TIME_RT = 2012-05-25T19:24:14.000+00:00
MBO_BID_RT = 560.56005859375
MBO_BID_BROKER_RT = "NQBX"
MBO_BID_BROKER_MODE_RT = OPEN
MBO_BID_COND_CODE_RT = ""
MBO_BID_COND_CODE_SRC_RT = ""
MBO_BID_LSRC_RT = "UB"
MBO_BID_SIZE_RT = 100
MBL_TABLE_ASK[] = {
}
MBL_TABLE_BID[] = {
}
MBO_TABLE_ASK[] = {
}
MBO_TABLE_BID[] = {
}
}
9 B-Pipe
132
Processing SUBSCRIPTION_DATA
MarketDepthUpdates = {
MKTDEPTH_EVENT_TYPE = MARKET_BY_ORDER
MKTDEPTH_EVENT_SUBTYPE = BID
EID = 14023
MD_TABLE_CMD_RT = REPLACE_BY_BROKER
MBO_TIME_RT = 2012-05-25T19:24:14.000+00:00
MBO_BID_RT = 560.60009765625
MBO_BID_BROKER_RT = "ARCX"
MBO_BID_BROKER_MODE_RT = OPEN
MBO_BID_COND_CODE_RT = ""
MBO_BID_COND_CODE_SRC_RT = ""
MBO_BID_LSRC_RT = "UP"
MBO_BID_SIZE_RT = 100
MBL_TABLE_ASK[] = {
}
MBL_TABLE_BID[] = {
}
MBO_TABLE_ASK[] = {
}
MBO_TABLE_BID[] = {
}
}
Notes:
The first message above is the initial paint (as indicated by the TABLE_INITPAINT event subtype (i.e., MKTDEPTH_EVENT_SUBTYPE)) and indicates that it is a Market-By-Order
message, as indicated by the MARKET_BY_ORDER event type (i.e.,
MKTDEPTH_EVENT_TYPE). Within the initial paint message, you will find a table of asks
and bids. In this case, it is an MBO request, so the table will consist of MBO bids and asks
(indicated by MBO_TABLE_BID[] and MBO_TABLE_ASK[] array items). When you receive
an initial paint message, you should clear your book prior to populating with the array of Asks
and Bids.
Because this is a Request-By-Broker (RBB) MBO Book Type, the MD_TABLE_CMD_RT field
in the initial paint and subsequent update is REPLACE_BY_BROKER. The other valid table
commands for an RBB type are REPLACE_CLEAR and CLEARALL, which are sent by the
exchange.
9 B-Pipe
133
order book be resent. The bandwidth impact for small order books is minimal but can be
extreme for large order books. For this reason AMD is often used for large order books.
MBL-RBL Subscription Output (for //blp/mktdepth/ticker/ESM2 Index?type=MBL),
Processing SUBSCRIPTION_DATA
MarketDepthUpdates = {
MKTDEPTH_EVENT_TYPE = MARKET_BY_LEVEL
MKTDEPTH_EVENT_SUBTYPE = TABLE_INITPAINT
ID_BB_SEC_NUM_SRC = 2078784978839
FEED_SOURCE = "eCME"
EID = 14002
MD_TABLE_CMD_RT = REPLACE
MD_BOOK_TYPE = MBL-RBL
MBL_WINDOW_SIZE = 10
MBL_TABLE_ASK[] = {
MBL_TABLE_ASK = {
MBL_ASK_POSITION_RT = 1
MBL_ASK_RT = 1314.75
MBL_ASK_COND_CODE_RT = ""
MBL_ASK_NUM_ORDERS_RT = 35
MBL_ASK_SIZE_RT = 384
MBL_TIME_RT = 2012-05-25T20:05:13.302+00:00
MD_TABLE_CMD_RT = REPLACE
}
MBL_TABLE_ASK = {
MBL_ASK_POSITION_RT = 2
MBL_ASK_RT = 1315
MBL_ASK_COND_CODE_RT = ""
MBL_ASK_NUM_ORDERS_RT = 65
MBL_ASK_SIZE_RT = 397
MBL_TIME_RT = 2012-05-25T20:05:13.648+00:00
MD_TABLE_CMD_RT = REPLACE
}
(more)
9 B-Pipe
134
MBL_TABLE_BID[] = {
MBL_TABLE_BID = {
MBL_BID_POSITION_RT = 1
MBL_BID_RT = 1314.5
MBL_BID_COND_CODE_RT = ""
MBL_BID_NUM_ORDERS_RT = 65
MBL_TIME_RT = 2012-05-25T20:05:13.043+00:00
MBL_BID_SIZE_RT = 427
MD_TABLE_CMD_RT = REPLACE
}
MBL_TABLE_BID = {
MBL_BID_POSITION_RT = 2
MBL_BID_RT = 1314.25
MBL_BID_COND_CODE_RT = ""
MBL_BID_NUM_ORDERS_RT = 69
MBL_TIME_RT = 2012-05-25T20:05:11.351+00:00
MBL_BID_SIZE_RT = 631
MD_TABLE_CMD_RT = REPLACE
}
(more)
}
}
Processing SUBSCRIPTION_DATA
MarketDepthUpdates = {
MKTDEPTH_EVENT_TYPE = MARKET_BY_LEVEL
MKTDEPTH_EVENT_SUBTYPE = ASK
EID = 14002
MD_TABLE_CMD_RT = REPLACE
MD_MULTI_TICK_UPD_RT = 0
MBL_ASK_POSITION_RT = 2
MBL_ASK_RT = 1315
MBL_ASK_COND_CODE_RT = ""
MBL_ASK_NUM_ORDERS_RT = 66
MBL_ASK_SIZE_RT = 398
MBL_TIME_RT = 2012-05-25T20:05:14.085+00:00
MBL_TABLE_ASK[] = {
}
MBL_TABLE_BID[] = {
}
MBO_TABLE_ASK[] = {
}
MBO_TABLE_BID[] = {
}
}
9 B-Pipe
135
Processing SUBSCRIPTION_DATA
MarketDepthUpdates = {
MKTDEPTH_EVENT_TYPE = MARKET_BY_LEVEL
MKTDEPTH_EVENT_SUBTYPE = ASK
EID = 14002
MD_TABLE_CMD_RT = REPLACE
MD_MULTI_TICK_UPD_RT = 0
MBL_ASK_POSITION_RT = 2
MBL_ASK_RT = 1315
MBL_ASK_COND_CODE_RT = ""
MBL_ASK_NUM_ORDERS_RT = 65
MBL_ASK_SIZE_RT = 397
MBL_TIME_RT = 2012-05-25T20:05:14.148+00:00
MBL_TABLE_ASK[] = {
}
MBL_TABLE_BID[] = {
}
MBO_TABLE_ASK[] = {
}
MBO_TABLE_BID[] = {
}
}
Notes:
The first message above is the initial paint (as indicated by the TABLE_INITPAINT event subtype (i.e. MKTDEPTH_EVENT_SUBTYPE)) and indicates that it is a Market-By-Level (MBL)
message, as indicated by the MARKET_BY_LEVEL event type (i.e.
MKTDEPTH_EVENT_TYPE). Within the initial paint message, you will find the
MBL_WINDOW_SIZE. This indicates the number of levels in the book, along with the table
command (i.e. MD_TABLE_CMD_RT) with a value of "REPLACE" and book type (i.e.
MD_BOOK_TYPE) with a value of "MBL-RBL".
Because this is a Request-By-Level (RBL) MBL Book Type, the MD_TABLE_CMD_RT field
in the initial paint is REPLACE and all subsequent updates will possess a table command of
either REPLACE_CLEAR, REPLACE or CLEARALL. This is true for both MBO and MBL
event types. The output above includes a sample BID/REPLACE and ASK/
REPLACE_CLEAR message.
9 B-Pipe
136
Gap Detection
Data gaps occur as a result of missed network messages. While rare, as in every complex
networked system, missed messages can occur at any level and for many reasons. If a data
gap occurs between the B-Pipe order book systems and the application, it is the client
application's responsibility to take action to restore the order book to an accurate state. If the
gap is detected by the Bloomberg upstream order book systems, B-Pipe will automatically
initiate the recap without any action by the client application.
When B-Pipe detects a gap in the MBL or MBO "AMD" order book, the
MD_GAP_DETECTED field is present and set to "true" in every market depth update
message for each effected order book. This informs the client application that B-Pipe has
detected the gap and to expect an automatic recap.
MD_GAP_DETECTED will not be present once the recap is sent. Therefore, even though a
client application detects a gap, if this field is present in market depth update messages, no
further action is required by the client application except to begin reading the recap
messages, which will follow immediately and be indicated with a
MKTDEPTH_EVENT_SUBTYPE of BID_RETRANS and ASK_RETRANS in each message
update. In cases where a sequence number gap is detected but the MD_GAP_DETECTED
field is not present in the message, it is the responsibility of the client application to request a
recap (i.e., resubscribe) to the order book.
Table 9-1: Fields Affected by Recaps
Fields
Descriptions
MKTDEPTH_EVENT_SUBTYPE
MBL_SEQNUM_RT and
MBO_SEQNUM_RT
Present in every market depth message for AMD, and only AMD,
order books. They will have a value of 0 if the message is part of an
order book recap, regardless of how initiated. Gap detection does
not apply to recaps. The value of these fields in the first non-recap
market depth update message following the recap will have a nonzero value which should be used to detect any gaps following the
recap.
MD_TABLE_CMD_RT
9 B-Pipe
137
Fields
Descriptions
MD_MULTI_TICK_UPD_RT
For a book with a book size of 5 and 5 active levels, what happens when the
exchange needs to delete level 3?
The answer varies based on the book type. For instance,
For BookType=MB[LO]-RBL:
REPLACE POSITION=3
REPLACE POSITION=4
REPLACE_CLEAR POSITION=5
For Booktype=MB[LO]-AMD:
DELETE POSITON=3
9 B-Pipe
138
<service name>
<subservice name>
/chain
/secids
/cusip
Requests by CUSIP
/sedol
Requests by SEDOL
/isin
Requests by ISIN
/bsid
/bsym
/buid
/eid
/source
/gdco
/bpkbl
/esym
/ticker
/bbgid
<topic type>
<topic key>a
/cusip
/sedol
/isin
/bpkbl
/buid
/bsym
/bbgid
/bsid
/source
/gdco
/eid
/ticker
9 B-Pipe
139
Code Examples
You will find two separate examples in the B-Pipe SDK for C++, Java, and .NET. They are as
follows:
MarketListSubscriptionExample
This example demonstrates how to make a simple Market List "chain" subscription
for one, or more, securities and displays all of the messages to the console window.
MarketListSnapshotExample
This example demonstrates how to make a Market List "secids" snapshot request
and displays the message to the console window.
Now that you have a better understanding as to how a //blp/mktlist subscription or snapshot
string is formed, it is now time to use it in your application. The following sections provide
further details as to how to subscribe to a chain of instruments and request a Snapshot of a
list of members.
9 B-Pipe
140
Index and Curve lists are handled differently. The list's members are maintained by the
Bloomberg Data Center. Once it is determined that this list subscription is for index or curve
members, the Bloomberg Data Center is queried for the list of members. This list contains the
terminal ticker (ParseKeyable symbol) for each member, which is resolved to an instrument
on B-Pipe. It is possible that an index or curve list member is not available on B-Pipe. In this
case, the list member will be included in the list, but return only the ParseKeyable symbol.
This allows the requestor to contact Bloomberg about getting the missing instrument added
to B-Pipe.
The default security class of the list members depends on the security class of the underlying
instrument specified in the request. The default can be overridden using the optional
parameter "secclass". Table 9-3 defines the default security class of the list members for
each underlying instrument security class
.
Table 9-3: Default Security Class of List Members
Underlying Security Class
Currency
Option
Equity
Option
Fixed Income
N/A
Fund
Option
Future Root
Future
Future Contract
Option
Index
Members
Option
N/A
Warrant
N/A
Curve
Members
An alternate security class for the returned members is available and can be specified in the
subscription string using a parameter. For example, the following chain requests are
equivalent because the default member security class is Option:
//blp/mktlist/chain/bsym/US/IBM
//blp/mktlist/chain/bsym/US/IBM;secclass=Option
However, by using a parameter, we can obtain a list of Futures with IBM as the underlying
instrument:
//blp/mktlist/chain/bsym/US/IBM;secclass=Future
In order to further qualify the subscription string, a parameter "source" can be applied. The
value of this parameter is assigned by the user or application to limit the amount of returned
members to those belonging to the specified source(s) only. More than one value is allowed
for this parameter.
9 B-Pipe
141
The "source" can be substituted by a "~". This value can be used when the client assumes
that there is only one source for the security and there is no actual need to specify it. If this is
the case, the subscription request will be processed successfully, but if the security has more
than one source and the request is ambiguous, then the client will receive a
SubscriptionFailure response with a NOTUNIQUE description. An example of such a
subscription string would be "//blp/mktlist/chain/cusip/~/459200101".
Table 9-4: Chain Subservice Examples
Type of
Chain List
Topic
Type
Topic Keya
Refreshesb
Option
Chains
//blp/mktlist/chain/bsym/LN/VOD
/bsym
/<DX282>/<DY003>
No
//blp/mktlist/chain/bsid/678605358297
/bsid
/<ID122>
No
//blp/mktlist/chain/buid/LN/EQ0010160500001000
/buid
/<DX282>/<ID059>
No
//blp/mktlist/chain/bbid/LN/EQ0010160500001000
/bbid
/<DX282>/<ID059>
No
//blp/mktlist/chain/bpkbl/VOD LN Equity
/bpkbl
/<DX194>
No
//blp/mktlist/chain/esym/LN/VOD
/esym
/<DX282>/<EX005>
No
/blp/mktlist/chain/cusip/UN/459200101
/cusip
/<DX282>/<ID032>
No
//blp/mktlist/chain/isin/LN/GB00BH4HKS39
/isin
/<DX282>/<ID005>
No
//blp/mktlist/chain/sedol/LN/BH4HKS3
/sedol
/<DX282>/<ID002>
No
//blp/mktlist/chain/bbgid/LN/BBG000C6K6G9
/bbgid
/<DX282>/<ID135>
No
//blp/mktlist/chain/ticker/VOD LN Equity
/ticker
/<DX194>
No
Index List
//blp/mktlist/chain/bsym/FTUK/UKX Index;secclass=Option
/bsym
/<DX282>/<DY003>
Daily
Yield Curve
//blp/mktlist/chain/bpkbl/YCMM0010 Index
/bpkbl
/<identifier>
Daily
GDCO
//blp/mktlist/chain/gdco/broker/id
/gdco
/<broker_id>/<mon_id>
N/A
EID List
//blp/mktlist/chain/eid/14014
/eid
/<source>
No
Source List
//blp/mktlist/chain/source/UN;secclass=Equity
/source
/<source>
No
a.
b.
The FLDS <GO> identifier associated with the expected key values for that particular topic is listed, where
applicable, which can be found on FLDS <GO> on the Bloomberg Professional service
Denotes whether that particular subscription (based on the <topic type> of the subscription string) will refresh
and at what periodicity. For Daily refreshes, this will occur at the start of a new market day.
Mnemonic
FLDS <GO>
Identifier
Mnemonic
DX194
PARSEKYABLE_DES_SOURCE
ID005
ID_ISIN
DX282
FEED_SOURCE
ID032
ID_CUSIP
DY003
ID_BB_SEC_NUM_DES
ID059
ID_BB_UNIQUE
EX005
ID_EXCH_SYMBOL
ID122
ID_BB_SEC_NUM_SRC
ID002
ID_SEDOL1
ID035
ID_BB_GLOBAL
9 B-Pipe
142
Returns
//blp/mktlist/chain/bsym/FTUK/UKX Index;secclass=Option
//blp/mktlist/chain/bsym/FTUK/UKX Index;secclass=Option&source=LN
//blp/mktlist/chain/cusip/~/459200101
SubscriptionFailure: ErrorCode=2;
Description=NOTUNIQUE; Category=BAD_SEC
Note: NOTUNIQUE is returned because the security
has more than one source and the request is
ambiguous.
//blp/mktlist/chain/bsid/1086627109973
//blp/mktlist/chain/bsym/US/IBM;secclass=Future
//blp/mktlist/chain/bpkbl/YCMM0010 Index
//blp/mktlist/chain/eid/38736
//blp/mktlist/chain/bsym/US/HP
//blp/mktlist/chain/bsym/DJI/INDU Index
//blp/mktlist/chain/bsid/1086627109973
//blp/mktlist/chain/isin/LN/GB00B16GWD56;secclass=Warrant
//blp/mktlist/chain/bsym/FTUK/UKX Index;secclass=Index
//blp/mktlist/chain/source/UN;secclass=Equity
//blp/mktlist/chain/bsym/BGN/YCCF0009 Index
//blp/mktlist/chain/bsid/1086627109973
//blp/mktlist/chain/bpkbl/IBM US Equity
//blp/mktlist/chain/isin/LN/GB00B16GWD56;secclass=Warrant
//blp/mktlist/chain/bsym/eNYL/XG1;secclass=Future
The following code snippet demonstrates how to subscribe for streaming market list chain
data and assumes that a session already exists and that the "//blp/mktlist" service has been
successfully opened.
const char *security = "//blp/mktlist/chain/esym/LN/BP";
SubscriptionList subscriptions;
subscriptions.add(security, CorrelationId((char *)security));
session.susbcribe (subscriptions);
9 B-Pipe
143
Response Overview
The Market List response will be a series of SUBSCRIPTION_DATA events, which you will
be familiar with if you have developed Bloomberg API applications using any of the other
streaming services, such as //blp/mktdata, //blp/mktvwap or //blp/mktdepth.
A SUBSCRIPTION_DATA event message will either be of type ListRecap or ListData. The
initial such event message(s) will be of type ListRecap. These represent the initial paint of
your chain of instruments. Within a single ListRecap message, you will find a
LIST_LISTTYPE, comprising zero, or more, LIST_INSERT_ENTRIES.
If a subscription is made for a chain that does not contain any members, an empty list will be
returned. An example of this is requesting the options for an equity that does not have any
options. Although, there are no options for the equity, the subscription succeeds and a single
ListRecap message will be received with LIST_INSERT_ENTRIES[] showing no elements. If
the LIST_MUTABLE field value, from the ListRecap message is equal to 'MUTABLE', then
that means there could be ListData items received later on, so you may wish to keep the
subscription alive. The newly created members are then added to the previously empty list.
However, if the LIST_MUTABLE field is 'IMMUTABLE', then that means it will not return any
further updates and you may wish to terminate the subscription by unsubscribing. This is
explained further in the following paragraph.
Various types of lists are available for a subscription. Though the subscription formats are the
same, the lists could be:
ORDERED
UNORDERED
IMMUTABLE
9 B-Pipe
144
Description
CLEAR
ADD
CLEAR_AND_ADD
Delete all of the existing list members and then Add all
of the list members in this sequence
DELETE
END
CLEAR_AND_END
ADD_AND_END
Add all of the list members in this set and end. There
are no more entries in this sequence
CLEAR_AND_ADD_AND_END
DELETE_AND_END
9 B-Pipe
145
ListRecap = {
LIST_ID = //blp/mktlist/chain/source/TQ
EID = 35009
LIST_LISTTYPE = Source List
LIST_INSERT_ENTRIES[] =
LIST_INSERT_ENTRIES = {
ID_BB_SEC_NUM_SRC = 7992941317759
FEED_SOURCE = TQ
ID_BB_SEC_NUM_DES = RHI
ID_BB_UNIQUE = EQ0000000006685436
SECURITY_TYP2 = Equity
}
LIST_INSERT_ENTRIES = {
ID_BB_SEC_NUM_SRC = 7992941317760
FEED_SOURCE = TQ
ID_BB_SEC_NUM_DES = GIL
ID_BB_UNIQUE = EQ0000000006687052
SECURITY_TYP2 = Equity
}
...MORE...
LIST_INSERT_ENTRIES = {
ID_BB_SEC_NUM_SRC = 7992961685384
FEED_SOURCE = TQ
ID_BB_SEC_NUM_DES = ECONB
ID_BB_UNIQUE = EQ0000000023559102
SECURITY_TYP2 = Equity
}
LIST_INSERT_ENTRIES = {
ID_BB_SEC_NUM_SRC = 7992961685385
FEED_SOURCE = TQ
ID_BB_SEC_NUM_DES = FIS1V
ID_BB_UNIQUE = EQ0000000023561882
SECURITY_TYP2 = Equity
}
LIST_INSERT_ENTRIES = {
ID_BB_SEC_NUM_SRC = 7992961842174
FEED_SOURCE = TQ
ID_BB_SEC_NUM_DES = ENQ1
ID_BB_UNIQUE = EQ0000000023716301
SECURITY_TYP2 = Equity
}
LIST_ORDERED = NOTORDERED
LIST_MUTABLE = MUTABLE
}
ListData = {
LIST_ID = //blp/mktlist/chain/source/TQ
EID = 35009
LIST_ACTION = ADD_AND_END
FEED_SOURCE = TQ
ID_BB_SEC_NUM_DES = SNOP
}
In the above sample output, a ListRecap message was returned first with a large number of
list entries (only the partial recap is shown, however) and a single ListData message, which is
9 B-Pipe
146
an actual update to the subscription. Although, the ListRecap does not possess a
LIST_ACTION value, you are to treat such a message as a CLEAR_AND_ADD action. In
other words, you will clear your cache and add the entries included in the message.
In the ListRecap message, you will notice a few other pieces of information in addition to the
entries, such as the LIST_LISTTYPE field (in our case, its value is "Source List", which you
will find included in the "TABLE OF SUBSERVICE NAME EXAMPLES" shown earlier in this
section), the EID and the LIST_MUTABLE value, which is MUTABLE in this case. This
indicates that the constituent instruments of a list can change.
After the ListRecap message, you will see one such change to the list, which is returned in
the form of a ListData message. This message includes the LIST_ACTION, among other
fields. In this case, it is indicating that you will ADD this message to your list at the END (as
indicated by ADD_AND_END).
Enumerator
Description
FRAGMENT_NONE
FRAGMENT_START
FRAGMENT_INTERMEDIATE
FRAGMENT_END
To check for the Fragment Type, you will call the fragmentType property of the Message
object (e.g. msg.fragmentType()).
Within your application, you will check to see if the fragment type of the ListRecap message
is FRAGMENT_NONE or FRAGMENT_START. If one of these are determined, then you will
want to clear your list and begin adding the entries included in that part of the ListRecap
message. In the case where FRAGMENT_START is determined, then you will know to
continue reading the ListRecap messages and adding the entries to your list from those
messages until you receive a ListRecap with a fragment type for FRAGMENT_END. At this
point, you know you are finished building your list and it is now time to wait for any
subsequent ListData updates.
9 B-Pipe
147
Topic Type
Topic Key
B-PIPE Field
FLDS<GO> Field
/bpkbl
/<identifier>
PARSEKYABLE_DES_SOURCE
/bsid
/<identifier>
ID_BB_SEC_NUM_SRC
ID122
/bsym
/<identifier>
ID_BB_SEC_NUM_DES
DY003
/buid
/<identifier>
ID_BB_UNIQUE
ID059
/cusip
/<identifier>
ID_CUSIP
ID032
/esym
/<identifier>
ID_EXCH_SYMBOL
EX005->EX011
/isin
/<identifier>
ID_ISIN
ID005
/sedol
/<identifier>
ID_SEDOL1
ID002
/bbgid
/<identifier>
ID_BB_GLOBAL
ID135
/ticker
/<identifier>
PARSEKYABLE_DES_SOURCE
Market list requests with the secids subservice name are always IMMUTABLE, which means
that the returned list of instruments does not receive update messages and must be rerequested to discover any new pricing sources that emerge after the initial request.
Table 9-9: Market List Requests with the Secids Subservice Name
Key Field
Format
Result
Bloomberg Unique
ID
//blp/mktlist/secids/buid/uniqueid
Bloomberg
Symbol
//blp/mktlist/secids/bsym/symbol
SEDOL
//blp/mktlist/secids/sedol/sedol
//blp/mktlist/secids/buid/EQ0010080100001000
//blp/mktlist/secids/bsym/VOD
//blp/mktlist/secids/sedol/2005973
CUSIP
//blp/mktlist/secids/cusip/cusip
//blp/mktlist/secids/cusip/459200101
ISIN
//blp/mktlist/secids/isin/isin
//blp/mktlist/secids/isin/US4592001014
Parsekeyable
//blp/mktlist/secids/bpkbl/parsekeyable
//blp/mktlist/secids/bpkbl/UKX Index
9 B-Pipe
148
Table 9-9: Market List Requests with the Secids Subservice Name
Key Field
Format
Result
Message Scraping
(MSG1)
//blp/mktlist/secids/bsym/MSGSCRP
Bloomberg
Global ID
//blp/mktlist/secids/bbgid/globalid
Bloomberg
Ticker
//blp/mktlist/secids/ticker/symbol
//blp/mktlist/secids/bsym/MSGSCRP
//blp/mktlist/secids/bbgid/BBG000BLNNH6
//blp/mktlist/secids/ticker/IBM US Equity
A security-based secids request can also be modified to limit the source using the 'source'
parameter. This table demonstrates such an instrument with and without the "source"
parameter.
Table 9-10: SecidsRequests with and without Source Parameter
Subscription String
Returns
//blp/mktlist/secids/cusip/459200101
//blp/mktlist/secids/cusip/459200101;source=US
The following code snippet demonstrates how to request static market list snapshot data and
assumes that a session already exists and that the "//blp/mktlist" service has been
successfully opened.
const char *security = "//blp/mktlist/secids/cusip/459200101;source=US";
Service mktListService = session.getService("//blp/mktlist");
Request request = mktListService.createRequest("SnapshotRequest");
request.set("security", security);
9 B-Pipe
149
In your application, you will handle the data response the same way, initially, as you would
any static request. This is accomplished by checking the event type of the incoming
message. If its event type is PARTIAL_RESPONSE, then that indicates that there is at least
one more message to be received to fulfill that request. You will continue reading the
incoming messages until you receive a RESPONSE event type, which indicates that the
request has been fully served. Further information is available in "Appendix A Schemas".
9 B-Pipe
150
Here is a sample event handler written in C++. It was extracted from the
"MarketListSnapshotExample" example found in the B-Pipe C++ API SDK, and is the event
handler that is responsible for displaying the above output to a console window.
9 B-Pipe
151
If you examine the response from the example market list request, which is "//blp/mktlist/
secids/cusip/459200101;source=US", you will find that the data is all returned in a single
message, which means that the message will have an event type of "RESPONSE". Within
that block of code, there is a call to processResponseEvent(). It is here that we first check for
the responseCode element. To understand why we are checking for this element, you will first
need to understand the structure of the schema for the //blp/mktlist service. Here is a
screenshot capturing the sub-elements of the SnapshotRequest/Responses node.
9 B-Pipe
152
If the responseCode is found in the message, then you will check to see if the resultCode is
greater than zero. If it is, then this is an indication that there was a problem with the request
and that this message contains an error. The details of the error will be provided by the
message's resultCode, resultText and sourceId values.
If the resultCode equals zero, then data can be expected to be contained within the message.
In this case, we will retrieve the snapshot element of the message. You will see in the above
processResponseEvent() handler that the number of elements contained in the snapshot are
determined by a call to numElements() and then each of those elements are then read into a
dataItem variable, of type Element, one at a time. You can check to see if the dataItem is an
array by calling its isArray() function. If it returns true, then it is an array containing one, or
more, items and must be processed differently than if containing a single item.
You will see in the schema screenshot that there are a total of ten possible single field
elements and one array element in a snapshot. The array element is indicated by the
SEQUENCE type. In our case, the resultCode is zero (i.e. no errors) and there are 6
elements contained in the snapshot element. The first 3 of them are single field elements
(e.g. LIST_ID, EID, LIST_LISTTYPE), which means that isArray() returns false for each of
them. However, the 4th element, LIST_INSERT_ENTRIES, is an array (a.k.a. SEQUENCE
type). This element is then processed in the processBulkData() function. The remaining two
elements (LIST_ORDERED and LIST_MUTABLE) are also single field elements.
9 B-Pipe
153
All possible values of FEED_SOURCE for the EID and a short description of the
source
Whether or not the source is a composite and all the local sources for composites
where <topic> is comprised of '<topic type>/<topic key>. Table 9-11 provides further details.
Table 9-11: Source Reference String Definitions
<service owner>
<service name>
<subservice name>
<topic type>
/eid
<topic key>
There are currently four subservices that can be used in your subscription string.
Table 9-12: Subservice Definitions
Subservice
Description
/brokercodes
//blp/srcref/brokercodes/eid/<eid>
/conditioncodes
//blp/srcref/conditioncodes/eid/<eid>
/tradingstatuses
//blp/srcref/tradingstatuses/eid/<eid>
/ticksizes
//blp/srcref/ticksizes/eid/<eid>
9 B-Pipe
154
Filters can be used for /conditioncodes and /tradingstatuses subscription only. Here are the
possible filters available for each:
Table 9-13: Filters for Events
Filter Name (type)
TRADE
QUOTE
MKTDEPTH
TRADE,QUOTE
TRADE,MKTDEPTH
QUOTE,MKTDEPTH
TRADE,QUOTE,MKTDEPTH
//blp/srcref/conditioncodes/eid/<eid>?type=TRADE
//blp/srcref/conditioncodes/eid/<eid>?type=QUOTE
//blp/srcref/conditioncodes/eid/<eid>?type= MKTDEPTH
//blp/srcref/conditioncodes/eid/<eid>?type=TRADE,QUOTE
//blp/srcref/conditioncodes/eid/<eid>?type= TRADE,MKTDEPTH
//blp/srcref/conditioncodes/eid/<eid>?type= QUOTE,MKTDEPTH
//blp/srcref/conditioncodes/eid/<eid>?type= TRADE,QUOTE,MKTDEPTH
PERIOD
STATUS
PERIOD,STATUS
//blp/srcref/tradingstatuses/eid/<eid>?type=PERIOD
//blp/srcref/tradingstatuses/eid/<eid>?type=STATUS
//blp/srcref/tradingstatuses/eid/<eid>?type=PERIOD,STATUS
For subscriptions without a filter, users will receive all event types of that subservice name in
the initial snapshot, as well as within subsequent daily updates. However, for subscriptions
with filters, users will receive all events in the initial snapshot, but only specified events within
subsequent daily updates.
Important BPOD Upgrade Notes:
1.
B-Pipe breaks down the subscriptions into a more granular format. With BPOD, you
would have subscribed to "//blp/mktref/srcref/eid/<eid>" to obtain all source
references for that EID, which included the broker codes, trade condition codes,
quote condition codes, market depth condition codes, period suspense codes,
security suspense codes and ticksizes. Now, by using B-Pipe, you can break down
these source references into four main subscriptions: "//blp/srcref/brokercodes/eid/
<eid>", "//blp/srcref/conditioncodes/eid/<eid>", "//blp/srcref/tradingstatuses/eid/
<eid>" and "//blp/srcref/ticksizes/eid/<eid>".
2.
B-Pipe has introduced filters for some of its subservices to allow you to subscribe to
the data you are most interested.
3.
4.
With B-Pipe, Bloomberg now offers intraday updating for tick size changes.
5.
If you are looking for the sources on contributor EIDs (or any EID), you should
subscribe to //blp/srcref for any of the subservices (i.e. /ticksizes, /brokercode, etc)
and the list of descriptions for that source will be included even if the subservice
doesn't apply. For example, "//blp/srcref/ticksizes/eid/14240" will return the sources
for 14240, but there will not be any ticksizes information.
9 B-Pipe
155
Code Example
You will find a SourceRefSubscriptionExample in the B-Pipe SDK for C++, Java and .NET.
This C++ example demonstrates how to make a simple Source Reference subscription for
the condition codes associated with EID 14003.
Figure 9-4: C++ code snippet - subscribing for a list of condition codes for EID 14003
Response Overview
The Source Reference response will be a series of SUBSCRIPTION_DATA events, which
you will be familiar with if you have developed Bloomberg API applications using any of the
other streaming services, such as //blp/mktdata, //blp/mktlist or //blp/mktdepth.
All SUBSCRIPTION_DATA event messages will be of message type
SourceReferenceUpdates and will contain a SOURCE_REF_EVENT_TYPE_RT (event
type), SOURCE_REF_EVENT_SUBTYPE_RT (event sub-type) and EID field (int32), along
with an array of event type field items applicable to the subservice you are subscribing.
Table 9-14 lists the possible enumeration values for the event type and event sub-type fields:
Table 9-14: Enumeration Values
Name
Description
Values
SOURCE_REF_EVENT_TYPE_RT
SOURCE_REF_EVENT_SUBTYPE_RT
The subservice name included in your subscription will dictate which event type
(SOURCE_REF_EVENT_TYPE_RT) field items will be returned as initial snapshot
9 B-Pipe
156
(INITPAINT) and refresh sub-type messages. Table 9-15 will assist you in determining which
SOURCE_REF_EVENT_TYPE_RT field types to expect based on the subservice in your
subscription.
/brokercodes
DESCRIPTION + BROKER_CODE
/conditioncodes
/tradingstatuses
/ticksizesa
DESCRIPTION + TICK_SIZE_TABLE
a. All subservices will return INITPAINT and REFRESH event messages. However, /ticksizes will also return
UPDATE event messages."
For a breakdown of each message returned for your subservice, please see Table 9-16.
Type
Contents
DESCRIPTIONS
SourceReferenceDescriptions
BROKER_CODES
SourceReferenceBrokerCodes
TRADE_COND_CODES
SourceReferenceTradeConditionCodes
9 B-Pipe
157
Type
Contents
QUOTE_COND_CODES
SourceReferenceQuoteConditionCodes
MKTDEPTH_COND_CODES
SourceReferenceMarketDepthConditionCodes
TRADING_PERIODS
SourceReferenceTradingPeriods
TRADING_STATUSES
SourceReferenceTradingStatuses
TICK_SIZE_TABLES
TickSizeTable
As you will see, initial paint messages can be split into one or more smaller
messages in the case where the returned data is too large to fit into a single
message. It will be up to you to handle this in your application.
You will achieve this by checking the Fragment type of any SUBSCRIPTION_DATA
event SourceReferenceUpdates message. The Fragment enum is used to indicate
whether a message is a fragmented message or not and what position it occurs
within the chain of split fragmented messages. If the SourceReferenceUpdates is
9 B-Pipe
158
split into two parts, then the first message will have a Fragment type value of
FRAGMENT_START and a last message of FRAGMENT_END. If the
SourceReferenceUpdates is split into more than 2 parts, all middle Fragments will
be of type FRAGMENT_INTERMEDIATE.
Table 9-17: Fragment Type Enumerators
FRAGMENT_START
FRAGMENT_INTERMEDIATE
FRAGMENT_END
9 B-Pipe
159
TICK_SIZE_TABLE_ROW[] =
TICK_SIZE_TABLE_ROW = {
TICK_SIZE_TABLE_PRICE_TYPE_RT =
TICK_SIZE_TBL_BAND_TICK_SIZE_RT
TICK_SIZE_TBL_BAND_LOWER_VAL_RT
TICK_SIZE_TBL_BAND_UPPER_VAL_RT
}
ABSOLUTE
= 0.050000
= 0.000000
= 10000000000.000000
}
-- MORE -}
***********************************************************************
* DAILY REFRESH
***********************************************************************
SourceReferenceUpdates = {
SOURCE_REF_EVENT_TYPE_RT = DESCRIPTION
SOURCE_REF_EVENT_SUBTYPE_RT = REFRESH
EID = 35009
DESCRIPTIONS[] =
DESCRIPTIONS = {
FEED_SOURCE = LN
FEED_EID = 14014
DESCRIPTION[] =
DESCRIPTION = {
FEED_SOURCE_DES_RT = London Stock Exchange Domestic
}
}
-- MORE -}
SourceReferenceUpdates = {
SOURCE_REF_EVENT_TYPE_RT = TICK_SIZE_TABLE
SOURCE_REF_EVENT_SUBTYPE_RT = REFRESH
EID = 35009
TICK_SIZE_TABLES[] =
TICK_SIZE_TABLES = {
FEED_SOURCE = LN
FEED_EID = 14014
TICK_SIZE_TABLE_IDENTIFIER_RT = 5977
TICK_SIZE_TABLE_TYPE_RT = PRICE
TICK_SIZE_TABLE_UPDATE_FREQ_RT = DAILY
TICK_SIZE_TABLE_FIELD_NAME_RT = LAST_TRADE
TICK_SIZE_TABLE_ROW[] =
TICK_SIZE_TABLE_ROW = {
TICK_SIZE_TABLE_PRICE_TYPE_RT = ABSOLUTE
TICK_SIZE_TBL_BAND_TICK_SIZE_RT = 0.000100
TICK_SIZE_TBL_BAND_LOWER_VAL_RT = 0.000100
TICK_SIZE_TBL_BAND_UPPER_VAL_RT = 10.000000
}
TICK_SIZE_TABLE_ROW = {
TICK_SIZE_TABLE_PRICE_TYPE_RT = ABSOLUTE
TICK_SIZE_TBL_BAND_TICK_SIZE_RT = 0.010000
TICK_SIZE_TBL_BAND_LOWER_VAL_RT = 10.000000
TICK_SIZE_TBL_BAND_UPPER_VAL_RT = 100.000000
}
}
-- MORE -}
9 B-Pipe
160
*******************************************************************
* TICKSIZE INTRADAY UPDATE
*******************************************************************
SourceReferenceUpdates = {
SOURCE_REF_EVENT_TYPE_RT = TICK_SIZE_TABLE
SOURCE_REF_EVENT_SUBTYPE_RT = UPDATE
EID = 35009
TICK_SIZE_TABLES[] =
TICK_SIZE_TABLES = {
FEED_SOURCE = LN
FEED_EID = 14014
TICK_SIZE_TABLE_IDENTIFIER_RT = 5995
TICK_SIZE_TABLE_TYPE_RT = PRICE
TICK_SIZE_TABLE_UPDATE_FREQ_RT = DAILY
TICK_SIZE_TABLE_FIELD_NAME_RT = LAST_TRADE
TICK_SIZE_TABLE_ROW[] =
TICK_SIZE_TABLE_ROW = {
TICK_SIZE_TABLE_PRICE_TYPE_RT = ABSOLUTE
TICK_SIZE_TBL_BAND_TICK_SIZE_RT = 0.300000
TICK_SIZE_TBL_BAND_LOWER_VAL_RT = 0.250000
TICK_SIZE_TBL_BAND_UPPER_VAL_RT = 100000000.000000
}
}
-- MORE -}
In the above sample output, a subscription containing the subservice "/ticksizes" was made,
which means that you can expect to receive "INITPAINT" and "REFRESH" event types (i.e.
SOURCE_REF_EVENT_TYPE_RT) messages containing "DESCRIPTION" and
"TICK_SIZE_TABLE" event sub-types (i.e. SOURCE_REF_EVENT_SUBTYPE_RT). In
addition to the aforementioned messages, which are standard for all of the subservice
requests, you will also receive "UPDATE" event type messages, which are unique to the /
ticksizes subservice. However, there will not be an UPDATE "DESCRIPTION" message sent.
Taking a look at the sample output above, you will notice that every
SourceReferenceUpdates message contains the standard event type, sub-type and EID
single-value fields, along with an array of fields applicable for that event type. For instance, in
the message containing the event type of "TICK_SIZE_TABLE" you will find an array of
"TICK_SIZE_TABLES" fields.
9 B-Pipe
161
A Schemas
A.1 Overview
Each of the following sections provides an overview of the request options and response
structure for each request type within each of the Bloomberg API services. A service is
defined by a request and a response schema. In the following sections the request schema is
broken into tables detailing all options and arguments and example syntax. The response
schema is represented graphically.
A.2.1 Operations
Operation Name
Request Type
Response Type
Description
HistoricalDataRequest
HistoricalDataRequest
HistoricalDataResponse
Request Historical
Data
IntraDayTickRequest
IntraDayTickRequest
IntraDayTickResponse
IntraDayBarRequest
IntraDayBarRequest
IntradayBarResponse
ReferenceDataRequest
ReferenceDataRequest
ReferenceDataResponse
Request Reference
Data
PortfolioDataRequest
PortfolioDataRequest
PortfolioDataResponse
Request Portfolio
Data
BeqsRequest
BeqsRequest
BeqsResponse
Element Value
Type
Description
securities
string array
string
A Schemas
162
Element
Element Value
fields
Type
Description
string
Element Value
Type
Description
fieldID
string
value
string
Element Value
Type
Description
returnEids
TRUE or
FALSE
Boolean
Example Syntax:
request.Set("returnEids", true);
Element Value
Type
Description
returnFormattedValue
TRUE or
FALSE
Boolean
Element Value
Type
Description
useUTCTime
TRUE or
FALSE
Boolean
Element Value
Type
Description
forcedDelay
TRUE or
FALSE
Boolean
A Schemas
163
A Schemas
164
Element Value
securities
Type
Description
string
See Security/Securities on
page 77 for additional details.
Element Value
fields
Type
Description
string
array
Element Value
Type
Description
startDate
yyyymmdd
string
Element Value
Type
Description
endDate
yyyymmdd
string
Element Value
Type
Description
periodicityAdjustment
ACTUAL
string
CALENDAR
string
FISCAL
string
A Schemas
165
Period Selection: Determine the frequency of the output. To be used in conjunction with Period
Adjustment.
Element
Element Value
Type
Description
periodicitySelection
DAILY
string
WEEKLY
string
MONTHLY
string
QUARTERLY
string
SEMI_ANNUALLY
string
YEARLY
string
Element Value
Type
Description
currency
string
Element Value
Type
Description
overrideOption
OVERRIDE_OPTION_CLOS
E
string
OVERRIDE_OPTION_GPA
string
Element Value
Type
Description
pricingOption
PRICING_OPTION_PRICE
string
PRICING_OPTION_YIELD
string
Element Value
Type
Description
nonTradingDayFillOption
NON_TRADING_WEEKDAYS
string
ALL_CALENDAR_DAYS
string
ACTIVE_DAYS_ONLY
string
A Schemas
166
Non Trading Day Fill Method: If data is to be displayed for non trading days what is the data to be
returned.
Element
Element Value
Type
Description
nonTradingDayFillMethod
PREVIOUS_VALUE
string
NIL_VALUE
string
Element Value
maxDataPoints
Type
Description
integer
Element Value
Type
Description
returnEids
TRUE or FALSE
Boolean
Element Value
Type
Description
returnRelativeDate
TRUE or FALSE
Boolean
Element Value
Type
Description
adjustmentNormal
TRUE or FALSE
Boolean
A Schemas
167
Element Value
Type
Description
adjustmentAbnormal
TRUE or FALSE
Boolean
Element Value
Type
Description
adjustmentSplit
TRUE or FALSE
Boolean
Element Value
Type
Description
adjustmentFollowDPDF
TRUE or FALSE
Boolean
Element Value
Type
Description
calendarCodeOverride
String
A Schemas
168
CalendarOverridesInfo: Returns data based on the calendar code of multiple countries, exchanges, or
religious calendars from CDR<GO>.
Element
Element Value
Type
Description
calendarOverrides
String
array
calendareOverrides
Operation
CDR_AND
String
CDR_OR
String
Type
Description
fieldID
string
value
string
Example Syntax:
A Schemas
Element Value
169
A Schemas
170
A.2.6
IntradayTickRequest: Sequence
Element Value
securities
Type
Description
string
Element Value
Type
Description
startDateTime
yyyy-mm-dd
Thh:mm:ss
string
Element Value
Type
Description
endDateTime
yyyy-mm-dd
Thh:mm:ss
string
Element Value
Type
Description
eventType
TRADE
string
Corresponds to LAST_PRICE
BID
string
ASK
string
BID_BEST
string
ASK_BEST
string
MID_PRICE
string
AT_TRADE
string
BEST_BID
string
BEST_ASK
string
A Schemas
171
Include Condition Codes: return any condition codes that may be associated to a tick, which identifies
extraordinary trading and quoting circumstances.
Element
Element Value
Type
Description
includeConditionCodes
TRUE or
FALSE
Boolean
Element Value
Type
Description
includeNonPlottable
Events
TRUE or
FALSE
Boolean
Element Value
Type
Description
includeExchangeCodes
TRUE or
FALSE
Boolean
Element Value
Type
Description
returnEids
TRUE or
FALSE
Boolean
Element Value
Type
Description
includeBrokerCodes
TRUE or
FALSE
Boolean
Element Value
Type
Description
includeRpsCodes
TRUE or
FALSE
Boolean
A Schemas
172
Element Value
Type
Description
includeBicMicCodes
TRUE or
FALSE
Boolean
The BIC, or Bank Identifier Code, as a 4character unique identifier for each bank that
executed and reported the OTC trade, as
required by MiFID. BICs are assigned and
maintained by SWIFT (Society for Worldwide
Interbank Financial Telecommunication). The
MIC is the Market Identifier Code, and this
indicates the venue on which the trade was
executed.
A Schemas
173
A Schemas
174
Element Value
securities
Type
Description
string
Element Value
Type
Description
startDateTime
yyyy-mm-dd
Thh:mm:ss
string
Element Value
Type
Description
endDateTime
yyyy-mm-dd
Thh:mm:ss
string
Element Value
Type
Description
eventType
TRADE
string
Corresponds to LAST_PRICE
BID
string
ASK
string
BID_BEST
string
ASK_BEST
string
BEST_BID
string
BEST_ASK
string
Element Value
Type
Description
interval
1...1440
integer
A Schemas
175
Gap Fill Initial Bar: populate an empty bar with previous value
Element
Element Value
Type
Description
gapFillInitialBar
TRUE or
FALSE
Boolean
Element Value
Type
Description
returnEids
TRUE or
FALSE
Boolean
Element Value
Type
Description
adjustmentNormal
TRUE or
FALSE
Boolean
Element Value
Type
Description
adjustmentAbnormal
TRUE or
FALSE
Boolean
Element Value
Type
Description
adjustmentSplit
TRUE or
FALSE
Boolean
Element Value
Type
Description
adjustmentFollowDPDF
TRUE or
FALSE
Boolean
A Schemas
176
A Schemas
177
Element Value
Type
Description
securities
string array
string
Element Value
fields
Type
Description
string
Element Value
Type
Description
fieldId
string
value
string
A Schemas
178
A Schemas
179
Element Value
Type
Description
screenName
string
string
Element Value
Type
Description
screenType
PRIVATE or
GLOBAL
string
Element Value
languageId (optional)
Type
Description
string
Element Value
Group (optional)
Type
Description
string
Type
Description
fieldId
string
value
string
Example Syntax:
A Schemas
Element Value
180
A Schemas
181
Description
responseError
securityData[ ]
securityData
barData
barTickData[ ]
barTickData
Contains values associated to the bar, including time, open, high, low,
close, volume, numEvents.
tickData
tickData[ ]
tickData[ ] :: tickData
eidData[ ]
securityError
fieldExceptions[ ]
fieldExceptions
fieldData[ ]
fieldData
errorInfo
A Schemas
Contains values about the error which has occurred, including the
source, code, category, message, and subcategory.
182
Type
Description
security
String
eidData
Integer
sequenceNumber
Integer
fieldId
String
relativeDate
String
Relative date string associated with this historical datapoint. This field will only be returned if
"returnRelativeDate" historical data request option is
specified as "true".
Date
Date
Time
DateTime
Type
String
Value
Integer
Double
String
Date
Time
Datetime
Size
Integer
conditionCode
String
exchangeCode
String
Source
String
Code
Integer
Category
String
message
String
subcategory
String
A Schemas
183
String
brokerBuyCode
String
brokerSellCode
String
micCode
String
A Schemas
184
Type
Description
fieldInfoRequest
FieldInfoRequest
fieldSearchRequest
FieldSearchRequest
categorizedFieldSearchRequest
CategorizedFieldSearch Request
Type
Description
fieldResponse
FieldResponse
categorizedFieldResponse
CategorizedFieldResponse
Element Value
id
Type
Description
string
Element Value
Type
Description
returnFieldDocumentatio
n
TRUE or
FALSE
Boolean
A Schemas
185
A Schemas
186
Element Value
searchSpec
Example Syntax:
Type
Description
String
Include options:
Element
Element Value
Type
Description
category
New Fields
Analysis
Corporate
Actions
Custom Fields
Descriptive
Earnings
Estimates
Fundamentals
Market Activity
Metadata
Ratings
Trading
Systems
String
productType
All
String
Govt
String
Corp
String
Mtge
String
M-Mkt
String
Muni
String
Pfd
String
Equity
String
Cmdty
String
Index
String
Curncy
String
A Schemas
187
fieldType
All
String
Realtime
String
Static
String
Element Value
Type
Description
category
New Fields
Analysis
Corporate
Actions
Custom Fields
Descriptive
Earnings
Estimates
Fundamentals
Market Activity
Metadata
Ratings
Trading
Systems
String
productType
All
String
Govt
String
Corp
String
Mtge
String
M-Mkt
String
Muni
String
Pfd
String
Equity
String
Cmdty
String
Index
String
Curncy
String
A Schemas
188
fieldType
Example Syntax:
All
String
Realtime
String
Static
String
Element Value
Type
Description
returnFieldDocumentatio
n
TRUE or
FALSE
Boolean
A Schemas
189
A Schemas
190
Element Value
searchSpec
Example Syntax:
Type
Description
String
Exclude options:
Element
Element Value
Type
Description
category
New Fields
Analysis
Corporate
Actions
Custom Fields
Descriptive
Earnings
Estimates
Fundamentals
Market Activity
Metadata
Ratings
Trading
Systems
String
productType
All
String
Govt
String
Corp
String
Mtge
String
M-Mkt
String
Muni
String
Pfd
String
Equity
String
Cmdty
String
Index
String
Curncy
String
A Schemas
191
fieldType
Example Syntax:
All
String
Realtime
String
Static
String
Element Value
Type
Description
returnFieldDocumentatio
n
TRUE or
FALSE
Boolean
A Schemas
192
Element Value
Type
Description
fieldType
All
String
Realtime
String
Static
String
Example Syntax:
element.setElement("fieldType", "Static");
Element Value
Type
Description
returnFieldDocumentatio
n
TRUE or
FALSE
Boolean
request.Set("returnFieldDocumentation", true);
A Schemas
194
A Schemas
195
Description
fieldSearchError
fieldData[ ]
fieldData
fieldInfo
fieldError
categorizedFieldSearchE
rror
category[ ]
category
errorInfo
Contains values about the error which has occurred, including the
source, code, category, message, and subcategory.
A Schemas
196
Type
Description
id
String
mnemonic
Integer
datatype
Enumeration
ftype
Enumeration
categoryName
String
description
String
documentation
String
Time
DateTime
Type
String
Source
String
Code
Integer
Category
String
message
String
subcategory
String
A Schemas
197
Type
Description
Security
string
"//blp/mktbar/symbology/identifier"
Fields
string
bar_size
string
start_time
string
Optional. This should be in the format hh:mm. If not set then the time
of session start of the security or subscription time will be used.
end_time
string
Example Syntax:
Subscription mySubscription = new Subscription(
"//blp/mktbar/TICKERX/IBM US Equity",
"last_price",
"bar_size=5&start_time=13:30&end_time=20:00",
new CorrelationID("IBM US Equity"));
A Schemas
198
MarketBarStart
/blp/mktbar/TICKER/IBM US Equity - MarketBarStart
TIME = 12:5
OPEN = 176.88
HIGH = 176.89
LOW = 176.85
CLOSE = 176.88
NUMBER_OF_TICKS = 12
VOLUME = 1400
VALUE = 247622.0
DATE_TIME = 2/7/2014 12:5
MarketBarUpdate
//blp/mktbar/TICKER/IBM US Equity - MarketBarUpdate
TIME = 12:5
HIGH = 176.89
LOW = 176.85
CLOSE = 176.87
NUMBER_OF_TICKS = 13
VOLUME = 1500
VALUE = 265309.0
DATE_TIME = 2/7/2014 12:5
MarketBarIntervalEnd
//blp/mktbar/TICKER/IBM US Equity - MarketBarIntervalEnd
TIME = 12:5
DATE_TIME = 2/7/2014 12:5
MarketBarEnd
//blp/mktbar/TICKER/IBM US Equity - MarketBarEnd
TIME = 12:5
DATE_TIME = 2/7/2014 12:5
A Schemas
199
Argument Value
Type
Description
TIME
datetime
Float64
Float64
Float64
Float64
Int32
Example Syntax:
int number_of_ticks = msg.getElementAsInt32(NUMBER_OF_TICKS);
VALUE
Float64
Example Syntax:
float value = msg.getElementAsInt64(VALUE);
VOLUME
Int64
Example Syntax:
float volume = msg.getElementAsInt64(VOLUME);
DATE_TIME
datetime
Example Syntax:
Datetime datetime = msg.getElementAsDatetime(DATE_TIME);
A Schemas
200
Type
Description
MarketDataEvents
MarketDataEvents
Type
Description
interval
string
Sets a defined period in seconds for which updates will be received for
the subscription.
The range for this argument is 0.10 to 86400.00, which is equal to
100ms to 24hours. For example setting this argument to 30 will result
in the requesting application to receive updates every 30 seconds for
the requested securities.
Example Syntax:
Subscription mySubscription = new Subscription(security, fields,
"interval=30.0", new CorrelationID(security));
delayed
string
Forces the subscription to be delayed even if the requestor has realtime exchange entitlements.
Example Syntax:
Subscription mySubscription = new Subscription(security, fields,
"delayed", new CorrelationID(security));
Type
Description
TORONTO_MOC_ELIGIBLE_REALTIME
Optional
Boolean
NASDAQ_CLOSING_CROSS_ELIGIBLE_RT
Optional
Boolean
MGF_SETTING_RT
Optional
Boolean
RT_EXCH_TRADE_STATUS
Optional
Boolean
RT_QUOTE_STATUS
Optional
Boolean
Quotation Status
A Schemas
201
Element
Type
Description
IND_BID_FLAG
Optional
Boolean
IND_ASK_FLAG
Optional
Boolean
TRADING_DT_REALTIME
Optional Date
Trading Date
RT_TIME_OF_TRADE
Optional
Datetime
CR_OBSERVATION_DATE
Optional
Datetime
PRIOR_OBSERVATION_DATE
Optional
Datetime
TIME
Optional
Datetime
VOLUME
Optional Int32
Volume
BID_YIELD
Optional Float32
Bid Yield
ASK_YIELD
Optional Float32
Ask Yield
RT_OPEN_INTEREST
Optional Float32
OFF_ON_EXCH_VOLUME_RT
Optional Int32
OFF_EXCH_VOLUME_RT
Optional Int32
PX_VOLUME_BAL_RT
Optional Int32
DELTA_BID_RT
Optional Float32
DELTA_ASK_RT
Optional Float32
DELTA_MID_RT
Optional Float32
DELTA_LAST_RT
Optional Float32
GAMMA_BID_RT
Optional Float32
GAMMA_ASK_RT
Optional Float32
GAMMA_MID_RT
Optional Float32
GAMMA_LAST_RT
Optional Float32
VEGA_BID_RT
Optional Float32
VEGA_ASK_RT
Optional Float32
VEGA_MID_RT
Optional Float32
VEGA_LAST_RT
Optional Float32
IVOL_BID_RT
Optional Float32
IVOL_ASK_RT
Optional Float32
IVOL_MID_RT
Optional Float32
IVOL_LAST_RT
Optional Float32
EQY_SH_FOREIGN_RT
Optional Float32
LISTED_SH_RT
Optional Float32
A Schemas
202
Element
Type
Description
BLP_SPRD_TO_BENCH_BID_RT
Optional Float32
BLP_SPRD_TO_BENCH_ASK_RT
Optional Float32
BLP_SPRD_TO_BENCH_MID_RT
Optional Float32
BLP_Z_SPRD_MID_RT
Optional Float32
BLP_ASW_SPREAD_MID_RT
Optional Float32
BLP_I_SPRD_MID_RT
Optional Float32
BLP_CDS_BASIS_MID_RT
Optional Float32
BLP_SPRD_TO_BENCH_CHG_RT
Optional Float32
BLP_Z_SPRD_CHG_RT
Optional Float32
BLP_ASW_SPRD_CHG_RT
Optional Float32
BLP_I_SPRD_CHG_RT
Optional Float32
BLP_CDS_BASIS_CHG_RT
Optional Float32
BLP_SPRD_TO_BENCH_PCT_CHG_RT
Optional Float32
BLP_Z_SPRD_PCT_CHG_RT
Optional Float32
BLP_ASW_SPRD_PCT_CHG_RT
Optional Float32
BLP_I_SPRD_PCT_CHG_RT
Optional Float32
BLP_CDS_BASIS_PCT_CHG_RT
Optional Float32
PX_SETTLE_ACTUAL_RT
Optional Float32
ARBITRAGE_ASK_ORD_NOT_MATCHED_RT
Optional Float32
ARBITRAGE_BID_ORD_NOT_MATCHED_RT
Optional Float32
NON_ARBITRAGE_ASK_NOT_MATCHED_RT
Optional Float32
NON_ARBITRAGE_BID_NOT_MATCHED_RT
Optional Float32
ARBITRAGE_ASK_ORD_VOLUME_RT
Optional Int32
ARBITRAGE_BID_ORD_VOLUME_RT
Optional Int32
A Schemas
203
Element
Type
Description
NON_ARBIT_ASK_ORD_VOLUME_RT
Optional Int32
NON_ARBIT_BID_ORD_VOLUME_RT
Optional Int32
PRE_ANNOUNCE_NUM_PROG_ASK_RT
Optional Float32
PRE_ANNOUNCE_NUM_PROG_BID_RT
Optional Float32
TRUST_ASK_ORD_VOLUME_RT
Optional Int32
PROPRIETARY_ASK_ORD_VOLUME_RT
Optional Int32
TRUST_BID_ORD_VOLUME_RT
Optional Int32
PROPRIETARY_BID_ORD_VOLUME_RT
Optional Int32
TOTAL_VOLUME_PROGRAM_TRADE_RT
Optional Int32
PX_INDICATIVE_BID_SIZE_RT
Optional Int32
PX_INDICATIVE_ASK_SIZE_RT
Optional Int32
NUM_TRADES_RT
Optional Int32
Number Of Trades
MGF_VOLUME_RT
Optional Int32
NUM_TRADES_OPENING_AUCTION_RT
Optional Int32
NUM_TRADES_CLOSING_AUCTION_RT
Optional Int32
ALL_PRICE_SIZE
Optional Int32
RT_NYSE_LIQUIDITY_BID_SIZE
Optional Int32
RT_NYSE_LIQUIDITY_ASK_SIZE
Optional Int32
VOLUME_THEO
Optional Int32
Theoretical Volume
SIZE_LAST_AT_TRADE
Optional Int32
SIZE_LAST_AT_TRADE_TDY
Optional Int32
OPEN_YLD
Optional Float32
Open Yield
OPEN_YLD_TDY
Optional Float32
HIGH_YLD
Optional Float32
High Yield
HIGH_YLD_TDY
Optional Float32
LOW_YLD
Optional Float32
Low Yield
LOW_YLD_TDY
Optional Float32
LAST_YLD
Optional Float32
Last Yield
LAST_YLD_TDY
Optional Float32
SIZE_LAST_TRADE_TDY
Optional Int32
A Schemas
204
Element
Type
Description
LAST2_YLD
Optional Float32
Last 2 Yield
LAST_DIR_YLD
Optional Int32
LAST2_DIR_YLD
Optional Int32
PREV_SES_LAST_YLD
Optional Float32
BID2_YLD
Optional Float32
Bid 2 Yield
ASK2_YLD
Optional Float32
Ask 2 Yield
BID_DIR_YLD
Optional Int32
ASK_DIR_YLD
Optional Int32
MID_DIR
Optional Int32
Mid Direction
MID2_DIR
Optional Int32
RT_PX_CHG_PCT_1D
Optional Float32
RT_YLD_CHG_NET_1D
Optional Float32
RT_YLD_CHG_PCT_1D
Optional Float32
ASK_SIZE_TDY
Optional Int32
BID_SIZE_TDY
Optional Int32
VOLUME_TDY
Optional Int32
Today's Volume
BID_YLD_TDY
Optional Float32
ASK_YLD_TDY
Optional Float32
UP_LIMIT
Optional Float32
Up Limit
DOWN_LIMIT
Optional Float32
Down Limit
LAST_DIR
Optional Int32
Last Direction
LAST2_DIR
Optional Int32
BID_DIR
Optional Int32
Bid Direction
ASK_DIR
Optional Int32
Ask Direction
SIZE_LAST_TRADE
Optional Int32
ASK_SIZE
Optional Int32
Ask Size
BID_SIZE
Optional Int32
Bid Size
LAST_PRICE
Optional Float64
Last Price
BID
Optional Float64
Bid Price
ASK
Optional Float64
Ask Price
HIGH
Optional Float64
High Price
LOW
Optional Float64
Low Price
BEST_BID
Optional Float64
Best Bid
BEST_ASK
Optional Float64
Best Ask
MID
Optional Float64
Mid Price
LAST_TRADE
Optional Float64
Last Trade
OPEN
Optional Float64
Open Price
A Schemas
205
Element
Type
Description
PREV_SES_LAST_PRICE
Optional Float64
EXCH_VWAP
Optional Float64
Exchange VWAP
NASDAQ_OPEN
Optional Float64
NASDAQ_FIRST_TRADE
Optional Float64
NASDAQ_PREV_BID
Optional Float64
NASDAQ_PREV_ASK
Optional Float64
INDICATIVE_FAR
Optional Float64
INDICATIVE_NEAR
Optional Float64
IMBALANCE_BID
Optional Float64
IMBALANCE_ASK
Optional Float64
ORDER_IMB_BUY_VOLUME
Optional Int32
ORDER_IMB_SELL_VOLUME
Optional Int32
VWAP
Optional Float64
FIXING_RATE_REALTIME
Optional Float64
Fixing Rate
HIGH_TEMP_REALTIME
Optional Float64
High Temperature
LOW_TEMP_REALTIME
Optional Float64
Low Temperature
MEAN_TEMP_REALTIME
Optional Float64
Mean Temperature
HEATING_DAYS_REALTIME
Optional Float64
COOLING_DAYS_REALTIME
Optional Float64
REL_HUMIDITY_REALTIME
Optional Float64
Relative Humidity
WIND_SPEED_REALTIME
Optional Float64
Wind Speed
WEATHER_CODE_REALTIME
Optional Float64
PRECIPITATION_REALTIME
Optional Float64
Precipitation
MARKET_DEFINED_VWAP_REALTIME
Optional Float64
MIN_LIMIT
Optional Float64
MAX_LIMIT
Optional Float64
THEO_PRICE
Optional Float64
Theoretical Price
MIN_LIMIT_OUT_OF_SESSION
Optional Float64
MAX_LIMIT_OUT_OF_SESSION
Optional Float64
BID_WEIGHTED_AVG_SPREAD
Optional Float64
ASK_WEIGHTED_AVG_SPREAD
Optional Float64
RT_NYSE_LIQUIDITY_PX_BID
Optional Float64
RT_NYSE_LIQUIDITY_PX_ASK
Optional Float64
INDICATIVE_BID
Optional Float64
INDICATIVE_ASK
Optional Float64
PX_EVAL_JAPANESE_REALTIME
Optional Float64
LAST_ALL_SESSIONS
Optional Float64
A Schemas
206
Element
Type
Description
PX_NASDAQ_VWOP_REALTIME
Optional Float64
BLP_I_SPRD_LAST_RT
Optional Float64
PREV_CLOSE_VALUE_REALTIME
Optional Float64
BID_ALL_SESSION
Optional Float64
ASK_ALL_SESSION
Optional Float64
EBS_TOUCH_HIGH_REALTIME
Optional Float64
EBS_TOUCH_LOW_REALTIME
Optional Float64
PX_PREV_TO_LAST_REALTIME
Optional Float64
Previous-To-Last Price
PX_TARGIN_SERVICE_REALTIME
Optional Float64
PX_TARGIN_OFFCIAL_REALTIME
Optional Float64
FOREIGN_HOLDING_PCT_RT
Optional Float64
OWNERSHIP_LIMIT_RATIO_RT
Optional Float64
RT_EVAL_JAPANESE_CHG_ON_DAY
Optional Float64
RT_EVAL_JAPANESE_PCT_CHG_ON_DAY
Optional Float64
BLP_Z_SPRD_LAST_RT
Optional Float64
BLP_ASW_SPREAD_LAST_RT
Optional Float64
BLP_RT_SPRD_TO_BENCH_LAST_RT
Optional Float64
TRUST_ASK_ORD_VALUE_RT
Optional Float64
PROPRIETARY_ASK_ORD_VALUE_RT
Optional Float64
TRUST_BID_ORD_VALUE_RT
Optional Float64
PROPRIETARY_BID_ORD_VALUE_RT
Optional Float64
TOTAL_VALUE_PROGRAM_TRADE_RT
Optional Float64
PX_OFFICIAL_AUCTION_RT
Optional Float64
NYSE_LRP_HIGH_PRICE_RT
Optional Float64
NYSE_LRP_LOW_PRICE_RT
Optional Float64
ALL_PRICE
Optional Float64
All Price
BEST_BID1
Optional Float64
Best Bid 1
BEST_BID2
Optional Float64
Best Bid 2
BEST_BID3
Optional Float64
Best Bid 3
BEST_BID4
Optional Float64
Best Bid 4
BEST_BID5
Optional Float64
Best Bid 5
BEST_ASK1
Optional Float64
Best Ask 1
BEST_ASK2
Optional Float64
Best Ask 2
A Schemas
207
Element
Type
Description
BEST_ASK3
Optional Float64
Best Ask 3
BEST_ASK4
Optional Float64
Best Ask 4
BEST_ASK5
Optional Float64
Best Ask 5
BEST_BID1_SZ
Optional Int32
BEST_BID2_SZ
Optional Int32
BEST_BID3_SZ
Optional Int32
BEST_BID4_SZ
Optional Int32
BEST_BID5_SZ
Optional Int32
BEST_ASK1_SZ
Optional Int32
BEST_ASK2_SZ
Optional Int32
BEST_ASK3_SZ
Optional Int32
BEST_ASK4_SZ
Optional Int32
BEST_ASK5_SZ
Optional Int32
LAST_AT_TRADE
Optional Float64
Last AT Trade
LAST2_AT_TRADE
Optional Float64
Last 2 AT Trade
LAST_AT_TRADE_TDY
Optional Float64
MID_TDY
Optional Float64
MID2
Optional Float64
Mid 2 Price
RT_PX_CHG_NET_1D
Optional Float64
OPEN_TDY
Optional Float64
LAST_PRICE_TDY
Optional Float64
BID_TDY
Optional Float64
ASK_TDY
Optional Float64
HIGH_TDY
Optional Float64
LOW_TDY
Optional Float64
LAST2_PRICE
Optional Float64
Last 2 Price
BID2
Optional Float64
Bid 2 Price
ASK2
Optional Float64
Ask 2 Price
RT_EXCH_MARKET_STATUS
Optional String
RT_TRADING_PERIOD
Optional String
Trading Period
BID_BROKER_CODE
Optional String
ASK_BROKER_CODE
Optional String
IMBALANCE_INDIC_RT
Optional String
Imbalance Indicator
BLP_SPREAD_BENCHMARK_NAME_RT
Optional String
BLP_SWAP_CURVE_NAME_RT
Optional String
A Schemas
208
Element
Type
Description
FINANCIAL_STATUS_INDICATOR_RT
Optional String
BID_YLD_COND_CODE
Optional String
YLD_COND_CODE
Optional String
ASK_YLD_COND_CODE
Optional String
ALL_PRICE_COND_CODE
Optional String
BID_COND_CODE
Optional String
ASK_COND_CODE
Optional String
RT_SIMP_SEC_STATUS
Optional String
RT_PRICING_SOURCE
Optional String
NYSE_LRP_SEND_TIME_RT
Optional Time
BID_ASK_TIME
Optional Time
SES_START
Optional Time
Session Start
SES_END
Optional Time
Session End
TRADE_SPREAD_TIME
Optional Time
NEWS_STORY_TIME
Optional Time
BID_TIME
Optional Time
BID_BEST_TIME
Optional Time
VOLUME_UPDATE_TIME
Optional Time
MARKET_DEPTH_TIME
Optional Time
CANCEL_CORRECT_TIME
Optional Time
MIN_LIMIT_OUT_OF_SESSION_TIME
Optional Time
Time of MIN_LIMIT_OUT_OF_SESSION
tick
BID_SPREAD_TIME
Optional Time
BT_MKT_TURN_TIME
Optional Time
HIGH_TIME
Optional Time
BT_LSE_LAST_TIME
Optional Time
AT_TRADE_TIME
Optional Time
ASK_YEILD_TIME
Optional Time
PRICE_UPDATE_TIME
Optional Time
OPEN_INTEREST_TIME
Optional Time
VOLUME_TIME
Optional Time
EVAL_JAPANESE_TIME
Optional Time
ASK_WEIGHTED_AVG_SPREAD_TIME
Optional Time
Time of
ASK_WEIGHTED_AVG_SPREAD tick
THEO_PRICE_TIME
Optional Time
BUY_SELL_INFO_TIME
Optional Time
SETS_MID_PRICE_TIME
Optional Time
A Schemas
209
Element
Type
Description
TAKE_TIME
Optional Time
TICK_NUM_TIME
Optional Time
SMART_TIME
Optional Time
INDICATIVE_ASK_TIME
Optional Time
BT_SEC_ASK_TIME
Optional Time
LOW_TIME
Optional Time
BT_SEC_BID_TIME
Optional Time
LOW_YIELD_TIME
Optional Time
MAX_LIMIT_TIME
Optional Time
TRADING_PERIOD_TIME
Optional Time
INDICATIVE_BID_TIME
Optional Time
API_INTERNAL_TIME
Optional Time
ASK_LIFT_TIME
Optional Time
NYSE_LIQUIDITY_ASK_TIME
Optional Time
BID_YEILD_TIME
Optional Time
ASK_BEST_TIME
Optional Time
MKT_INDICATOR_TIME
Optional Time
NYSE_LIQUIDITY_BID_TIME
Optional Time
SMART_QUOTE_TIME
Optional Time
NEW_MKT_DAY_TIME
Optional Time
MAN_TRADE_WITH_SIZE_TIME
Optional Time
BT_ASK_RECAP_TIME
Optional Time
BT_MID_PRICE_TIME
Optional Time
BID_MKT_MAKER_TIME
Optional Time
SETTLE_TIME
Optional Time
HIT_TIME
Optional Time
BT_LAST_RECAP_TIME
Optional Time
LAST_TRADE_TIME
Optional Time
Time of LAST_TRADE
PRE_POST_MARKET_TIME
Optional Time
ALL_PRICE_TIME
Optional Time
OPEN_TIME
Optional Time
HIGH_YIELD_TIME
Optional Time
ASK_MKT_MAKER_TIME
Optional Time
MAX_LIMIT_OUT_OF_SESSION_TIME
Optional Time
Time of
MAX_LIMIT_OUT_OF_SESSION tick
SMARTMAX_TIME
Optional Time
YIELD_TIME
Optional Time
A Schemas
210
Element
Type
Description
VWAP_TIME
Optional Time
BID_WEIGHTED_AVG_SPREAD_TIME
Optional Time
Time of BID_WEIGHTED_AVG_SPREAD
tick
ASK_TIME
Optional Time
MIN_LIMIT_TIME
Optional Time
ASK_SPREAD_TIME
Optional Time
SETTLE_YIELD_TIME
Optional Time
BID_LIFT_TIME
Optional Time
BT_BID_RECAP_TIME
Optional Time
A Schemas
211
Type
Description
VWAP_START_TIME
string
Example Syntax:
Subscription mySubscription = new Subscription( topic + security,
fields, "&VWAP_START_TIME=11:00",
new CorrelationID(security) );
VWAP_END_TIME
string
Example Syntax:
Subscription mySubscription = new Subscription( topic + security,
fields, "&VWAP_END_TIME=12:00",
new CorrelationID(security) );
VWAP_MIN_SIZE
string
Example Syntax:
Subscription mySubscription = new Subscription( topic + security,
fields, "&VWAP_MIN_SIZE=1000",
new CorrelationID(security) );
VWAP_MAX_SIZE
string
Example Syntax:
Subscription mySubscription = new Subscription( topic + security,
fields, "&VWAP_MAX_SIZE=2000",
new CorrelationID(security) );
VWAP_MIN_PX
string
Example Syntax:
Subscription mySubscription = new Subscription( topic + security,
fields, "&VWAP_MIN_PX=23.5",
new CorrelationID(security) );
VWAP_MAX_PX
string
Example Syntax:
Subscription mySubscription = new Subscription( topic + security,
fields, "&VWAP_MAX_PX=25.5",
new CorrelationID(security) );
A Schemas
212
Description
AuthorizationRequest
UserAsidEquivalenceRequest
LogonStatusRequest
UserEntitlementsRequest
SecurityEntitlementsRequest
SecurityEntitlementsByUserRequest
TokenRequest
Element Value
uuid
Type
Description
integer
Element Value
ipAddress
Type
Description
string
Example Syntax:
Request authRequest = d_apiAuthSvc.CreateAuthorizationRequest();
authRequest.Set("ipAddress", "111.22.33.44");
Require ASID equivalence: Deprecated. Sets a flag to check the user has a superset of
entitlements compared to the ServerAPI. Used for the All-or-None model of permissioning.
Element
Element Value
Type
Description
requireAsidEquivalence
TRUE or
FALSE
Boolean
Token: Deprecated. Authorizes the user with the token based approach.
Element
token
A Schemas
Element Value
Type
Description
Token returned by TokenRequest for a user.
(Optional. Either ipAddress or token must be
supplied.)
213
A Schemas
214
Element Value
uuid
Type
Description
integer
sid
sidInstance
terminalSid
terminalSidInstance
Example Syntax:
Request request = authSvc.CreateRequest("LogonStatusRequest");
Element userinfo = request.GetElement("userInfo");
userinfo.SetElement("uuid", 11223344);
IP Address: The location where the user is viewing API data
Element
ipAddress
Element Value
Type
Description
string
Example Syntax:
Request logonStatusRequest = authSvc.CreateRequest("LogonStatusRequest");
logonStatusRequest.Set("ipAddress", "111.22.33.44");
A Schemas
215
Element Value
Type
Description
integer
sid
sidInstance
terminalSid
terminalSidInstance
Example Syntax:
Request request = authSvc.CreateRequest("UserEntitlementsRequest");
Element userinfo = request.GetElement("userInfo");
userinfo.SetElement("uuid", 11223344);
A Schemas
216
Element Value
Type
Description
string
Example Syntax:
Request request = authSvc.CreateRequest("SecurityEntitlementsRequest");
Element securities = request.GetElement("securities");
securities.AppendValue("IBM US Equity");
A Schemas
217
Element Value
uuid
Type
Description
integer
Example Syntax:
Request request = authSvc.CreateRequest("AuthorizationTokenRequest");
request.Set("uuid", 11223344);
Label: A label that identifies which Server API application is requesting the token.
Element
label
Element Value
Type
Description
string
Example Syntax:
Request request = authSvc.CreateRequest("AuthorizationTokenRequest");
request.Set("label", "myApp");
A Schemas
218
Description
AuthorizationSuccess
AuthorizationFailure
reason
responseError
errorInfo
Contains values about the error which has occurred, including the
source, code, category, message, and subcategory.
eidData[ ]
eidData[ ]::eidData
eids[ ]
Type
Description
Source
String
Code
Integer
Category
String
message
String
subcategory
String
entitlementId
Integer
status
Integer
sequenceNumber
Integer
isLoggedOn
Boolean
A Schemas
219
B Error Codes
See the following sections:
General
//BLP/APIAUTH
//BLP/REFDATA
B.1 General
Event Name: ADMIN
Scenario
Message Type
SlowConsumerWarning
SlowConsumerWarningCleared
Category
Message Type
SessionStarted
SessionTerminated
IO_ERROR
SessionStartupFailure
IO_ERROR
SessionConnectionUp
IO_ERROR
SessionConnectionDown
IO_ERROR
B Error Codes
Category
220
Message Type
Category
ServiceOpened
ServiceOpenFailure
IO_ERROR
ServiceOpenFailure
UNCLASSIFIED
B.2 //BLP/APIAUTH
B.2.1 AUTHORIZATION_STATUS, REQUEST_STATUS,
RESPONSE and PARTIAL_RESPONSE Events
Request: AuthorizationRequest
Scenario
Message Type
Category
Sub-Category
AuthorizationSuccess
AuthorizationFailure
NO_AUTH
NOT_LOGGED_IN
AuthorizationFailure
BAD_ARGS
INVALID_USER
ResponseError
NO_AUTH
CROSS_FIRM_AUTH
AuthorizationFailure
NO_AUTH
INVALID_DISPLAY
AuthorizationFailure
NO_AUTH
TOKEN_EXPIRED
AuthorizationFailure
NO_AUTH
BAD_AUTH_TOKEN
AuthorizationFailure
NO_AUTH
CANCELLED_BY_USER
UserAsidEquivalence check
failed
AuthorizationFailure
NO_AUTH
ENTITLEMENTS_MISMATCH
ResponseError
BAD_ARGS
N/A
EntitlementChanged
N/A
N/A
Scenario
Message Type
Category
Sub-Category
EntitlementChanged
N/A
N/A
AuthorizationRevoked
NO_AUTH
INVALID_DISPLAY
AuthorizationFailure
NOT_AVAILABLE
NOT_AVAILABLE_API
AuthorizationRevoked
NO_AUTH
LOCKOUT
AuthorizationRevoked
NO_AUTH
CANCELED_BY_SERVER
AuthorizationRevoked
NO_AUTH
INVALID_DISPLAY
message = "Administrative
Action
message = "Administrative
Action"
A user logs into a Bloomberg
Professional service other than
the one on the PC he is running
his application.
B Error Codes
222
Scenario
Category
Sub-Category
AuthorizationUpdate
NO_AUTH
INVALID_DISPLAY
AuthorizationUpdate
NO_AUTH
LOCKOUT
AuthorizationUpdate
UNCLASSIFIED
CANCELLED_BY_SERVER
AuthorizationRequest
NO_AUTH
NO_APP_PERM
AuthorizationRequest
NO_AUTH
INVALID_ASID_TYPE
AuthorizationRequest
NO_AUTH
CREDENTIAL_REUSE
AuthorizationRequest
NO_AUTH
EXPIRED_AUTHTOKEN
AuthorizationRequest
LIMIT
MAX_DEVICES_EXCEEDED
AuthorizationFailure
LIMIT
n/a
AuthorizationUpdate
NO_AUTH
EMRS_ENTITY_ASID_MISMATCH
AuthorizationFailure
NO_AUTH
EMRS_ENTITY_ASID_MISMATCH
NO_AUTH
EMRS_IPRANGE_MISMATCH
AuthorizationFailure
NO_AUTH
EMRS_DATAFEED_DISABLED
AuthorizationFailure
NO_AUTH
EMRS_PLATFORM_DISABLED
AuthorizationFailure
NO_AUTH
INVALID_DELIVERY_POINT
AuthorizationFailure
NO_AUTH
IP_NOT_IN_RANGE
B Error Codes
223
Scenario
Category
Sub-Category
TokenGenerationSuccess
N/A
N/A
TokenGenerationFailure
NO_AUTH
INTERNAL_ERROR
TokenGenerationFailure
NO_AUTH
INVALID_USER
TokenGenerationFailure
NO_AUTH
INVALID_APP
TokenGenerationFailure
NO_AUTH
CROSS_FIRM_AUTH
TokenGenerationSuccess
TokenGenerationFailure
BAD_ARGS
INVALID_USER or INVALID_APP
Message Type
Category
SubscriptionTerminated
LIMIT
SubscriptionTerminated
UNCLASSIFIED
SubscriptionTerminated
CANCELED
SubscriptionStarted
SubscriptionFailure
NO_AUTH
SubscriptionFailure
BAD_TOPIC
Bad Security
SubscriptionFailure
BAD_SEC
SubscriptionFailure
NOT_MONITORABLE
SubscriptionFailure
NOT_APPLICABLE
Invalid field
SubscriptionFailure
BAD_FLD
Request timed-out.
SubscriptionFailure
TIMEOUT
SubscriptionFailure
UNCLASSIFIED
B Error Codes
224
Scenario
Message Type
Category
SubscriptionFailure
SVC_UNAVAILABLE
SubscriptionFailure
NOT_MONITORABLE
B.4 //BLP/REFDATA
B.4.1 For All Requests
Scenario
Message Type
Category
Sub-Category
ResponseError
LIMIT
DAILY_LIMIT_REACHED
ResponseError
LIMIT
MONTHLY_LIMIT_REACHED
ResponseError
LIMIT
MANUALLY_DISABLED
ResponseError
LIMIT
FREE_TRIAL_TERM_LIMIT_REACHED
ResponseError
NO_AUTH
INVALID_USER
ResponseError
NO_AUTH
NO_PRODUCTS_FOUND
ResponseError
NO_AUTH
CROSS_FIRM_AUTH
ResponseError
BAD_SEC
INVALID_SECURITY_IDENTIFIER
Internal error
ResponseError
UNCLASSIFIED
UNKNOWN
B.4.2 HistoricalDataRequest
Scenario
Message Type
Category
Sub-Category
ResponseError
BAD_ARGS
INVALID_START_END
ResponseError
BAD_ARGS
INVALID_CURRENCY
No Fields requested.
ResponseError
BAD_ARGS
NO_FIELDS
ResponseError
BAD_ARGS
TOO_MANY_FIELDS
Invalid Field
ResponseError
BAD_FLD
INVALID_FIELD
ResponseError
BAD_FLD
INVALID_OVERRIDE_FIELD
ResponseError
BAD_FLD
NOT_APPLICABLE_TO_HIST_DATA
ResponseError
BAD_FLD
NOT_APPLICABLE_TO_SECTOR
ResponseError
NOT_AVAILABLE
NOT_AVAILABLE_API
B Error Codes
225
Message Type
Category
Sub-Category
ResponseError
BAD_ARGS
NO_EVENT_TYPE
B.4.4 ReferenceDataRequest
Scenario
Message Type
Category
Sub-Category
Invalid field
ResponseError
NOT_AVAILABLE
INVALID_FIELD_DATA
ResponseError
BAD_ARGS
TOO_MANY_OVERRIDES
ResponseError
BAD_FLD
INVALID_OVERRIDE_FIELD
ResponseError
BAD_FLD
NOT_APPLICABLE_TO_REF_DATA
B.4.5 categorizedFieldSearchRequest
Scenario
Message Type
Category
Contact Bloomberg.
categorizedFieldResponse
UNCLASSIFIED
categorizedFieldSearchError
BAD_ARGS
categorizedFieldResponse
BAD_FLD
categorizedFieldSearchError
B.4.6 fieldInfoRequest
Scenario
Message Type
Category
Contact Bloomberg.
fieldResponse
UNCLASSIFIED
fieldResponse.fieldData.field
B.4.7 fieldSearchRequest
Scenario
Message Type
Category
fieldSearchError
Invalid request/Invalid Field
IDs
B Error Codes
fieldResponse.fieldSearchError
226
C Java Examples
This section contains the following code examples and sample output from each example:
C Java Examples
227
/ RequestResponseParadigm.java
package BloombergLP;
import
import
import
import
import
import
import
import
com.bloomberglp.blpapi.CorrelationID;
com.bloomberglp.blpapi.Event;
com.bloomberglp.blpapi.Message;
com.bloomberglp.blpapi.MessageIterator;
com.bloomberglp.blpapi.Request;
com.bloomberglp.blpapi.Service;
com.bloomberglp.blpapi.Session;
com.bloomberglp.blpapi.SessionOptions;
C Java Examples
229
C Java Examples
230
// SubscriptionParadigm.java
package BloombergLP;
import
import
import
import
import
import
import
import
com.bloomberglp.blpapi.CorrelationID;
com.bloomberglp.blpapi.Event;
com.bloomberglp.blpapi.Message;
com.bloomberglp.blpapi.MessageIterator;
com.bloomberglp.blpapi.Session;
com.bloomberglp.blpapi.SessionOptions;
com.bloomberglp.blpapi.Subscription;
com.bloomberglp.blpapi.SubscriptionList;
C Java Examples
231
int updateCount = 0;
while (true) {
Event event = session.nextEvent();
switch (event.eventType().intValue()) {
case Event.EventType.Constants.SUBSCRIPTION_DATA:
handleDataEvent(event, updateCount++);
break;
default:
handleOtherEvent(event);
break;
}
}
}
private static void handleDataEvent(Event event, int updateCount)
throws Exception {
System.out.println("EventType=" + event.eventType());
System.out.println("updateCount = " + updateCount);
MessageIterator iter = event.messageIterator();
while (iter.hasNext()) {
Message message = iter.next();
System.out.println("correlationID = " +
message.correlationID());
System.out.println("messageType
= " +
message.messageType());
message.print(System.out);
}
}
private static void handleOtherEvent(Event event) throws Exception
{
System.out.println("EventType=" + event.eventType());
MessageIterator iter = event.messageIterator();
while (iter.hasNext()) {
Message message = iter.next();
System.out.println("correlationID=" +
message.correlationID());
System.out.println("messageType=" + message.messageType());
message.print(System.out);
if (Event.EventType.Constants.SESSION_STATUS ==
event.eventType().intValue()
&& "SessionTerminated" ==
message.messageType().toString()){
System.out.println("Terminating: " +
message.messageType());
System.exit(1);
}
}
}
}
C Java Examples
232
C Java Examples
233
LAST_PRICE_TDY = 93.0
BID_TDY = 92.92
ASK_TDY = 92.95
HIGH_TDY = 94.34
LOW_TDY = 92.6
RT_PRICING_SOURCE = US
ASK_SIZE = 1
BID_SIZE = 1
TIME = 22:20:00.000+00:00
API_MACHINE = n119
EXCH_CODE_LAST = D
EXCH_CODE_BID = Q
EXCH_CODE_ASK = O
EID = 14005
IS_DELAYED_STREAM = false
}
EventType=SUBSCRIPTION_DATA
updateCount = 1
correlationID = User: 2
messageType
= MarketDataEvents
MarketDataEvents = {
LAST_ALL_SESSIONS = 93.0
BID_ALL_SESSION = 92.92
ASK_ALL_SESSION = 92.95
TRADE_SIZE_ALL_SESSIONS_RT = 0
IS_DELAYED_STREAM = false
}
C Java Examples
234
// AsynchronousEventHandling.java
package BloombergLP;
import java.io.IOException;
import
import
import
import
import
import
import
import
import
com.bloomberglp.blpapi.CorrelationID;
com.bloomberglp.blpapi.Event;
com.bloomberglp.blpapi.EventHandler;
com.bloomberglp.blpapi.Message;
com.bloomberglp.blpapi.MessageIterator;
com.bloomberglp.blpapi.Request;
com.bloomberglp.blpapi.Service;
com.bloomberglp.blpapi.Session;
com.bloomberglp.blpapi.SessionOptions;
C Java Examples
235
C Java Examples
236
case Event.EventType.Constants.SERVICE_STATUS: {
MessageIterator iter = event.messageIterator();
while (iter.hasNext()) {
Message message = iter.next();
if (message.correlationID().value() == 99
&& message.messageType().equals("ServiceOpened")) {
//Construct and issue a Request
Service service = session.getService("//blp/refdata");
Request request =
service.createRequest("ReferenceDataRequest");
request.append("securities", "IBM US Equity");
request.append("fields", "LAST_PRICE");
try {
session.sendRequest(request, new CorrelationID(86));
} catch (Exception e) {
System.err.println("Could not send request");
System.exit(1);
}
} else {
System.out.println("Unexpected SERVICE_STATUS message:");
try {
message.print(System.err);
} catch (Exception e){
e.printStackTrace();
}
}
}
break;
}
C Java Examples
237
C Java Examples
238
// RequestResponseMultiple.java
package BloombergLP;
import
import
import
import
import
import
import
import
import
com.bloomberglp.blpapi.CorrelationID;
com.bloomberglp.blpapi.Element;
com.bloomberglp.blpapi.Event;
com.bloomberglp.blpapi.Message;
com.bloomberglp.blpapi.MessageIterator;
com.bloomberglp.blpapi.Request;
com.bloomberglp.blpapi.Service;
com.bloomberglp.blpapi.Session;
com.bloomberglp.blpapi.SessionOptions;
C Java Examples
239
C Java Examples
240
+
+
+
+
+
security);
sequenceNumber);
px_last);
ds002);
vwap_volume);
}
}
}
}
private static void handleOtherEvent(Event event) throws Exception
{
System.out.println("EventType=" + event.eventType());
MessageIterator iter = event.messageIterator();
while (iter.hasNext()) {
Message message = iter.next();
System.out.println("correlationID=" +
message.correlationID());
System.out.println("messageType=" + message.messageType());
message.print(System.out);
if (Event.EventType.Constants.SESSION_STATUS ==
event.eventType().intValue()
&& "SessionTerminated" ==
message.messageType().toString()){
System.out.println("Terminating: " +
message.messageType());
System.exit(1);
}
}
}
}
C Java Examples
241
security
=IBM US Equity
sequenceNumber=1
px_last
=92.51
ds002
=INTL BUSINESS MACHINES CORP
vwap_volume
=8916238.0
* security
=BLAHBLAHBLAH US Equity
securityError = {
source = 193::bbdbs1
code = 15
category = BAD_SEC
message = Unknown/Invalid security [nid:193]
subcategory = INVALID_SECURITY
}
C Java Examples
242
// SubscriptionMultiple.java
package BloombergLP;
import java.io.IOException;
import java.io.PrintStream;
import
import
import
import
import
import
import
import
import
com.bloomberglp.blpapi.CorrelationID;
com.bloomberglp.blpapi.Event;
com.bloomberglp.blpapi.EventHandler;
com.bloomberglp.blpapi.Message;
com.bloomberglp.blpapi.MessageIterator;
com.bloomberglp.blpapi.Session;
com.bloomberglp.blpapi.SessionOptions;
com.bloomberglp.blpapi.Subscription;
com.bloomberglp.blpapi.SubscriptionList;
C Java Examples
243
C Java Examples
244
C Java Examples
245
C Java Examples
246
MarketDataEvents = {
LAST_PRICE = 343.32
BID = 343.43
ASK = 343.44
VOLUME = 7283742
HIGH = 345.05
LOW = 340.11
BEST_BID = 343.43
BEST_ASK = 343.44
LAST_TRADE = 343.32
OPEN = 344.54
PREV_SES_LAST_PRICE = 348.67
INDICATIVE_FAR = 343.16
INDICATIVE_NEAR = 343.16
VWAP = 342.842
THEO_PRICE = 343.16
LAST_ALL_SESSIONS = 344.2
IMBALANCE_INDIC_RT = NOIM
BID_ALL_SESSION = 343.4
ASK_ALL_SESSION = 344.2
TRADING_DT_REALTIME = 2009-01-29+00:00
EQY_TURNOVER_REALTIME = 2.4559597933911133E9
LAST_UPDATE_BID_RT = 21:00:00.000+00:00
LAST_UPDATE_ASK_RT = 21:00:00.000+00:00
TOT_CALL_VOLUME_CUR_DAY_RT = 3644
TOT_PUT_VOLUME_CUR_DAY_RT = 3623
TOT_OPT_VOLUME_CUR_DAY_RT = 7267
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 0
IN_AUCTION_RT = false
RT_API_MACHINE = n242
ALL_PRICE_SIZE = 250
ALL_PRICE = 344.2
VOLUME_THEO = 732968
BID_ASK_TIME = 21:00:00.000+00:00
LAST_AT_TRADE_TDY = 0.0
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.0
HIGH_YLD_TDY = 0.0
LOW_YLD_TDY = 0.0
LAST_YLD_TDY = 0.0
MID_TDY = 0.0
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
RT_PX_CHG_NET_1D = -5.35
RT_PX_CHG_PCT_1D = -1.5344
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 344.54
ASK_SIZE_TDY = 1
BID_SIZE_TDY = 7
VOLUME_TDY = 7283742
LAST_PRICE_TDY = 343.32
C Java Examples
247
BID_TDY = 343.43
ASK_TDY = 343.44
HIGH_TDY = 345.05
LOW_TDY = 340.11
BID_YLD_TDY = 0.0
ASK_YLD_TDY = 0.0
LAST2_PRICE = 340.54
LAST_DIR = 1
LAST2_DIR = -1
BID_DIR = 1
ASK_DIR = -1
BID2 = 343.4
ASK2 = 343.45
ASK_SIZE = 1
BID_SIZE = 7
TIME = 22:20:00.000+00:00
API_MACHINE = n242
TRADE_SIZE_ALL_SESSIONS_RT = 250
EID = 14005
IS_DELAYED_STREAM = false
}
handleDataEvent: leave
handleDataEvent: enter
handler label=myLabel
eventType=SUBSCRIPTION_DATA
messageType=MarketDataEvents
CorrelationID=User: 20
MarketDataEvents = {
VOLUME = 7283742
LAST_AT_TRADE_TDY = 0.0
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.0
HIGH_YLD_TDY = 0.0
LOW_YLD_TDY = 0.0
LAST_YLD_TDY = 0.0
MID_TDY = 0.0
RT_PX_CHG_NET_1D = -5.35
RT_PX_CHG_PCT_1D = -1.5344
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 344.54
ASK_SIZE_TDY = 1
BID_SIZE_TDY = 7
VOLUME_TDY = 7283742
LAST_PRICE_TDY = 343.32
BID_TDY = 343.43
ASK_TDY = 343.44
HIGH_TDY = 345.05
LOW_TDY = 340.11
BID_YLD_TDY = 0.0
ASK_YLD_TDY = 0.0
C Java Examples
248
EID = 14005
IS_DELAYED_STREAM = false
}
handleDataEvent: leave
handleDataEvent: enter
handler label=myLabel
eventType=SUBSCRIPTION_DATA
messageType=MarketDataEvents
CorrelationID=User: 10
MarketDataEvents = {
LAST_PRICE = 92.51
BID = 92.56
ASK = 92.62
VOLUME = 9233664
HIGH = 94.58
LOW = 92.02
BEST_BID = 92.56
BEST_ASK = 92.62
LAST_TRADE = 92.51
OPEN = 93.58
PREV_SES_LAST_PRICE = 94.82
IMBALANCE_ASK = 92.52
ORDER_IMB_SELL_VOLUME = 34800.0
VWAP = 93.2768
THEO_PRICE = 92.52
LAST_ALL_SESSIONS = 92.49
IMBALANCE_INDIC_RT = SELL
BID_ALL_SESSION = 92.31
ASK_ALL_SESSION = 92.5
TRADING_DT_REALTIME = 2009-01-29+00:00
EQY_TURNOVER_REALTIME = 8.743154979367981E8
LAST_UPDATE_BID_RT = 21:00:00.000+00:00
LAST_UPDATE_ASK_RT = 21:00:00.000+00:00
NYSE_LRP_HIGH_PRICE_RT = 93.63
NYSE_LRP_LOW_PRICE_RT = 91.63
NYSE_LRP_SEND_TIME_RT = 20:59:52.000+00:00
TOT_CALL_VOLUME_CUR_DAY_RT = 4950
TOT_PUT_VOLUME_CUR_DAY_RT = 7369
TOT_OPT_VOLUME_CUR_DAY_RT = 12319
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 1
IN_AUCTION_RT = false
RT_API_MACHINE = p065
ALL_PRICE_SIZE = 200
ALL_PRICE = 92.5
VOLUME_THEO = 467100
BID_ASK_TIME = 21:00:00.000+00:00
LAST_AT_TRADE_TDY = 0.0
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.0
HIGH_YLD_TDY = 0.0
LOW_YLD_TDY = 0.0
LAST_YLD_TDY = 0.0
MID_TDY = 0.0
C Java Examples
249
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
RT_PX_CHG_NET_1D = -2.31
RT_PX_CHG_PCT_1D = -2.43619
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 93.58
ASK_SIZE_TDY = 5
BID_SIZE_TDY = 1
VOLUME_TDY = 9233664
LAST_PRICE_TDY = 92.51
BID_TDY = 92.56
ASK_TDY = 92.62
HIGH_TDY = 94.58
LOW_TDY = 92.02
BID_YLD_TDY = 0.0
ASK_YLD_TDY = 0.0
LAST2_PRICE = 92.51
LAST_DIR = -1
LAST2_DIR = 1
BID_DIR = -1
ASK_DIR = 1
BID2 = 92.56
ASK2 = 92.61
ASK_SIZE = 5
BID_SIZE = 1
TIME = 21:15:12.000+00:00
API_MACHINE = p065
TRADE_SIZE_ALL_SESSIONS_RT = 500
EID = 14003
IS_DELAYED_STREAM = false
}
handleDataEvent: leave
handleDataEvent: enter
handler label=myLabel
eventType=SUBSCRIPTION_DATA
messageType=MarketDataEvents
CorrelationID=User: 10
MarketDataEvents = {
VOLUME = 9233664
VWAP = 93.2764
LAST_ALL_SESSIONS = 92.5
BID_ALL_SESSION = 92.31
ASK_ALL_SESSION = 92.5
EQY_TURNOVER_REALTIME = 8.743154979367981E8
ALL_PRICE_SIZE = 200
ALL_PRICE = 92.5
LAST_AT_TRADE_TDY = 0.0
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.0
HIGH_YLD_TDY = 0.0
LOW_YLD_TDY = 0.0
C Java Examples
250
LAST_YLD_TDY = 0.0
MID_TDY = 0.0
RT_PX_CHG_NET_1D = -2.31
RT_PX_CHG_PCT_1D = -2.43619
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 93.58
ASK_SIZE_TDY = 5
BID_SIZE_TDY = 1
VOLUME_TDY = 9233664
LAST_PRICE_TDY = 92.51
BID_TDY = 92.56
ASK_TDY = 92.62
HIGH_TDY = 94.58
LOW_TDY = 92.02
BID_YLD_TDY = 0.0
ASK_YLD_TDY = 0.0
TRADE_SIZE_ALL_SESSIONS_RT = 200
EID = 14003
IS_DELAYED_STREAM = false
}
handleDataEvent: leave
handleDataEvent: enter
handler label=myLabel
eventType=SUBSCRIPTION_DATA
messageType=MarketDataEvents
CorrelationID=User: 40
MarketDataEvents = {
LAST_PRICE = 40.71
BID = 40.71
ASK = 40.77
VOLUME = 8446464
HIGH = 42.76
LOW = 40.37
RT_OPEN_INTEREST = 7953467
BEST_BID = 40.71
BEST_ASK = 40.77
LAST_TRADE = 40.71
OPEN = 42.76
PREV_SES_LAST_PRICE = 43.24
VWAP = 40.9212
TRADING_DT_REALTIME = 2009-01-29+00:00
EQY_TURNOVER_REALTIME = 3.45612128E8
PREV_TRADING_DT_REALTIME = 2009-01-29+00:00
RT_API_MACHINE = p164
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
RT_PX_CHG_NET_1D = -2.53
RT_PX_CHG_PCT_1D = -5.85106
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 42.76
ASK_SIZE_TDY = 124
C Java Examples
251
BID_SIZE_TDY = 228
VOLUME_TDY = 8446464
LAST_PRICE_TDY = 40.71
BID_TDY = 40.71
ASK_TDY = 40.77
HIGH_TDY = 42.76
LOW_TDY = 40.37
RT_PRICING_SOURCE = US
ASK_SIZE = 124
BID_SIZE = 228
TIME = 21:15:02.000+00:00
API_MACHINE = p164
EXCH_CODE_LAST = N
EXCH_CODE_BID = N
EXCH_CODE_ASK = N
EID = 14003
IS_DELAYED_STREAM = false
}
handleDataEvent: leave
handleDataEvent: enter
handler label=myLabel
eventType=SUBSCRIPTION_DATA
messageType=MarketDataEvents
CorrelationID=User: 40
MarketDataEvents = {
LAST_ALL_SESSIONS = 40.71
BID_ALL_SESSION = 40.71
ASK_ALL_SESSION = 40.77
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
RT_PX_CHG_NET_1D = -2.53
RT_PX_CHG_PCT_1D = -5.85106
TIME = 21:15:02.000+00:00
TRADE_SIZE_ALL_SESSIONS_RT = 0
IS_DELAYED_STREAM = false
}
handleDataEvent: leave
com.bloomberglp.blpapi.CorrelationID;
com.bloomberglp.blpapi.Element;
com.bloomberglp.blpapi.Event;
com.bloomberglp.blpapi.Message;
com.bloomberglp.blpapi.MessageIterator;
com.bloomberglp.blpapi.Request;
com.bloomberglp.blpapi.Service;
com.bloomberglp.blpapi.Session;
com.bloomberglp.blpapi.SessionOptions;
com.bloomberglp.blpapi.Identity;
C Java Examples
253
+
+
+
+
+
security);
sequenceNumber);
px_last);
ds002);
vwap_volume);
}
private static void handleResponseEvent(Event event, Identity identity)
throws IOException {
MessageIterator iter = event.messageIterator();
while (iter.hasNext()) {
Message message
= iter.next();
Element ReferenceDataResponse = message.asElement();
if (ReferenceDataResponse.hasElement("responseError")) {
message.print(System.out);
System.exit(1);
}
Element securityDataArray =
ReferenceDataResponse.getElement("securityData");
int
numItems
= securityDataArray.numValues();
for (int i = 0; i < numItems; ++i) {
Element securityData
=
securityDataArray.getValueAsElement(i);
String security
=
securityData.getElementAsString("security");
int
sequenceNumber =
securityData.getElementAsInt32("sequenceNumber");
if (securityData.hasElement("securityError")) {
Element securityError =
securityData.getElement("securityError");
System.out.println("* security
=" + security);
securityError.print(System.out);
return;
}
C Java Examples
254
C Java Examples
255
C Java Examples
256
C Java Examples
257
C Java Examples
258
D .Net Examples
This section contains the following code examples:
D .Net Examples
259
D.1 RequestResponseParadigm
// RequestResponseParadigm.cs
using System;
using System.Collections.Generic;
using System.Text;
using
using
using
using
using
using
using
using
CorrelationID
Element
Event
Message
Request
Service
Session
SessionOptions
=
=
=
=
=
=
=
=
Bloomberglp.Blpapi.CorrelationID;
Bloomberglp.Blpapi.Element;
Bloomberglp.Blpapi.Event;
Bloomberglp.Blpapi.Message;
Bloomberglp.Blpapi.Request;
Bloomberglp.Blpapi.Service;
Bloomberglp.Blpapi.Session;
Bloomberglp.Blpapi.SessionOptions;
namespace RequestResponseParadigm
{
class RequestResponseParadigm
{
static void Main(string[] args)
{
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.ServerHost = "localhost";
sessionOptions.ServerPort = 8194;
Session session = new Session(sessionOptions);
if (!session.Start())
{
System.Console.WriteLine("Could not start session.");
System.Environment.Exit(1);
}
if (!session.OpenService("//blp/refdata"))
{
System.Console.WriteLine("Could not open service " +
"//blp/refdata");
System.Environment.Exit(1);
}
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);
D .Net Examples
260
261
D .Net Examples
262
// SubscriptionParadigm.cs
using System;
using System.Collections.Generic;
using System.Text;
using
using
using
using
using
using
using
CorrelationID
Event
EventHandler
Message
Session
SessionOptions
Subscription
=
=
=
=
=
=
=
Bloomberglp.Blpapi.CorrelationID;
Bloomberglp.Blpapi.Event;
Bloomberglp.Blpapi.EventHandler;
Bloomberglp.Blpapi.Message;
Bloomberglp.Blpapi.Session;
Bloomberglp.Blpapi.SessionOptions;
Bloomberglp.Blpapi.Subscription;
namespace SubscriptionParadigm
{
class SubscriptionParadigm
{
static void Main(string[] args)
{
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.ServerHost = "localhost";
sessionOptions.ServerPort = 8194;
Session session = new Session(sessionOptions);
if (!session.Start())
{
System.Console.WriteLine("Could not start session.");
System.Environment.Exit(1);
}
if (!session.OpenService("//blp/mktdata"))
{
System.Console.WriteLine("Could not open service " +
"//blp/mktdata");
System.Environment.Exit(1);
}
CorrelationID subscriptionID = new CorrelationID(2);
List<Subscription> subscriptions = new List<Subscription>();
subscriptions.Add(new Subscription("AAPL US Equity",
"LAST_PRICE",
subscriptionID));
session.Subscribe(subscriptions);
D .Net Examples
263
int updateCount = 0;
while (true)
{
Event eventObj = session.NextEvent();
switch (eventObj.Type)
{
case Event.EventType.SUBSCRIPTION_DATA:
handleDataEvent(eventObj, updateCount++);
break;
default:
handleOtherEvent(eventObj);
break;
}
}
}
private static void handleDataEvent(Event eventObj, int
updateCount)
{
System.Console.WriteLine("EventType=" + eventObj.Type);
System.Console.WriteLine("updateCount = " + updateCount);
foreach (Message message in eventObj.GetMessages())
{
System.Console.WriteLine("correlationID = " +
message.CorrelationID);
System.Console.WriteLine("messageType
= " +
message.MessageType);
message.Print(System.Console.Out);
}
}
private static void handleOtherEvent(Event eventObj)
{
System.Console.WriteLine("EventType=" + eventObj.Type);
foreach (Message message in eventObj.GetMessages())
{
System.Console.WriteLine("correlationID=" +
message.CorrelationID);
System.Console.WriteLine("messageType=" +
message.MessageType);
message.Print(System.Console.Out);
if (Event.EventType.SESSION_STATUS == eventObj.Type
&& message.MessageType.Equals("SessionTerminated"))
{
System.Console.WriteLine("Terminating: " +
message.MessageType);
System.Environment.Exit(1);
}
}
}
}
}
D .Net Examples
264
D .Net Examples
265
BID_ASK_TIME = 18:45:46.000+00:00
LAST_AT_TRADE_TDY = 0
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0
HIGH_YLD_TDY = 0
LOW_YLD_TDY = 0
LAST_YLD_TDY = 0
MID_TDY = 0
SIZE_LAST_TRADE_TDY = 100
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
RT_PX_CHG_NET_1D = -2.11
RT_PX_CHG_PCT_1D = -2.26882
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 92.6
ASK_SIZE_TDY = 19
BID_SIZE_TDY = 5
VOLUME_TDY = 14304168
LAST_PRICE_TDY = 90.89
BID_TDY = 90.88
ASK_TDY = 90.9
HIGH_TDY = 93.62
LOW_TDY = 90.6
BID_YLD_TDY = 0
ASK_YLD_TDY = 0
LAST2_PRICE = 90.89
LAST_DIR = 1
LAST2_DIR = 1
BID_DIR = -1
ASK_DIR = 1
BID2 = 90.88
ASK2 = 90.9
SIZE_LAST_TRADE = 100
ASK_SIZE = 19
BID_SIZE = 5
TIME = 18:45:45.000+00:00
API_MACHINE = p060
TRADE_SIZE_ALL_SESSIONS_RT = 100
EID = 14005
IS_DELAYED_STREAM = false
}
EventType=SUBSCRIPTION_DATA
updateCount = 1
correlationID = User: 2
messageType
= MarketDataEvents
MarketDataEvents = {
LAST_PRICE = 90.89
BID = 90.88
ASK = 90.9
VOLUME = 14304168
HIGH = 93.62
LOW = 90.6
D .Net Examples
266
BEST_BID = 90.88
BEST_ASK = 90.9
LAST_TRADE = 90.89
VWAP = 91.6348
LAST_ALL_SESSIONS = 90.89
BID_ALL_SESSION = 90.88
ASK_ALL_SESSION = 90.9
EQY_TURNOVER_REALTIME = 1294308731.96565
LAST_UPDATE_BID_RT = 18:45:46.000+00:00
LAST_UPDATE_ASK_RT = 18:45:46.000+00:00
TOT_CALL_VOLUME_CUR_DAY_RT = 12783
TOT_PUT_VOLUME_CUR_DAY_RT = 17211
TOT_OPT_VOLUME_CUR_DAY_RT = 29994
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 1
IN_AUCTION_RT = false
ALL_PRICE_SIZE = 100
ALL_PRICE = 90.89
BID_ASK_TIME = 18:45:46.000+00:00
LAST_AT_TRADE_TDY = 0
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0
HIGH_YLD_TDY = 0
LOW_YLD_TDY = 0
LAST_YLD_TDY = 0
MID_TDY = 0
SIZE_LAST_TRADE_TDY = 100
RT_PX_CHG_NET_1D = -2.11
RT_PX_CHG_PCT_1D = -2.26882
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 92.6
ASK_SIZE_TDY = 19
BID_SIZE_TDY = 5
VOLUME_TDY = 14304168
LAST_PRICE_TDY = 90.89
BID_TDY = 90.88
ASK_TDY = 90.9
HIGH_TDY = 93.62
LOW_TDY = 90.6
BID_YLD_TDY = 0
ASK_YLD_TDY = 0
LAST2_PRICE = 90.89
LAST_DIR = 1
LAST2_DIR = 1
BID_DIR = -1
ASK_DIR = 1
BID2 = 90.88
ASK2 = 90.9
SIZE_LAST_TRADE = 100
ASK_SIZE = 19
BID_SIZE = 5
D .Net Examples
267
TIME = 18:45:45.000+00:00
TRADE_SIZE_ALL_SESSIONS_RT = 100
EID = 14005
IS_DELAYED_STREAM = false
}
D .Net Examples
268
// AsynchronousEventHandling.cs
using System;
using System.Collections.Generic;
using System.Text;
using
using
using
using
using
using
using
using
CorrelationID
Event
EventHandler
Message
Request
Service
Session
SessionOptions
=
=
=
=
=
=
=
=
Bloomberglp.Blpapi.CorrelationID;
Bloomberglp.Blpapi.Event;
Bloomberglp.Blpapi.EventHandler;
Bloomberglp.Blpapi.Message;
Bloomberglp.Blpapi.Request;
Bloomberglp.Blpapi.Service;
Bloomberglp.Blpapi.Session;
Bloomberglp.Blpapi.SessionOptions;
namespace BloombergLP
{
class AsynchronousEventHandling
{
static void Main(string[] args)
{
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.ServerHost = "localhost";
sessionOptions.ServerPort = 8194;
Session session = new Session(sessionOptions,
new EventHandler(ProcessEvent));
session.StartAsync();
// Wait for events
Object obj = new Object();
lock (obj)
{
System.Threading.Monitor.Wait(obj);
}
}
static void dumpEvent(Event eventObj)
{
System.Console.WriteLine("eventType=" + eventObj.Type);
foreach (Message message in eventObj.GetMessages())
{
System.Console.WriteLine("messageType=" +
message.MessageType);
System.Console.WriteLine("CorrelationID=" +
message.CorrelationID);
D .Net Examples
269
try
{
message.Print(System.Console.Out);
}
catch (System.IO.IOException e)
{
System.Console.WriteLine(e);
}
}
}
static public void ProcessEvent(Event eventObj, Session session)
{
switch (eventObj.Type)
{
case Event.EventType.SESSION_STATUS:
{
foreach (Message message in eventObj.GetMessages())
{
if
(message.MessageType.Equals("SessionStarted"))
{
try
{
session.OpenServiceAsync(
"//blp/refdata",
new CorrelationID(99));
}
catch (Exception)
{
System.Console.Error.WriteLine(
"Could not open //blp/refdata for
async");
System.Environment.Exit(1);
}
}
else
{
System.Console.Error.WriteLine(
"Could not start session.");
System.Environment.Exit(1);
}
}
break;
}
D .Net Examples
270
case Event.EventType.SERVICE_STATUS:
{
foreach (Message message in eventObj.GetMessages())
{
if (message.CorrelationID.Value == 99
&& message.MessageType.Equals("ServiceOpened"))
{
//Construct and issue a Request
Service service = session.GetService(
"//blp/refdata");
Request request = service.CreateRequest(
"ReferenceDataRequest");
request.Append("securities",
"IBM US Equity");
request.Append("fields", "PX_LAST");
try
{
session.SendRequest(
request,
new CorrelationID(86));
}
catch (Exception)
{
System.Console.Error.WriteLine(
"Could not send request");
System.Environment.Exit(1);
}
}
else
{
System.Console.WriteLine(
"Unexpected SERVICE_STATUS message:");
try
{
message.Print(System.Console.Error);
}
catch (Exception e)
{
System.Console.WriteLine(e);
}
}
}
break;
}
D .Net Examples
271
case Event.EventType.PARTIAL_RESPONSE:
{//
dumpEvent(eventObj); // Handle Partial Response
break;
}
case Event.EventType.RESPONSE:
{
dumpEvent(eventObj); // Handle final response
// Now, the example is complete. Shut it down.
try
{
session.Stop(Session.StopOption.ASYNC);
}
catch (System.Threading.ThreadInterruptedException
e)
{
System.Console.WriteLine(e);
}
System.Console.Error.WriteLine(
"terminate process from handler");
System.Environment.Exit(0);
break;
}
default:
{
break;
}
case Event.EventType.RESPONSE:
{
dumpEvent(eventObj); // Handle final response
System.Console.WriteLine("unexpected Event");
dumpEvent(eventObj);
System.Environment.Exit(1);
break;
}
}
}
}
}
D .Net Examples
272
D .Net Examples
273
CorrelationID
Element
Event
Message
Request
Service
Session
SessionOptions
=
=
=
=
=
=
=
=
Bloomberglp.Blpapi.CorrelationID;
Bloomberglp.Blpapi.Element;
Bloomberglp.Blpapi.Event;
Bloomberglp.Blpapi.Message;
Bloomberglp.Blpapi.Request;
Bloomberglp.Blpapi.Service;
Bloomberglp.Blpapi.Session;
Bloomberglp.Blpapi.SessionOptions;
namespace RequestResponseMultiple
{
class RequestResponseMultiple
{
static void Main(string[] args)
{
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.ServerHost = "localhost";
sessionOptions.ServerPort = 8194;
Session session = new Session(sessionOptions);
if (!session.Start())
{
System.Console.WriteLine("Could not start session.");
System.Environment.Exit(1);
}
if (!session.OpenService("//blp/refdata"))
{
System.Console.WriteLine("Could not open service " +
"//blp/refdata");
System.Environment.Exit(1);
}
Service refDataSvc = session.GetService("//blp/refdata");
Request request
= refDataSvc.CreateRequest(
"ReferenceDataRequest");
request.GetElement("securities").AppendValue("AAPL US Equity");
request.GetElement("securities").AppendValue("IBM US Equity");
request.GetElement("securities").AppendValue(
"BLAHBLAHBLAH US Equity");
request.GetElement("fields").AppendValue("PX_LAST");
// Last Price
request.GetElement("fields").AppendValue("DS002");
// Description
request.GetElement("fields").AppendValue("VWAP_VOLUME");
// Volume used to calculate the Volume Weighted Average Price
session.SendRequest(request, new CorrelationID(1));
D .Net Examples
274
D .Net Examples
275
else
{
Element fieldData
=
securityData.GetElement("fieldData");
double px_last
=
fieldData.GetElementAsFloat64("PX_LAST");
String ds002
=
fieldData.GetElementAsString("DS002");
double vwap_volume =
fieldData.GetElementAsFloat64("VWAP_VOLUME");
// Individually output each value
System.Console.WriteLine("* security
="
security);
System.Console.WriteLine("* sequenceNumber="
sequenceNumber);
System.Console.WriteLine("* px_last
="
px_last);
System.Console.WriteLine("* ds002
="
ds002);
System.Console.WriteLine("* vwap_volume
="
vwap_volume);
System.Console.WriteLine("");
+
+
+
+
+
}
}
}
}
private static void handleOtherEvent(Event eventObj)
{
System.Console.WriteLine("EventType=" + eventObj.Type);
foreach (Message message in eventObj.GetMessages())
{
System.Console.WriteLine("correlationID=" +
message.CorrelationID);
System.Console.WriteLine("messageType=" +
message.MessageType);
message.Print(System.Console.Out);
if (Event.EventType.SESSION_STATUS == eventObj.Type
&& message.MessageType.Equals("SessionTerminated"))
{
System.Console.WriteLine("Terminating: " +
message.MessageType);
System.Environment.Exit(1);
}
}
}
}
}
D .Net Examples
276
security
=IBM US Equity
sequenceNumber=1
px_last
=92.04
ds002
=INTL BUSINESS MACHINES CORP
vwap_volume
=4661754
* security
=BLAHBLAHBLAH US Equity
securityError = {
source = 236::bbdbs2
code = 15
category = BAD_SEC
message = Unknown/Invalid security [nid:236]
subcategory = INVALID_SECURITY
}
D .Net Examples
277
System;
System.Collections.Generic;
System.Text;
System.IO;
using
using
using
using
using
using
using
CorrelationID
Event
EventHandler
Message
Session
SessionOptions
Subscription
=
=
=
=
=
=
=
Bloomberglp.Blpapi.CorrelationID;
Bloomberglp.Blpapi.Event;
Bloomberglp.Blpapi.EventHandler;
Bloomberglp.Blpapi.Message;
Bloomberglp.Blpapi.Session;
Bloomberglp.Blpapi.SessionOptions;
Bloomberglp.Blpapi.Subscription;
namespace SubscriptionMultiple
{
class SubscriptionEventHandler {
private String
d_label;
private TextWriter d_printStream;
// CREATORS
public SubscriptionEventHandler(String label, TextWriter
printStream)
{
d_label = label;
d_printStream = printStream;
}
// MANIPULATORS
public void ProcessEvent(Event eventObj, Session session)
{
switch (eventObj.Type)
{
case Event.EventType.SUBSCRIPTION_DATA:
handleDataEvent(eventObj, session);
break;
case Event.EventType.SESSION_STATUS:
case Event.EventType.SERVICE_STATUS:
case Event.EventType.SUBSCRIPTION_STATUS:
handleStatusEvent(eventObj, session);
break;
default:
{
handleOtherEvent(eventObj, session);
break;
}
}
}
D .Net Examples
278
279
if (!session.Start())
{
System.Console.WriteLine("Could not start session.");
System.Environment.Exit(1);
}
if (!session.OpenService("//blp/mktdata"))
{
System.Console.WriteLine("Could not open service " +
"//blp/mktdata");
System.Environment.Exit(1);
}
List<Subscription> subscriptions = new List<Subscription>();
subscriptions.Add(new Subscription("IBM US Equity",
"LAST_TRADE",
new CorrelationID(10)));
subscriptions.Add(new Subscription("/ticker/GOOG US Equity",
"BID,ASK,LAST_PRICE",
new CorrelationID(20)));
subscriptions.Add(new Subscription("MSFTT US Equity",
"LAST_PRICE",
"interval=.5",
new CorrelationID(30)));
subscriptions.Add(new Subscription( //BA US Equity
"/cusip/097023105?fields=LAST_PRICE&interval=5.0",
new CorrelationID(40)));
session.Subscribe(subscriptions);
// Wait for events
Object obj = new Object();
lock (obj)
{
System.Threading.Monitor.Wait(obj);
}
}
}
}
D .Net Examples
280
D .Net Examples
281
handleStatusEvent: leave
handleDataEvent: enter
handler label=myLabel
eventType=SUBSCRIPTION_DATA
messageType=MarketDataEvents
CorrelationID=User: 20
MarketDataEvents = {
LAST_PRICE = 340.7
BID = 340.74
ASK = 340.92
VOLUME = 2630520
HIGH = 348.8
LOW = 337.62
BEST_BID = 340.74
BEST_ASK = 340.92
LAST_TRADE = 340.7
OPEN = 344.69
PREV_SES_LAST_PRICE = 343.32
INDICATIVE_FAR = 344.69
INDICATIVE_NEAR = 344.69
IMBALANCE_ASK = 344.76
VWAP = 341.6714
LAST_ALL_SESSIONS = 340.7
IMBALANCE_INDIC_RT = SELL
BID_ALL_SESSION = 340.74
ASK_ALL_SESSION = 340.92
TRADING_DT_REALTIME = 2009-01-30+00:00
EQY_TURNOVER_REALTIME = 891123786.45166
LAST_UPDATE_BID_RT = 18:46:07.000+00:00
LAST_UPDATE_ASK_RT = 18:46:09.000+00:00
TOT_CALL_VOLUME_CUR_DAY_RT = 2146
TOT_PUT_VOLUME_CUR_DAY_RT = 2887
TOT_OPT_VOLUME_CUR_DAY_RT = 5033
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 1
IN_AUCTION_RT = false
RT_API_MACHINE = p060
ALL_PRICE_SIZE = 300
ALL_PRICE = 340.7
BID_ASK_TIME = 18:46:09.000+00:00
LAST_AT_TRADE_TDY = 0
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0
HIGH_YLD_TDY = 0
LOW_YLD_TDY = 0
LAST_YLD_TDY = 0
MID_TDY = 0
SIZE_LAST_TRADE_TDY = 300
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
RT_PX_CHG_NET_1D = -2.62
RT_PX_CHG_PCT_1D = -0.763135
IND_BID_FLAG = false
IND_ASK_FLAG = false
D .Net Examples
282
OPEN_TDY = 344.69
ASK_SIZE_TDY = 3
BID_SIZE_TDY = 3
VOLUME_TDY = 2630520
LAST_PRICE_TDY = 340.7
BID_TDY = 340.74
ASK_TDY = 340.92
HIGH_TDY = 348.8
LOW_TDY = 337.62
BID_YLD_TDY = 0
ASK_YLD_TDY = 0
LAST2_PRICE = 340.77
LAST_DIR = -1
LAST2_DIR = -1
BID_DIR = 1
ASK_DIR = -1
BID2 = 340.74
ASK2 = 340.92
SIZE_LAST_TRADE = 300
ASK_SIZE = 3
BID_SIZE = 3
TIME = 18:46:02.000+00:00
API_MACHINE = p060
TRADE_SIZE_ALL_SESSIONS_RT = 300
EID = 14005
IS_DELAYED_STREAM = false
}
handleDataEvent: leave
handleDataEvent: enter
handler label=myLabel
eventType=SUBSCRIPTION_DATA
messageType=MarketDataEvents
CorrelationID=User: 10
MarketDataEvents = {
LAST_PRICE = 91.88
BID = 91.85
ASK = 91.88
VOLUME = 4625564
HIGH = 93.48
LOW = 91.56
BEST_BID = 91.85
BEST_ASK = 91.88
LAST_TRADE = 91.88
OPEN = 92.23
PREV_SES_LAST_PRICE = 92.51
VWAP = 92.5054
THEO_PRICE = 0
LAST_ALL_SESSIONS = 91.88
IMBALANCE_INDIC_RT = NOIM
BID_ALL_SESSION = 91.85
ASK_ALL_SESSION = 91.88
TRADING_DT_REALTIME = 2009-01-30+00:00
EQY_TURNOVER_REALTIME = 426434047.387161
D .Net Examples
283
FINANCIAL_STATUS_INDICATOR_RT = 0
LAST_UPDATE_BID_RT = 18:46:09.000+00:00
LAST_UPDATE_ASK_RT = 18:46:09.000+00:00
NYSE_LRP_HIGH_PRICE_RT = 92.85
NYSE_LRP_LOW_PRICE_RT = 90.85
NYSE_LRP_SEND_TIME_RT = 18:46:08.000+00:00
TOT_CALL_VOLUME_CUR_DAY_RT = 1507
TOT_PUT_VOLUME_CUR_DAY_RT = 2122
TOT_OPT_VOLUME_CUR_DAY_RT = 3629
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 1
IN_AUCTION_RT = false
RT_API_MACHINE = n160
ALL_PRICE_SIZE = 100
ALL_PRICE = 91.88
VOLUME_THEO = 0
BID_ASK_TIME = 18:46:09.000+00:00
LAST_AT_TRADE_TDY = 0
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0
HIGH_YLD_TDY = 0
LOW_YLD_TDY = 0
LAST_YLD_TDY = 0
MID_TDY = 0
SIZE_LAST_TRADE_TDY = 100
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
RT_PX_CHG_NET_1D = -0.6299
RT_PX_CHG_PCT_1D = -0.680898
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 92.23
ASK_SIZE_TDY = 1
BID_SIZE_TDY = 3
VOLUME_TDY = 4625564
LAST_PRICE_TDY = 91.88
BID_TDY = 91.85
ASK_TDY = 91.88
HIGH_TDY = 93.48
LOW_TDY = 91.56
BID_YLD_TDY = 0
ASK_YLD_TDY = 0
LAST2_PRICE = 91.87
LAST_DIR = 1
LAST2_DIR = 1
BID_DIR = 1
ASK_DIR = 1
D .Net Examples
284
BID2 = 91.85
ASK2 = 91.88
SIZE_LAST_TRADE = 100
ASK_SIZE = 1
BID_SIZE = 3
TIME = 18:46:09.000+00:00
API_MACHINE = n160
TRADE_SIZE_ALL_SESSIONS_RT = 100
EID = 14003
IS_DELAYED_STREAM = false
}
D .Net Examples
285
E C++ Examples
This section contains the following code examples:
Note: These examples use assert statements to make manifest the program state at
various key points. Follow your organizations guidelines for best practices on the use of
assert statements in production code.
E C++ Examples
286
E.1 RequestResponseParadigm
// RequestResponseParadigm.cpp
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
#include <iostream>
#include <string.h>
// for strcmp(3C)
E C++ Examples
287
message.print(std::cout);
if (Event::SESSION_STATUS == event.eventType()
&& 0 == ::strcmp("SessionTerminated",
message.messageType().string())) {
std::cout << "Terminating: "
<< message.messageType()
<< std::endl;
::exit(1);
}
}
}
int main()
{
SessionOptions sessionOptions;
sessionOptions.setServerHost("localhost");
sessionOptions.setServerPort(8194);
Session session(sessionOptions);
// Establish session
// Start Session
if (!session.start()) {
std::cerr << "Failed to start session." << std::endl;
return 1;
}
if (!session.openService("//blp/refdata")){
std::cerr << "Failed to open service //blp/refdata." << std::endl;
return 1;
}
CorrelationId requestId(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);
E C++ Examples
288
E C++ Examples
289
// SubscriptionParadigm.cpp
#include
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
<blpapi_subscriptionlist.h>
#include <iostream>
using namespace BloombergLP;
using namespace blpapi;
static void handleDataEvent(const Event& event, int updateCount) {
std::cout << "EventType="
<< event.eventType()
<< std::endl;
std::cout << "updateCount = "
<< updateCount
<< std::endl;
MessageIterator iter(event);
while (iter.next()) {
Message message = iter.message();
std::cout << "correlationId = "
<< message.correlationId()
<< std::endl;
std::cout << "messageType
= "
<< message.messageType()
<< std::endl;
message.print(std::cout);
}
}
static void handleOtherEvent(const Event& event)
{
std::cout << "EventType="
<< event.eventType()
<< std::endl;
E C++ Examples
290
MessageIterator iter(event);
while (iter.next()) {
Message message = iter.message();
std::cout << "correlationId="
<< message.correlationId()
<< std::endl;
std::cout << "messageType="
<< message.messageType()
<< std::endl;
message.print(std::cout);
if (Event::SESSION_STATUS == event.eventType()
&& 0 == ::strcmp("SessionTerminated",
message.messageType().string())) {
std::cout << "Terminating: "
<< message.messageType()
<< std::endl;
::exit(1);
}
}
}
int main(int argc, char **argv)
{
SessionOptions sessionOptions;
sessionOptions.setServerHost("localhost");
sessionOptions.setServerPort(8194);
Session session(sessionOptions);
if (!session.start()) {
std::cerr <<"Failed to start session." << std::endl;
return 1;
}
if (!session.openService("//blp/mktdata")) {
std::cerr <<"Failed to open //blp/mktdata" << std::endl;
return 1;
}
E C++ Examples
291
E C++ Examples
292
E C++ Examples
293
LAST_AT_TRADE_TDY = 0.000000
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.000000
HIGH_YLD_TDY = 0.000000
LOW_YLD_TDY = 0.000000
LAST_YLD_TDY = 0.000000
MID_TDY = 0.000000
SIZE_LAST_TRADE_TDY =
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 93.090000
ASK_SIZE_TDY = 1
BID_SIZE_TDY = 1
VOLUME_TDY = 21170839
LAST_PRICE_TDY = 93.000000
BID_TDY = 92.920000
ASK_TDY = 92.950000
HIGH_TDY = 94.340000
LOW_TDY = 92.600000
BID_YLD_TDY = 0.000000
ASK_YLD_TDY = 0.000000
LAST2_PRICE = 93.070000
LAST_DIR = -1
LAST2_DIR = 1
RT_PRICING_SOURCE = US
SIZE_LAST_TRADE =
ASK_SIZE = 1
BID_SIZE = 1
API_MACHINE = n208
EXCH_CODE_LAST =
EXCH_CODE_BID = Q
EXCH_CODE_ASK = O
TRADE_SIZE_ALL_SESSIONS_RT = 400
IS_DELAYED_STREAM = false
EID = 14005
PREV_SES_LAST_PRICE = 94.200000
RT_PX_CHG_NET_1D = -1.200000
RT_PX_CHG_PCT_1D = -1.273890
TIME = 22:20:00.000+00:00
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
}
E C++ Examples
294
// AsynchronousEventHandling.cpp
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
#include <iostream>
#include <string.h>
#include <unistd.h>
// for strcmp(3C)
// for pause(2)
E C++ Examples
295
// MANIPULATORS
bool RefDataEventHandler::processEvent(const Event& event,
Session
*session)
{
switch (event.eventType()) {
case Event::SESSION_STATUS: {
MessageIterator iter(event);
while (iter.next()) {
Message message = iter.message();
if (0 == ::strcmp("SessionStarted",
message.messageType().string())) {
session->openServiceAsync("//blp/refdata",
CorrelationId((long long)99));
} else {
std::cerr << "Session Start Failure" << std::endl;
message.print(std::cerr);
::exit(1);
}
}
break;
}
case Event::SERVICE_STATUS: {
MessageIterator iter(event);
iter.next();
Message message = iter.message();
if (message.correlationId() == 99
&& 0 == ::strcmp("ServiceOpened",
message.messageType().string())) {
// Construct and issue a Request
Service service = session->getService("//blp/refdata");
Request request =
service.createRequest("ReferenceDataRequest");
request.append("securities", "IBM US Equity");
request.append("fields", "LAST_PRICE");
session->sendRequest(request, CorrelationId((long long)86));
} else {
std::cerr << "Unexpected message" << std::endl;
message.print(std::cerr);
::exit(1);
}
break;
}
case Event::PARTIAL_RESPONSE: {
dumpEvent(event);
break;
}
case Event::RESPONSE: {
dumpEvent(event);
session->stop();
std::cout << "terminate process from handler" << std::endl;
::exit(0);
break;
}
E C++ Examples
296
default: {
std::cerr << "Unxepected Event Type"
<< event.eventType()
<< std::endl;
::exit(1);
break;
}
}
return true;
}
void RefDataEventHandler::dumpEvent(const Event& event)
{
std::cout << "eventType="
<< event.eventType()
<< std::endl;
MessageIterator messageIterator(event);
while (messageIterator.next()) {
Message message = messageIterator.message();
std::cout << "messageType="
<< message.messageType()
<< std::endl;
std::cout << "CorrelationId="
<< message.correlationId()
<< std::endl;
message.print(std::cout);
}
}
}
int main()
{
SessionOptions sessionOptions;
sessionOptions.setServerHost("localhost");
sessionOptions.setServerPort(8194);
RefDataEventHandler refDataEventHandler;
Session session(sessionOptions, &refDataEventHandler);
// Start Session
if (!session.startAsync()) {
std::cerr << "Failed to start async session." << std::endl;
return 1;
}
::pause();
return 0;
}
E C++ Examples
297
E C++ Examples
298
// RequestResponseParadigm.cpp
#include
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_element.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
#include <iostream>
#include <string.h>
// for strcmp(3C)
E C++ Examples
299
} else {
Element
double
std::string
double
fieldData
=
securityData.getElement("fieldData");
px_last
=
fieldData.getElementAsFloat64("PX_LAST");
ds002
=
fieldData.getElementAsString("DS002");
vwap_volume =
fieldData.getElementAsFloat64("VWAP_VOLUME");
// Individually
std::cout << "*
<< "*
<< "*
<< "*
<< "*
security
sequenceNumber
px_last
ds002
vwap_volume
<<
<< "\n"
<< "\n"
<< "\n"
<< "\n"
<< "\n"
std::endl;
}
}
}
}
static void handleOtherEvent(const Event& event)
{
std::cout << "EventType="
<< event.eventType()
<< std::endl;
MessageIterator iter(event);
while (iter.next()) {
Message message = iter.message();
std::cout << "correlationId="
<< message.correlationId()
<< std::endl;
std::cout << "messageType="
<< message.messageType()
<< std::endl;
message.print(std::cout);
if (Event::SESSION_STATUS == event.eventType()
&& 0 == ::strcmp("SessionTerminated", message.messageType().string())){
std::cout << "Terminating: "
<< message.messageType()
<< std::endl;
::exit(1);
}
}
}
E C++ Examples
300
int main()
{
SessionOptions sessionOptions;
sessionOptions.setServerHost("localhost");
sessionOptions.setServerPort(8194);
Session session(sessionOptions);
// Establish session
// Start Session
if (!session.start()) {
std::cerr << "Failed to start session." << std::endl;
return 1;
}
if (!session.openService("//blp/refdata")){
std::cerr << "Failed to open service //blp/refdata." << std::endl;
return 1;
}
CorrelationId requestId(1);
Service refDataSvc = session.getService("//blp/refdata");
Request request = refDataSvc.createRequest("ReferenceDataRequest");
// append fields to request
std::cout << "Initialize Request" << std::endl;
request.getElement("securities").appendValue("AAPL US Equity");
request.getElement("securities").appendValue("IBM US Equity");
request.getElement("securities").appendValue("BLAHBLAHBLAH US
Equity");
request.getElement("fields").appendValue("PX_LAST");
request.getElement("fields").appendValue("DS002");
request.getElement("fields").appendValue("VWAP_VOLUME");
// Volume used to calcuate the Volume Weighted Average Price (VWAP)
session.sendRequest(request, CorrelationId(1));
bool continueToLoop = true;
while (continueToLoop) {
Event event = session.nextEvent();
switch (event.eventType()) {
case Event::RESPONSE:
// final event
continueToLoop = false;
// fall through
case Event::PARTIAL_RESPONSE:
handleResponseEvent(event);
break;
default:
handleOtherEvent(event);
break;
}
}
E C++ Examples
301
session.stop();
return 0;
}
security
=IBM US Equity
sequenceNumber=1
px_last
=92.37
ds002
=INTL BUSINESS MACHINES CORP
vwap_volume
=4.22627e+06
* security
=BLAHBLAHBLAH US Equity
securityError = {
source = 119::bbdbs1
code = 15
category = BAD_SEC
message = Unknown/Invalid security [nid:119]
subcategory = INVALID_SECURITY
}
E C++ Examples
302
// SubscriptionMultiple.cpp
#include
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
<blpapi_subscriptionlist.h>
#include <iostream>
#include <cassert>
#include <string>
#include <unistd.h>
// for pause(2)
handleDataEvent
(const
const
handleStatusEvent(const
const
handleOtherEvent (const
const
Event&
Session&
Event&
Session&
Event&
Session&
event,
session);
event,
session);
event,
session);
void
dumpEvent(const Event& event);
public:
// CREATORS
SubscriptionEventHandler(const std::string& label,
std::ostream
*stream);
~SubscriptionEventHandler();
// MANIPULATORS
bool processEvent(const Event& event, Session *session);
};
E C++ Examples
303
// CREATORS
SubscriptionEventHandler::SubscriptionEventHandler(const std::string&
label,
std::ostream
*stream)
: d_label(label)
, d_stream(stream)
{
assert(d_stream);
}
SubscriptionEventHandler::~SubscriptionEventHandler()
{
}
// MANIPULATORS
bool SubscriptionEventHandler::processEvent(const Event& event,
Session
*session)
{
assert(session);
switch (event.eventType()) {
case Event::SUBSCRIPTION_DATA:
handleDataEvent(event, *session);
break;
case Event::SESSION_STATUS:
case Event::SERVICE_STATUS:
case Event::SUBSCRIPTION_STATUS:
handleStatusEvent(event, *session);
break;
default:
handleOtherEvent(event, *session);
break;
}
return true;
}
void SubscriptionEventHandler::dumpEvent(const Event& event)
{
*d_stream << "handler label="
<< d_label
<< std::endl
<< "eventType="
<< event.eventType()
<< std::endl;
E C++ Examples
304
MessageIterator messageIterator(event);
while (messageIterator.next()) {
Message message = messageIterator.message();
*d_stream << "messageType="
<< message.messageType()
<< std::endl
<< "CorrelationId="
<< message.correlationId()
<< std::endl;
message.print(*d_stream);
}
}
void SubscriptionEventHandler::handleDataEvent(const Event&
event,
const Session& session)
{
*d_stream << "handleDataEventHandler: enter" << std::endl;
dumpEvent(event);
*d_stream << "handleDataEventHandler: leave" << std::endl;
}
void SubscriptionEventHandler::handleStatusEvent(const Event&
event,
const Session& session)
{
*d_stream << "handleStatusEventHandler: enter" << std::endl;
dumpEvent(event);
*d_stream << "handleStatusEventHandler: leave" << std::endl;
}
void SubscriptionEventHandler::handleOtherEvent(const Event&
event,
const Session& session)
{
*d_stream << "handleOtherEvent: enter" << std::endl;
dumpEvent(event);
*d_stream << "handleOtherEvent: leave" << std::endl;
}
}
E C++ Examples
305
E C++ Examples
306
E C++ Examples
307
handleStatusEventHandler: leave
handleDataEventHandler: enter
handler label=myLabel
eventType=8
messageType=MarketDataEvents
CorrelationId=[ valueType=INT classId=0 value=20 ]
MarketDataEvents = {
LAST_PRICE = 338.460000
BID = 338.360000
ASK = 338.500000
VOLUME = 4068281
HIGH = 348.800000
LOW = 336.001000
BEST_BID = 338.360000
BEST_ASK = 338.500000
LAST_TRADE = 338.460000
OPEN = 344.690000
INDICATIVE_FAR = 344.690000
INDICATIVE_NEAR = 344.690000
IMBALANCE_BID =
IMBALANCE_ASK = 344.760000
VWAP = 341.666700
LAST_ALL_SESSIONS = 338.460000
IMBALANCE_INDIC_RT = SELL
PREV_CLOSE_VALUE_REALTIME = 343.320000
BID_ALL_SESSION = 338.360000
ASK_ALL_SESSION = 338.500000
TRADING_DT_REALTIME = 2009-01-30
EQY_TURNOVER_REALTIME = 1379007507.741211
TOT_CALL_VOLUME_CUR_DAY_RT = 3266
TOT_PUT_VOLUME_CUR_DAY_RT = 4650
TOT_OPT_VOLUME_CUR_DAY_RT = 7916
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 1
IN_AUCTION_RT = false
RT_API_MACHINE = p060
ALL_PRICE_SIZE = 100
ALL_PRICE = 338.460000
ALL_PRICE_COND_CODE =
BID_COND_CODE =
ASK_COND_CODE =
LAST_AT_TRADE_TDY = 0.000000
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.000000
HIGH_YLD_TDY = 0.000000
LOW_YLD_TDY = 0.000000
LAST_YLD_TDY = 0.000000
MID_TDY = 0.000000
SIZE_LAST_TRADE_TDY = 100
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 344.690000
E C++ Examples
308
ASK_SIZE_TDY = 2
BID_SIZE_TDY = 3
VOLUME_TDY = 4068281
LAST_PRICE_TDY = 338.460000
BID_TDY = 338.360000
ASK_TDY = 338.500000
HIGH_TDY = 348.800000
LOW_TDY = 336.001000
BID_YLD_TDY = 0.000000
ASK_YLD_TDY = 0.000000
LAST2_PRICE = 338.450000
LAST_DIR = 1
LAST2_DIR = 1
BID_DIR = 1
ASK_DIR = 1
BID2 = 338.360000
ASK2 = 338.500000
SIZE_LAST_TRADE = 100
ASK_SIZE = 2
BID_SIZE = 3
API_MACHINE = p060
EXCH_CODE_LAST =
EXCH_CODE_BID =
EXCH_CODE_ASK =
TRADE_SIZE_ALL_SESSIONS_RT = 100
IS_DELAYED_STREAM = false
EID = 14005
PREV_SES_LAST_PRICE = 343.320000
RT_PX_CHG_NET_1D = -4.860000
RT_PX_CHG_PCT_1D = -1.415590
TIME = 20:48:30.000+00:00
LAST_UPDATE_BID_RT = 20:48:33.000+00:00
LAST_UPDATE_ASK_RT = 20:48:32.000+00:00
BID_ASK_TIME = 20:48:33.000+00:00
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
}
handleDataEventHandler: leave
handleDataEventHandler: enter
handler label=myLabel
eventType=8
messageType=MarketDataEvents
CorrelationId=[ valueType=INT classId=0 value=10 ]
MarketDataEvents = {
LAST_PRICE = 91.830000
BID = 91.820000
ASK = 91.830000
VOLUME = 7233307
HIGH = 93.480000
LOW = 91.250000
BEST_BID = 91.820000
BEST_ASK = 91.830000
LAST_TRADE = 91.830000
E C++ Examples
309
OPEN = 92.230000
IMBALANCE_BID =
IMBALANCE_ASK = 91.780000
ORDER_IMB_BUY_VOLUME =
ORDER_IMB_SELL_VOLUME = 54500.000000
VWAP = 92.495700
THEO_PRICE = 0.000000
LAST_ALL_SESSIONS = 91.830000
IMBALANCE_INDIC_RT = SELL
PREV_CLOSE_VALUE_REALTIME = 92.510000
BID_ALL_SESSION = 91.820000
ASK_ALL_SESSION = 91.830000
TRADING_DT_REALTIME = 2009-01-30
EQY_TURNOVER_REALTIME = 666435537.542725
FINANCIAL_STATUS_INDICATOR_RT = 0
NYSE_LRP_HIGH_PRICE_RT = 92.850000
NYSE_LRP_LOW_PRICE_RT = 90.850000
TOT_CALL_VOLUME_CUR_DAY_RT = 2345
TOT_PUT_VOLUME_CUR_DAY_RT = 2282
TOT_OPT_VOLUME_CUR_DAY_RT = 4627
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 0
IN_AUCTION_RT = false
RT_API_MACHINE = n160
ALL_PRICE_SIZE = 100
ALL_PRICE = 91.830000
ALL_PRICE_COND_CODE =
BID_COND_CODE =
ASK_COND_CODE =
VOLUME_THEO = 0
LAST_AT_TRADE_TDY = 0.000000
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.000000
HIGH_YLD_TDY = 0.000000
LOW_YLD_TDY = 0.000000
LAST_YLD_TDY = 0.000000
MID_TDY = 0.000000
SIZE_LAST_TRADE_TDY = 100
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 92.230000
ASK_SIZE_TDY = 1
BID_SIZE_TDY = 2
VOLUME_TDY = 7233307
LAST_PRICE_TDY = 91.830000
BID_TDY = 91.820000
ASK_TDY = 91.830000
HIGH_TDY = 93.480000
LOW_TDY = 91.250000
BID_YLD_TDY = 0.000000
ASK_YLD_TDY = 0.000000
LAST2_PRICE = 91.839000
E C++ Examples
310
LAST_DIR = -1
LAST2_DIR = 1
BID_DIR = -1
ASK_DIR = -1
BID2 = 91.820000
ASK2 = 91.830000
SIZE_LAST_TRADE = 100
ASK_SIZE = 1
BID_SIZE = 2
API_MACHINE = n160
EXCH_CODE_LAST =
EXCH_CODE_BID =
EXCH_CODE_ASK =
TRADE_SIZE_ALL_SESSIONS_RT = 100
IS_DELAYED_STREAM = false
EID = 14003
PREV_SES_LAST_PRICE = 92.510000
RT_PX_CHG_NET_1D = -0.679900
RT_PX_CHG_PCT_1D = -0.734947
TIME = 20:48:34.000+00:00
LAST_UPDATE_BID_RT = 20:48:34.000+00:00
LAST_UPDATE_ASK_RT = 20:48:34.000+00:00
NYSE_LRP_SEND_TIME_RT = 20:48:34.000+00:00
BID_ASK_TIME = 20:48:34.000+00:00
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
}
E C++ Examples
311
F C Examples
This section contains the following code examples:
Note: These examples use assert statements to make manifest the program state at
various key points. Follow your organizations guidelines for best practices on the use of
assert statements in production code.
Note: When using the C language interface the programmer must explicitly recover allocated
resources such as sessions, session options, requests, and message iterators. In general, a
pointer to a resource obtained from a function containing the word create must be
recovered by invoking a similarly named function containing the word destroy. For
example, the blpapi_Service_createRequest function delivers a pointer to a
blpapi_Request_t type and that pointer, when no longer needed, must be passed to the
blpapi_Request_destroy function.
F C Examples
312
F.1 RequestResponseParadigm
/* RequestResponseParadigm.c */
#include
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_element.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
#include
#include
#include
#include
<assert.h>
<stdio.h>
<stdlib.h>
<string.h>
F C Examples
313
F C Examples
314
int main()
{
blpapi_SessionOptions_t
blpapi_Session_t
blpapi_CorrelationId_t
blpapi_Service_t
blpapi_Request_t
blpapi_Element_t
blpapi_Element_t
blpapi_Element_t
int
blpapi_CorrelationId_t
*sessionOptions
*session
requestId;
*refDataSvc
*request
*elements
*securitiesElements
*fieldsElements
continueToLoop
correlationId;
= 0;
= 0;
=
=
=
=
=
=
0;
0;
0;
0;
0;
1;
sessionOptions = blpapi_SessionOptions_create();
assert(sessionOptions);
blpapi_SessionOptions_setServerHost(sessionOptions, "localhost");
blpapi_SessionOptions_setServerPort(sessionOptions, "8194")
session = blpapi_Session_create(sessionOptions, 0, 0, 0);
assert(session);
blpapi_SessionOptions_destroy(sessionOptions);
if (0 != blpapi_Session_start(session)) {
fprintf(stderr, "Failed to start session.\n");
blpapi_Session_destroy(session);
return 1;
}
if (0 != blpapi_Session_openService(session, "//blp/refdata")){
fprintf(stderr, "Failed to open service //blp/refdata.\n");
blpapi_Session_destroy(session);
return 1;
}
memset(&requestId, '\0', sizeof(requestId));
requestId.size
= sizeof(requestId);
requestId.valueType
= BLPAPI_CORRELATION_TYPE_INT;
requestId.value.intValue = (blpapi_UInt64_t)1;
blpapi_Session_getService(session, &refDataSvc, "//blp/refdata");
blpapi_Service_createRequest(refDataSvc,
&request,
"ReferenceDataRequest");
assert(request);
F C Examples
315
elements = blpapi_Request_elements(request);
assert(elements);
blpapi_Element_getElement(elements,
&securitiesElements,
"securities",
0);
assert(securitiesElements);
blpapi_Element_setValueString(securitiesElements,
"IBM US Equity",
BLPAPI_ELEMENT_INDEX_END);
blpapi_Element_getElement(elements, &fieldsElements, "fields", 0);
blpapi_Element_setValueString(fieldsElements,
"PX_LAST",
BLPAPI_ELEMENT_INDEX_END);
memset(&correlationId, '\0',
correlationId.size
correlationId.valueType
correlationId.value.intValue
sizeof(correlationId));
= sizeof(correlationId);
= BLPAPI_CORRELATION_TYPE_INT;
= (blpapi_UInt64_t)1;
F C Examples
316
F C Examples
317
/* SubscriptionParadigm.c */
#include
#include
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_element.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
<blpapi_subscriptionlist.h>
#include
#include
#include
#include
<assert.h>
<stdio.h>
<stdlib.h>
<string.h>
/* for exit(2) */
/* for strcmp(3C) and memset(3C) */
F C Examples
318
printf("messageType
= %s\n", blpapi_Message_typeString(message));
messageElements = blpapi_Message_elements(message);
blpapi_Element_print(messageElements, &streamWriter, stdout, 0, 4);
}
blpapi_MessageIterator_destroy(iter);
}
static void handleOtherEvent(const blpapi_Event_t *event)
{
blpapi_MessageIterator_t *iter
= 0;
blpapi_Message_t
*message = 0;
assert(event);
printf("EventType=%d\n", blpapi_Event_eventType(event));
iter = blpapi_MessageIterator_create(event);
assert(iter);
while (0 == blpapi_MessageIterator_next(iter, &message)) {
blpapi_CorrelationId_t correlationId;
blpapi_Element_t
*messageElements = 0;
assert(message);
correlationId = blpapi_Message_correlationId(message, 0);
printf("correlationId=%d %d %lld\n",
correlationId.valueType,
correlationId.classId,
correlationId.value.intValue);
printf("messageType=%s\n", blpapi_Message_typeString(message));
messageElements = blpapi_Message_elements(message);
blpapi_Element_print(messageElements, &streamWriter, stdout, 0, 4);
if (BLPAPI_EVENTTYPE_SESSION_STATUS ==
blpapi_Event_eventType(event)
&& 0 == strcmp("SessionTerminated",
blpapi_Message_typeString(message))){
fprintf(stdout,
"Terminating: %s\n",
blpapi_Message_typeString(message));
exit(1);
}
}
blpapi_MessageIterator_destroy(iter);
}
F C Examples
319
int main()
{
blpapi_SessionOptions_t *sessionOptions
blpapi_Session_t
*session
blpapi_CorrelationId_t
subscriptionId;
blpapi_SubscriptionList *subscriptions
const char
*fields[1]
const char
**options
int
updateCount
= 0;
= 0;
=
=
=
=
0;
{"LAST_PRICE"};
0;
0;
sizeof(subscriptionId));
= sizeof(subscriptionId);
= BLPAPI_CORRELATION_TYPE_INT;
= (blpapi_UInt64_t)2;
subscriptions = blpapi_SubscriptionList_create();
assert(subscriptions);
F C Examples
320
blpapi_SubscriptionList_add(subscriptions,
"AAPL US Equity",
&subscriptionId,
fields,
options,
1,
0);
blpapi_Session_subscribe(session,
subscriptions,
0,
0,
0);
while (1) {
blpapi_Event_t *event = 0;
blpapi_Session_nextEvent(session, &event, 0);
assert(event);
switch (blpapi_Event_eventType(event)) {
case BLPAPI_EVENTTYPE_SUBSCRIPTION_DATA:
handleDataEvent(event, updateCount++);
break;
default:
handleOtherEvent(event);
break;
}
blpapi_Event_release(event);
}
return 0;
}
F C Examples
321
F C Examples
322
ALL_PRICE = 90.886000
ALL_PRICE_COND_CODE =
BID_COND_CODE =
ASK_COND_CODE =
LAST_AT_TRADE_TDY = 0.000000
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.000000
HIGH_YLD_TDY = 0.000000
LOW_YLD_TDY = 0.000000
LAST_YLD_TDY = 0.000000
MID_TDY = 0.000000
SIZE_LAST_TRADE_TDY = 1000
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 89.100000
ASK_SIZE_TDY = 5
BID_SIZE_TDY = 7
VOLUME_TDY = 7596090
LAST_PRICE_TDY = 90.886000
BID_TDY = 90.880000
ASK_TDY = 90.910000
HIGH_TDY = 91.640000
LOW_TDY = 88.900000
BID_YLD_TDY = 0.000000
ASK_YLD_TDY = 0.000000
LAST2_PRICE = 90.900000
LAST_DIR = -1
LAST2_DIR = 1
BID_DIR = 1
ASK_DIR = 1
BID2 = 90.880000
ASK2 = 90.910000
SIZE_LAST_TRADE = 1000
ASK_SIZE = 5
BID_SIZE = 7
API_MACHINE = n166
EXCH_CODE_LAST =
EXCH_CODE_BID =
EXCH_CODE_ASK =
TRADE_SIZE_ALL_SESSIONS_RT = 1000
IS_DELAYED_STREAM = false
EID = 14005
PREV_SES_LAST_PRICE = 90.130000
RT_PX_CHG_NET_1D = 0.756000
RT_PX_CHG_PCT_1D = 0.838788
TIME = 16:36:33.000+00:00
LAST_UPDATE_BID_RT = 16:36:35.000+00:00
LAST_UPDATE_ASK_RT = 16:36:32.000+00:00
BID_ASK_TIME = 16:36:35.000+00:00
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
}
F C Examples
323
EventType=8
updateCount = 1
correlationId=1 0 2
messageType
= MarketDataEvents
MarketDataEvents = {
LAST_PRICE = 90.886000
BID = 90.880000
ASK = 90.910000
VOLUME = 7596090
HIGH = 91.640000
LOW = 88.900000
BEST_BID = 90.880000
BEST_ASK = 90.910000
LAST_TRADE = 90.886000
VWAP = 90.644800
LAST_ALL_SESSIONS = 90.886000
BID_ALL_SESSION = 90.880000
ASK_ALL_SESSION = 90.910000
EQY_TURNOVER_REALTIME = 682873786.088959
TOT_CALL_VOLUME_CUR_DAY_RT = 4886
TOT_PUT_VOLUME_CUR_DAY_RT = 3457
TOT_OPT_VOLUME_CUR_DAY_RT = 8343
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 0
IN_AUCTION_RT = false
ALL_PRICE_SIZE = 1000
ALL_PRICE = 90.886000
ALL_PRICE_COND_CODE =
LAST_AT_TRADE_TDY = 0.000000
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.000000
HIGH_YLD_TDY = 0.000000
LOW_YLD_TDY = 0.000000
LAST_YLD_TDY = 0.000000
MID_TDY = 0.000000
SIZE_LAST_TRADE_TDY = 1000
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 89.100000
ASK_SIZE_TDY = 5
BID_SIZE_TDY = 7
VOLUME_TDY = 7596090
LAST_PRICE_TDY = 90.886000
BID_TDY = 90.880000
ASK_TDY = 90.910000
HIGH_TDY = 91.640000
LOW_TDY = 88.900000
BID_YLD_TDY = 0.000000
ASK_YLD_TDY = 0.000000
LAST2_PRICE = 90.900000
LAST_DIR = -1
LAST2_DIR = 1
BID_DIR = 1
ASK_DIR = 1
BID2 = 90.880000
F C Examples
324
ASK2 = 90.910000
SIZE_LAST_TRADE = 1000
ASK_SIZE = 5
BID_SIZE = 7
EXCH_CODE_LAST =
EXCH_CODE_BID =
EXCH_CODE_ASK =
TRADE_SIZE_ALL_SESSIONS_RT = 1000
IS_DELAYED_STREAM = false
EID = 14005
RT_PX_CHG_NET_1D = 0.756000
RT_PX_CHG_PCT_1D = 0.838788
TIME = 16:36:33.000+00:00
LAST_UPDATE_BID_RT = 16:36:35.000+00:00
LAST_UPDATE_ASK_RT = 16:36:32.000+00:00
BID_ASK_TIME = 16:36:35.000+00:00
}
EventType=8
updateCount = 2
correlationId=1 0 2
messageType
= MarketDataEvents
MarketDataEvents = {
LAST2_PRICE = 90.886000
LAST_PRICE = 90.910000
LAST_ALL_SESSIONS = 90.910000
LAST_PRICE_TDY = 90.910000
LAST2_DIR = -1
LAST_DIR = 1
EQY_TURNOVER_REALTIME = 682882877.088959
SIZE_LAST_TRADE = 100
SIZE_LAST_TRADE_TDY = 100
TRADE_SIZE_ALL_SESSIONS_RT = 100
VOLUME = 7596190
VOLUME_TDY = 7596190
LAST_TRADE = 90.910000
ALL_PRICE = 90.910000
ALL_PRICE_SIZE = 100
EID = 14005
RT_PX_CHG_NET_1D = 0.780000
RT_PX_CHG_PCT_1D = 0.865417
IS_DELAYED_STREAM = false
TIME = 16:36:37.000+00:00
EVENT_TIME = 16:36:37.000+00:00
}
F C Examples
325
EventType=8
updateCount = 3
correlationId=1 0 2
messageType
= MarketDataEvents
MarketDataEvents = {
LAST2_PRICE = 90.910000
LAST_PRICE = 90.910000
LAST_ALL_SESSIONS = 90.910000
LAST_PRICE_TDY = 90.910000
LAST2_DIR = 1
EQY_TURNOVER_REALTIME = 682891968.088959
SIZE_LAST_TRADE = 100
SIZE_LAST_TRADE_TDY = 100
TRADE_SIZE_ALL_SESSIONS_RT = 100
VOLUME = 7596290
VOLUME_TDY = 7596290
LAST_TRADE = 90.910000
ALL_PRICE = 90.910000
ALL_PRICE_SIZE = 100
EID = 14005
RT_PX_CHG_NET_1D = 0.780000
RT_PX_CHG_PCT_1D = 0.865417
IS_DELAYED_STREAM = false
TIME = 16:36:37.000+00:00
EVENT_TIME = 16:36:37.000+00:00
}
correlationId=1 0 2
messageType
= MarketDataEvents
MarketDataEvents = {
LAST2_PRICE = 90.910000
LAST_PRICE = 90.910000
LAST_ALL_SESSIONS = 90.910000
LAST_PRICE_TDY = 90.910000
LAST2_DIR = 1
EQY_TURNOVER_REALTIME = 682901059.088959
SIZE_LAST_TRADE = 100
SIZE_LAST_TRADE_TDY = 100
TRADE_SIZE_ALL_SESSIONS_RT = 100
VOLUME = 7596390
VOLUME_TDY = 7596390
LAST_TRADE = 90.910000
ALL_PRICE = 90.910000
ALL_PRICE_SIZE = 100
EID = 14005
RT_PX_CHG_NET_1D = 0.780000
RT_PX_CHG_PCT_1D = 0.865417
IS_DELAYED_STREAM = false
TIME = 16:36:37.000+00:00
EVENT_TIME = 16:36:37.000+00:00
}
F C Examples
326
/* RequestResponseParadigm.c */
#include
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_element.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
#include
#include
#include
#include
#include
<assert.h>
<stdio.h>
<stdlib.h>
<string.h>
<unistd.h>
/* for exit(2) */
/* for strcmp(3C) and memset(3C) */
/* for pause(2) */
F C Examples
327
messageElements = blpapi_Message_elements(message);
assert(messageElements);
blpapi_Element_print(messageElements, &streamWriter, stdout, 0, 4);
}
}
#ifdef __cplusplus
extern "C"
#endif
static void processEvent(blpapi_Event_t
*event,
blpapi_Session_t *session,
void
*userData)
{
assert(event);
assert(session);
switch (blpapi_Event_eventType(event)) {
case BLPAPI_EVENTTYPE_SESSION_STATUS: {
blpapi_MessageIterator_t *iter
= 0;
blpapi_Message_t
*message = 0;
iter = blpapi_MessageIterator_create(event);
assert(iter);
while (0 == blpapi_MessageIterator_next(iter, &message)) {
if (0 == strcmp("SessionStarted",
blpapi_Message_typeString(message))) {
blpapi_CorrelationId_t
correlationId;
F C Examples
328
}
case BLPAPI_EVENTTYPE_SERVICE_STATUS: {
blpapi_MessageIterator_t *iter
= 0;
blpapi_Message_t
*message
= 0;
blpapi_Service_t
*refDataSvc = 0;
blpapi_CorrelationId_t
correlationId;
iter = blpapi_MessageIterator_create(event);
assert(iter);
while (0 == blpapi_MessageIterator_next(iter, &message)) {
assert(message);
correlationId = blpapi_Message_correlationId(message, 0);
if (correlationId.value.intValue == (blpapi_UInt64_t)99
&& 0 == strcmp("ServiceOpened",
blpapi_Message_typeString(message))) {
blpapi_Request_t *request
= 0;
blpapi_Element_t *elements
= 0;
blpapi_Element_t *securitiesElements = 0;
blpapi_Element_t *fieldsElements
= 0;
/* Construct and issue a Request */
blpapi_Session_getService(session,
&refDataSvc,
"//blp/refdata");
blpapi_Service_createRequest(refDataSvc,
&request,
"ReferenceDataRequest");
assert(request);
elements = blpapi_Request_elements(request);
assert(elements);
blpapi_Element_getElement(elements,
&securitiesElements,
"securities",
0);
assert(securitiesElements);
blpapi_Element_setValueString(securitiesElements,
"IBM US Equity",
BLPAPI_ELEMENT_INDEX_END);
blpapi_Element_getElement(elements,
&fieldsElements,
"fields",
0);
blpapi_Element_setValueString(fieldsElements,
"PX_LAST",
BLPAPI_ELEMENT_INDEX_END);
F C Examples
329
F C Examples
330
int main()
{
blpapi_SessionOptions_t *sessionOptions
blpapi_Session_t
*session
= 0;
= 0;
sessionOptions = blpapi_SessionOptions_create();
assert(sessionOptions);
blpapi_SessionOptions_setServerHost(sessionOptions, "localhost");
blpapi_SessionOptions_setServerPort(sessionOptions, "8194");
session = blpapi_Session_create(sessionOptions, &processEvent, 0, 0);
assert(session);
blpapi_SessionOptions_destroy(sessionOptions);
if (0 != blpapi_Session_start(session)) {
fprintf(stderr, "Failed to start async session.\n");
blpapi_Session_destroy(session);
return 1;
}
pause();
blpapi_Session_destroy(session);
return 0;
}
F C Examples
331
/* RequestResponseParadigm.c */
#include
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_element.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
/* for strcmp(3C) */
F C Examples
332
= 0;
= 0;
= 0;
= 0;
= -1;
blpapi_Element_getValueAsElement(securityDataArray,
&securityData,
i);
assert(securityData);
blpapi_Element_getElement(securityData,
&securityElement,
"security",
0);
assert(securityElement);
blpapi_Element_getValueAsString(securityElement,
&security,
0);
assert(security);
blpapi_Element_getElement(securityData,
&sequenceNumberElement,
"sequenceNumber",
0);
assert(sequenceNumberElement);
blpapi_Element_getValueAsInt32(sequenceNumberElement,
&sequenceNumber,
0);
F C Examples
333
if (blpapi_Element_hasElement(securityData, "securityError",
0)){
blpapi_Element_t *securityErrorElement = 0;
printf("*security
=%s\n", security);
blpapi_Element_getElement(securityData,
&securityErrorElement,
"securityError",
0);
assert(securityErrorElement);
blpapi_Element_print(securityErrorElement,
&streamWriter,
stdout,
0,
4);
return;
} else {
blpapi_Element_t
*fieldDataElement = 0;
blpapi_Element_t
*PX_LAST_Element = 0;
blpapi_Element_t
*DS002_Element = 0;
blpapi_Element_t *VWAP_VOLUME_Element = 0;
double
px_last
= (double)777;
const char *ds002
= 0;
double
vwap_volume = (double)666;
blpapi_Element_getElement(securityData,
&fieldDataElement,
"fieldData",
0);
assert(fieldDataElement);
blpapi_Element_getElement(fieldDataElement,
&PX_LAST_Element,
"PX_LAST",
0);
assert(PX_LAST_Element);
blpapi_Element_getValueAsFloat64(PX_LAST_Element,
&px_last,
0);
blpapi_Element_getElement(fieldDataElement,
&DS002_Element,
"DS002",
0);
assert(DS002_Element);
blpapi_Element_getValueAsString(DS002_Element,
&ds002,
0);
F C Examples
334
blpapi_Element_getElement(fieldDataElement,
&VWAP_VOLUME_Element,
"VWAP_VOLUME",
0);
assert(VWAP_VOLUME_Element);
blpapi_Element_getValueAsFloat64(VWAP_VOLUME_Element,
&vwap_volume,
0);
printf("*security
=%s\n",
printf("*sequenceNumber=%d\n",
printf("*px_last
=%f\n",
printf("*ds002
=%s\n",
printf("*vwap_volume
=%f\n",
printf("\n");
security);
sequenceNumber);
px_last);
ds002);
vwap_volume);
}
}
}
blpapi_MessageIterator_destroy(iter);
}
static void handleOtherEvent(const blpapi_Event_t *event)
{
blpapi_MessageIterator_t *iter
= 0;
blpapi_Message_t
*message = 0;
assert(event);
printf("EventType=%d\n", blpapi_Event_eventType(event));
iter = blpapi_MessageIterator_create(event);
assert(iter);
while (0 == blpapi_MessageIterator_next(iter, &message)) {
blpapi_CorrelationId_t correlationId;
blpapi_Element_t
*messageElements = 0;
assert(message);
correlationId = blpapi_Message_correlationId(message, 0);
printf("correlationId=%d %d %lld\n",
correlationId.valueType,
correlationId.classId,
correlationId.value.intValue);
printf("messageType=%s\n", blpapi_Message_typeString(message));
messageElements = blpapi_Message_elements(message);
assert(messageElements);
blpapi_Element_print(messageElements, &streamWriter, stdout, 0, 4);
F C Examples
335
if (BLPAPI_EVENTTYPE_SESSION_STATUS ==
blpapi_Event_eventType(event)
&& 0 == strcmp("SessionTerminated",
blpapi_Message_typeString(message))){
fprintf(stdout,
"Terminating: %s\n",
blpapi_Message_typeString(message));
exit(1);
}
}
blpapi_MessageIterator_destroy(iter);
}
int main()
{
blpapi_SessionOptions_t
blpapi_Session_t
blpapi_CorrelationId_t
blpapi_Service_t
blpapi_Request_t
blpapi_Element_t
blpapi_Element_t
blpapi_Element_t
blpapi_CorrelationId_t
int
*sessionOptions
*session
requestId;
*refDataSvc
*request
*elements
*securitiesElements
*fieldsElements
correlationId;
continueToLoop
= 0;
= 0;
=
=
=
=
=
0;
0;
0;
0;
0;
= 1;
sessionOptions = blpapi_SessionOptions_create();
assert(sessionOptions);
blpapi_SessionOptions_setServerHost(sessionOptions, "localhost");
blpapi_SessionOptions_setServerPort(sessionOptions, "8194");
session = blpapi_Session_create(sessionOptions, 0, 0, 0);
assert(session);
blpapi_SessionOptions_destroy(sessionOptions);
if (0 != blpapi_Session_start(session)) {
fprintf(stderr, "Failed to start session.\n");
blpapi_Session_destroy(session);
return 1;
}
if (0 != blpapi_Session_openService(session,"//blp/refdata")){
fprintf(stderr, "Failed to open service //blp/refdata.\n");
blpapi_Session_destroy(session);
return 1;
}
F C Examples
336
memset(&requestId, '\0',
requestId.size
requestId.valueType
requestId.value.intValue
sizeof(requestId));
= sizeof(requestId);
= BLPAPI_CORRELATION_TYPE_INT;
= (blpapi_UInt64_t)1;
sizeof(correlationId));
= sizeof(correlationId);
= BLPAPI_CORRELATION_TYPE_INT;
= (blpapi_UInt64_t)1;
F C Examples
337
while (continueToLoop) {
blpapi_Event_t *event = 0;
blpapi_Session_nextEvent(session, &event, 0);
assert(event);
switch (blpapi_Event_eventType(event)) {
case BLPAPI_EVENTTYPE_RESPONSE: /* final event */
continueToLoop = 0;
/* fall through */
case BLPAPI_EVENTTYPE_PARTIAL_RESPONSE:
handleResponseEvent(event);
break;
default:
handleOtherEvent(event);
break;
}
blpapi_Event_release(event);
}
blpapi_Session_stop(session);
blpapi_Request_destroy(request);
blpapi_Session_destroy(session);
return 0;
}
F C Examples
338
F C Examples
339
/* SubscriptionMultiple.c */
#include
#include
#include
#include
#include
#include
#include
<blpapi_correlationid.h>
<blpapi_element.h>
<blpapi_event.h>
<blpapi_message.h>
<blpapi_request.h>
<blpapi_session.h>
<blpapi_subscriptionlist.h>
#include
#include
#include
#include
<assert.h>
<stdio.h>
<string.h>
<unistd.h>
/* for memset(3C) */
/* for pause(2)
*/
F C Examples
340
F C Examples
341
F C Examples
=
=
=
=
"/ticket/GOOG US Equity";
{ "BID", "ASK", "LAST_TRADE" };
0;
sizeof(fields_GOOG)/
= 0;
342
/* MSFT */
const char
*topic_MSFT
const char
*fields_MSFT[]
const char
*options_MSFT[]
int
numFields_MSFT
sizeof(*fields_MSFT);
int
numOptions_MSFT
sizeof(*options_MSFT);
=
=
=
=
= sizeof(options_MSFT)/
/* CUSIP 097023105 */
const char
*topic_097023105 =
"/cusip/
097023105?fields=LAST_PRICE&interval=5.0";
const char
**fields_097023105 = 0;
const char **options_097023105 = 0;
int
numFields_097023105 = 0;
int
numOptions_097023105 = 0;
setbuf(stdout, 0); /* DO NOT SHOW */
blpapi_CorrelationId_t
blpapi_CorrelationId_t
blpapi_CorrelationId_t
blpapi_CorrelationId_t
subscriptionId_IBM;
subscriptionId_GOOG;
subscriptionId_MSFT;
subscriptionId_097023105;
memset(&subscriptionId_IBM, '\0',
subscriptionId_IBM.size
subscriptionId_IBM.valueType
subscriptionId_IBM.value.intValue
sizeof(subscriptionId_IBM));
= sizeof(subscriptionId_IBM);
= BLPAPI_CORRELATION_TYPE_INT;
= (blpapi_UInt64_t)10;
memset(&subscriptionId_GOOG, '\0',
subscriptionId_GOOG.size
subscriptionId_GOOG.valueType
subscriptionId_GOOG.value.intValue
sizeof(subscriptionId_GOOG));
= sizeof(subscriptionId_GOOG);
= BLPAPI_CORRELATION_TYPE_INT;
= (blpapi_UInt64_t)20;
memset(&subscriptionId_MSFT, '\0',
subscriptionId_MSFT.size
subscriptionId_MSFT.valueType
subscriptionId_MSFT.value.intValue
sizeof(subscriptionId_MSFT));
= sizeof(subscriptionId_MSFT);
= BLPAPI_CORRELATION_TYPE_INT;
= (blpapi_UInt64_t)30;
memset(&subscriptionId_097023105,
'\0',
sizeof(subscriptionId_097023105));
subscriptionId_097023105.size
=
sizeof(subscriptionId_097023105);
subscriptionId_097023105.valueType
= BLPAPI_CORRELATION_TYPE_INT;
subscriptionId_097023105.value.intValue = (blpapi_UInt64_t)40;
sessionOptions = blpapi_SessionOptions_create();
assert(sessionOptions);
blpapi_SessionOptions_setServerHost(sessionOptions, "localhost");
blpapi_SessionOptions_setServerPort(sessionOptions, "8194");
F C Examples
343
session = blpapi_Session_create(sessionOptions,
&processEvent,
0,
&userData);
assert(session);
blpapi_SessionOptions_destroy(sessionOptions);
if (0 != blpapi_Session_start(session)) {
fprintf(stderr, "Failed to start session.\n");
blpapi_Session_destroy(session);
return 1;
}
if (0 != blpapi_Session_openService(session,"//blp/mktdata")){
fprintf(stderr, "Failed to open service //blp/mktdata.\n");
blpapi_Session_destroy(session);
return 1;
}
blpapi_SubscriptionList_t *subscriptions =
blpapi_SubscriptionList_create();
blpapi_SubscriptionList_add(subscriptions,
topic_IBM,
&subscriptionId_IBM,
fields_IBM,
options_IBM,
numFields_IBM,
numOptions_IBM);
blpapi_SubscriptionList_add(subscriptions,
topic_GOOG,
&subscriptionId_GOOG,
fields_GOOG,
options_GOOG,
numFields_GOOG,
numOptions_GOOG);
blpapi_SubscriptionList_add(subscriptions,
topic_MSFT,
&subscriptionId_MSFT,
fields_MSFT,
options_MSFT,
numFields_MSFT,
numOptions_MSFT);
blpapi_SubscriptionList_add(subscriptions,
topic_097023105,
&subscriptionId_097023105,
fields_097023105,
options_097023105,
numFields_097023105,
numOptions_097023105);
F C Examples
344
F C Examples
345
F C Examples
346
}
handleStatusEventHandler: leave
handleDataEventHandler: enter
handler label=myLabel
eventType=8
messageType=MarketDataEvents
correlationId=1 0 10
MarketDataEvents = {
LAST_PRICE = 92.410000
BID = 92.360000
ASK = 92.390000
VOLUME = 11337256
HIGH = 93.200000
LOW = 91.220000
BEST_BID = 92.360000
BEST_ASK = 92.390000
LAST_TRADE = 92.410000
OPEN = 92.130000
IMBALANCE_BID = 92.390000
IMBALANCE_ASK =
ORDER_IMB_BUY_VOLUME = 44300.000000
ORDER_IMB_SELL_VOLUME =
VWAP = 92.213100
THEO_PRICE = 0.000000
LAST_ALL_SESSIONS = 92.410000
IMBALANCE_INDIC_RT = BUY
BID_ALL_SESSION = 92.030000
ASK_ALL_SESSION = 92.370000
TRADING_DT_REALTIME = 2009-02-05
EQY_TURNOVER_REALTIME = 1042895294.262009
NYSE_LRP_HIGH_PRICE_RT = 93.360000
NYSE_LRP_LOW_PRICE_RT = 91.360000
TOT_CALL_VOLUME_CUR_DAY_RT = 5625
TOT_PUT_VOLUME_CUR_DAY_RT = 2314
TOT_OPT_VOLUME_CUR_DAY_RT = 7939
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 0
IN_AUCTION_RT = false
RT_API_MACHINE = p142
ALL_PRICE_SIZE = 1200
ALL_PRICE = 92.379200
ALL_PRICE_COND_CODE =
BID_COND_CODE =
ASK_COND_CODE =
VOLUME_THEO = 0
LAST_AT_TRADE_TDY = 0.000000
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.000000
HIGH_YLD_TDY = 0.000000
LOW_YLD_TDY = 0.000000
LAST_YLD_TDY = 0.000000
MID_TDY = 0.000000
SIZE_LAST_TRADE_TDY = 579500
IND_BID_FLAG = false
F C Examples
347
IND_ASK_FLAG = false
OPEN_TDY = 92.130000
ASK_SIZE_TDY = 79
BID_SIZE_TDY = 5
VOLUME_TDY = 11337256
LAST_PRICE_TDY = 92.410000
BID_TDY = 92.360000
ASK_TDY = 92.390000
HIGH_TDY = 93.200000
LOW_TDY = 91.220000
BID_YLD_TDY = 0.000000
ASK_YLD_TDY = 0.000000
LAST2_PRICE = 92.410000
LAST_DIR = 1
LAST2_DIR = 1
BID_DIR = 1
ASK_DIR = 1
BID2 = 92.360000
ASK2 = 92.390000
SIZE_LAST_TRADE = 579500
ASK_SIZE = 79
BID_SIZE = 5
API_MACHINE = p142
EXCH_CODE_LAST =
EXCH_CODE_BID =
EXCH_CODE_ASK =
TRADE_SIZE_ALL_SESSIONS_RT = 579500
IS_DELAYED_STREAM = false
EID = 14003
PREV_SES_LAST_PRICE = 92.780000
RT_PX_CHG_NET_1D = -0.369900
RT_PX_CHG_PCT_1D = -0.398684
TIME = 21:00:27.000+00:00
LAST_UPDATE_BID_RT = 21:00:22.000+00:00
LAST_UPDATE_ASK_RT = 21:00:22.000+00:00
NYSE_LRP_SEND_TIME_RT = 20:59:57.000+00:00
BID_ASK_TIME = 21:00:22.000+00:00
SES_START = 14:30:00.000+00:00
SES_END = 21:30:00.000+00:00
}
handleDataEventHandler: leave
handleDataEventHandler: enter
handler label=myLabel
eventType=8
messageType=MarketDataEvents
correlationId=1 0 10
MarketDataEvents = {
LAST_PRICE = 92.410000
BID = 92.360000
ASK = 92.390000
VOLUME = 11337256
BEST_BID = 92.360000
BEST_ASK = 92.390000
F C Examples
348
LAST_TRADE = 92.410000
IMBALANCE_BID = 92.390000
IMBALANCE_ASK =
ORDER_IMB_BUY_VOLUME = 44300.000000
ORDER_IMB_SELL_VOLUME =
VWAP = 92.251200
THEO_PRICE = 92.390000
LAST_ALL_SESSIONS = 92.410000
IMBALANCE_INDIC_RT = BUY
BID_ALL_SESSION = 92.030000
ASK_ALL_SESSION = 92.370000
EQY_TURNOVER_REALTIME = 1042895294.262009
NYSE_LRP_HIGH_PRICE_RT = 93.360000
NYSE_LRP_LOW_PRICE_RT = 91.360000
TOT_CALL_VOLUME_CUR_DAY_RT = 5625
TOT_PUT_VOLUME_CUR_DAY_RT = 2314
TOT_OPT_VOLUME_CUR_DAY_RT = 7939
PUT_CALL_VOLUME_RATIO_CUR_DAY_RT = 0
IN_AUCTION_RT = false
ALL_PRICE_SIZE = 1200
ALL_PRICE = 92.379200
ALL_PRICE_COND_CODE =
VOLUME_THEO = 545600
LAST_AT_TRADE_TDY = 0.000000
SIZE_LAST_AT_TRADE_TDY = 0
OPEN_YLD_TDY = 0.000000
HIGH_YLD_TDY = 0.000000
LOW_YLD_TDY = 0.000000
LAST_YLD_TDY = 0.000000
MID_TDY = 0.000000
SIZE_LAST_TRADE_TDY = 579500
IND_BID_FLAG = false
IND_ASK_FLAG = false
OPEN_TDY = 92.130000
ASK_SIZE_TDY = 79
BID_SIZE_TDY = 5
VOLUME_TDY = 11337256
LAST_PRICE_TDY = 92.410000
BID_TDY = 92.360000
ASK_TDY = 92.390000
HIGH_TDY = 93.200000
LOW_TDY = 91.220000
BID_YLD_TDY = 0.000000
ASK_YLD_TDY = 0.000000
LAST2_PRICE = 92.410000
LAST_DIR = 1
LAST2_DIR = 1
BID_DIR = 1
ASK_DIR = 1
BID2 = 92.360000
ASK2 = 92.390000
SIZE_LAST_TRADE = 579500
ASK_SIZE = 79
F C Examples
349
BID_SIZE = 5
EXCH_CODE_LAST =
EXCH_CODE_BID =
EXCH_CODE_ASK =
TRADE_SIZE_ALL_SESSIONS_RT = 579500
IS_DELAYED_STREAM = false
EID = 14003
RT_PX_CHG_NET_1D = -0.369900
RT_PX_CHG_PCT_1D = -0.398684
TIME = 21:00:27.000+00:00
LAST_UPDATE_BID_RT = 21:00:22.000+00:00
LAST_UPDATE_ASK_RT = 21:00:22.000+00:00
NYSE_LRP_SEND_TIME_RT = 20:59:57.000+00:00
BID_ASK_TIME = 21:00:22.000+00:00
}