assylias / jbloomberg Goto Github PK
View Code? Open in Web Editor NEWjBloomberg is a high-level API that wraps the low level Bloomberg Java API.
License: Apache License 2.0
jBloomberg is a high-level API that wraps the low level Bloomberg Java API.
License: Apache License 2.0
These fields should be used as a fallback when ASK/BID are blank
Apparently the quality of this field may vary by exchange, so we should also expose PRIMARY_EXCHANGE_MIC_RT
The dependency is only used to import TypedObject
.
Add a method in TypedObject
to cast the results as generic types, e.g. List<String>
.
Example:
2017-11-17 11:07:37,607 INFO [Bloomberg EDT #1] [SubscriptionManager.java:112] Subscription error [EURNOK Curncy]: SubscriptionStarted = {
exceptions[] = {
}
}
Hi Assylias
First of all, thanks for you work I use your library every day since few years and it was very helpful for my work.
I think Bloomberg made an update on the time zone in the date format and this create a runtime time exception on line 35 of com.assylias.jbloomberg.HistoricalResultParser.
May I suggest you a modification like
final LocalDate date = parseLocalDate(firstField.getValueAsString().substring(0,10));
instead of
final LocalDate date = parseLocalDate(firstField.getValueAsString());
If you think it is a bad idea no problem, I have rebuilt your lib with this correction and it’s work for me.
Thanks again for your work
Kinds regards
Alx
On several tickers, this exception is received when subscribing to real time fields.
Allow creation of an Identity and for it to be passed around for use with the underlying Session object as per section 3 of the Enterprise Developer Guide and GenerateTokenExample.java
Bloomberg exposes new RealtimeFields which are not available through jBloomberg.
If a new realtime field is exposed by the Bloomberg API, it can't be access until the RealtimeField enum is updated.
Allow to pass a realtime field as a string to the SubscriptionBuilder
.
First off, great work on with your library! This is exactly what I had hoped to do!
I was wondering if you thought it would make sense to add EMSX functionality to this library, or whether you thought it was outside of the scope. I currently want to add these request types and didn't know if it made sense to merge it upstream.
/*
* Copyright (C) 2012 - present by Yann Le Tallec.
* Please see distribution for license.
*/
package com.assylias.jbloomberg;
/**
* The names internally used by Bloomberg to identify the various types of requests - users don't need to use these
* values directly.
*/
public enum BloombergRequestType {
HISTORICAL_DATA("HistoricalDataRequest"),
INTRADAY_TICK("IntradayTickRequest"),
INTRADAY_BAR("IntradayBarRequest"),
REFERENCE_DATA("ReferenceDataRequest"),
PORTFOLIO_DATA("PortfolioDataRequest"),
EXCELGETGRIDREQUEST_DATA("ExcelGetGridRequest"),
INSTRUMENT_LIST("instrumentListRequest"),
/**
* EMSX Related Requests
* @see <a href="https://emsx-api-doc.readthedocs.io/en/latest/programmable/description.html">https://emsx-api-doc.readthedocs.io/en/latest/programmable/description.html</a>
*/
/**
* Assign an order to another UUID.
*/
ASSIGN_TRADER("AssignTrader"),
/**
* Cancel outstanding routes (placements).
*/
CANCEL_ROUTE_EX("CancelRouteEx"),
/**
* Create an order or stage an order into EMSX<GO>.
*/
CREATE_ORDER("CreateOrder"),
/**
* Create a new order and route in a single request.
*/
CREATE_ORDER_AND_ROUTE_EX("CreateOrderAndRouteEx"),
/**
* Create the order and notify EMSX this is routed.
*/
CREATE_ORDER_AND_ROUTE_MANUALLY("CreateOrderAndRouteManually"),
/**
* Delete an existing order in EMSX<GO>.
*/
DELETE_ORDER("DeleteOrder"),
/**
* Get all field meta data in a response message.
*/
GET_ALL_FIELD_META_DATA("GetAllFieldMetaData"),
/**
* Get all broker strategy information and asset class data.
*/
GET_BROKER_STRATEGIES_WITH_ASSET_CLASS("GetBrokerStrategiesWithAssetClass"),
/**
* Get all broker strategy info and asset class data.
*/
GET_BROKER_STRATEGY_INFO_WITH_ASSET_CLASS("GetBrokerStrategyInfoWithAssetClass"),
/**
* Get all broker data with asset class in a response message.
*/
GET_BROKER_WITH_ASSET_CLASS("GetBrokerWithAssetClass"),
/**
* Get field meta data in a reponse message.
*/
GET_FIELD_META_DATA("GetFieldMetaData"),
/**
* Get team data in a response message.
*/
GET_TEAMS("GetTeams"),
/**
* Submit the entire list as a single route to a basket algorithm.
*/
GROUP_ROUTE_EX("GroupRouteEx"),
/**
* Modify parent order.
*/
MODIFY_ORDER("ModifyOrder"),
/**
* Modify child route.
*/
MODIFY_ROUTE_EX("ModifyRouteEx"),
/**
* Route existing order.
*/
ROUTE_EX("RouteEx"),
/**
* Route manually and notify EMSX that it is routed.
*/
ROUTE_MANUALLY_EX("RouteManuallyEx");
private final String requestName;
BloombergRequestType(String requestName) {
this.requestName = requestName;
}
/**
* @return the type of request, for example "HistoricalDataRequest"
*/
@Override
public String toString() {
return requestName;
}
}
Some constructors take a Collection and some take a List.
The following realtime fields are not currently available for subscription
When retrieving bulk data an exception is thrown:
Caused by: com.bloomberglp.blpapi.InvalidConversionException: Cannot convert SEQUENCE to String
at com.bloomberglp.blpapi.impl.cU.ax(ElementImpl.java:408)
at com.bloomberglp.blpapi.impl.cU.getValueAsString(ElementImpl.java:360)
at com.bloomberglp.blpapi.impl.cU.getValueAsString(ElementImpl.java:352)
at assylias.jbloomberg.BloombergUtils.getSpecificObjectOf(BloombergUtils.java:61)
Test:
RequestBuilder request = new ReferenceRequestBuilder("IBM US Equity", "TOP_20_HOLDERS_PUBLIC_FILINGS");
session.submit(request);
Given that Bloomberg's Java package is com.bloomberglp.blpapi is there a reason you have chosen to use com.bloombergblp as the groupId?
bbcomm.exe
can be located in C:/blp/DAPI
instead of C:/blp/API
.
testParse_NoTickerErrorResponse
sometimes fails with a timeout
Bloomberg has an API to query portfolio created with PRTU.
By default timestamps reflect the users preference set in TZDF
, adding the "useGMT" option forces timestamps to be returned in UTC consistently across users and locations.
In order to do this the CorrelationId will need to be exposed when creating a subscription, which can then be passed to Session#cancel
Currently you can only check if a session is live by submitting a request and catching an exception.
It would be nice to be able to have a defined set of states that the session is going through and a way to register a callback on session startup which would get called with the state changes.
We could start with the two main states: Started
and Stopped
.
What do you think?
testConcurrent
fails when run in parallel because other threads may be adding new keys too.
Hi Yann,
test_IntradayTickExample => Doesn't work during Asian hours
Example fix: Replace "now.minusHours(2)" by "now.minusHours(23)"
Thanks
In order to ensure that your application is processing event messages fast enough and not losing data, you will want to handle all "ADMIN" event messages. We demonstrate how to handle this event type in the "SubscriptionWithEventHandlerExample" SDK example.
If your application is not reading/processing the incoming events fast enough, the internal queue of the API library will begin queuing up all event messages. When this occurs, you will receive an event of EventType ADMIN containing a message of type SlowConsumerWarning. This message will be sent once the number of undelivered events sent to the user(s) reaches the high percentage threshold set with the SessionOptions.SlowConsumerWarningHiWaterMark property (default: 0.75). This percentage is based on the maximum event queue size, which is set with the SessionOptions.MaxEventQueueSize property (default: 10000). At this point, no data has been lost, but you are in danger of doing so if appropriate action isn't taken. Ideally, this action would be to optimize your processing of event messages or reducing your data requests/subscriptions. but you could also try increasing the maximum event size by setting the MaxEventQueueSize property value.
If you receive a SlowConsumerWarningCleared message, then you have dropped below the low percentage threshold, which is set using the SessionOptions.SlowConsumerWarningLoWaterMark (default: 0.5).
If the number of events outstanding for delivery exceeds the specified threshold controlled by SessionOptions.MaxEventQueueSize, then the Bloomberg communication server (i.e. bbcomm, serverapi, etc.) will begin dropping events, as the API library's internal queue will be full and no longer able to receive any further messages until the situation is addressed. This will be indicated by a "DataLoss" message contained in an ADMIN event.
Within this message, you will find an "id", "source" and "numMessagesDropped" property value. The "id" property identifies the affected subscription, while the "source" will have a value of "InProc", which means that it occurred within your application (currently, this is the only possible source). The final property is "numMessagesDropped", which indicates the total number of messages dropped at the time the dataloss message was received for that particular subscription. It is important to note that the subscription, identified by "id", will not be automatically canceled by the API library.
IMPORTANT NOTES:
The above information only applies to API library versions 3.5.2.1, and greater. If you are using earlier versions of the API libraries, it is advised that you upgrade in order to ensure you are using the latest supported versions and taking advantage of new features and bug fixes. In earlier C++ API library versions, for example, you will not receive any DataLoss or SlowConsumerWarning/SlowConsumerWarningCleared Admin event messages, while for earlier Java and .NET API libraries, only SlowConsumerWarning/SlowConsumerWarningCleared Admin messages will be returned, but no DataLoss Admin messages.
Hi Assylias,
Fisrt of all thanks for your work,
I would like to use your library but i don't manage to get an example
My use case get is to get a response matrix (or guava table) with a list of ticker and a list of bloomberg field
Do you have an example to do this using you library?
Thanks a lot by advance
Kinds regard
oskar
PS: all is ok in my side about setup (bbg.jar and your library)
For example: 24:00:00 which should be parsed as 00:00:00
One possible use case is to create a RequestBuilder and share it accross threads. They should be made thread safe.
Hi,
Would it be possible to push the latest version into Maven repo? It looks like some features in source code are not available in 3.3 (custom session options).
Regards,
Lukasz
Currently DefaultBloombergSession
holds a static SessionOptions
object which cannot be customized by the user. I guess that's why the implementation is called 'Default'. However, it seems strange that the only other option a user has is to create (or copy) a whole new implementation of the BloombergSession
interface in order to set a different server port.
What is the reason behind this and would you accept adding another constructor to DefaultBloombergSession
with an ability to override the SessionOptions
?
If I want to mock out a BloombergSession to simulate subscription I need to access package-private properties - it would be helpful to make them public.
I started jBloomberg for some bloomberg work and its been great. The one functionality that I dont think I was able to do was being able to run the bloomberg SRCH data queries. Here's an example in python on how it is implemented: It needs to use the ExcelGetGridRequest service functionality via the API unfortunately.
https://github.com/matthewgilbert/pdblp/blob/master/pdblp/pdblp.py
def bsrch(self, domain):
"""This function uses the Bloomberg API to retrieve 'bsrch'
(Bloomberg SRCH Data) queries. Returns list of tickers.
Parameters
----------
domain: string
A character string with the name of the domain to execute.
It can be a user defined SRCH screen, commodity screen or
one of the variety of Bloomberg examples. All domains are in the format
:<search_name>. Example "COMDTY:NGFLOW"
Returns
-------
data: pandas.DataFrame
List of bloomberg tickers from the BSRCH
"""
logger = _get_logger(self.debug)
request = self.exrService.createRequest("ExcelGetGridRequest")
request.set("Domain", domain)
self.session.sendRequest(request)
data = []
# Process received events
while True:
event = self.session.nextEvent(self.timeout)
if event.eventType() == blpapi.Event.RESPONSE or
event.eventType() == blpapi.Event.PARTIAL_RESPONSE:
for msg in event:
logger.info(msg)
for v in msg.getElement("DataRecords").values():
for f in v.getElement("DataFields").values():
data.append(f.getElementAsString("StringValue"))
if event.eventType() == blpapi.Event.RESPONSE:
break
return pd.DataFrame(data)
Hi assylias,
I downloaded your project from here, and I'm trying to import it to Eclipse as a Java project. However, Eclipse says that "No projects are found to import." Can you please help me out?
Thank you so much in advance!
If the session can't be open, submit hangs forever instead of throwing an exception.
Typical log output:
2013-09-23 19:29:36,742 INFO [AWT-EventQueue-0] [BloombergUtils.java:107] bbcomm.exe is started
2013-09-23 19:29:36,744 INFO [AWT-EventQueue-0] [DefaultBloombergSession.java:106] Starting Bloomberg session #1 with options: {AllowMultipleCorrelatorsPerMsg=false, AutoRestartOnDisconnection=false, ClientMode=AUTO, ConnectTimeout=5000, DefaultKeepAliveInactivityTime=20000, DefaultKeepAliveResponseTimeout=5000, DefaultServices=[Ljava.lang.String;@79402611, DefaultSubscriptionService=//blp/mktdata, DefaultTopicPrefix=ticker/, MaxEventQueueSize=10000, MaxOutstandingRequests=128, MaxPendingRequests=1024, MaxSendCacheSize=134217728, ServerAddresses=[Lcom.bloomberglp.blpapi.SessionOptions$ServerAddress;@d0012ae, ServerHost=127.0.0.1, ServerPort=8194, SlowConsumerWarningHiWaterMark=0.75, SlowConsumerWarningLoWaterMark=0.5}
2013-09-23 19:29:36,755 INFO [AWT-EventQueue-0] [DefaultBloombergSession.java:117] Session #1 started asynchronously
2013-09-23 19:29:36,793 DEBUG [Thread-4] [BloombergEventHandler.java:46] [SESSION_STATUS] SessionConnectionUp = {
server = "/127.0.0.1:8194"
}
2013-09-23 19:29:44,812 DEBUG [SwingWorker-pool-1-thread-1] [BloombergCharts.java:156] Retrieving security name for SX5E Index
2013-09-23 19:29:44,813 DEBUG [SwingWorker-pool-1-thread-1] [DefaultBloombergSession.java:174] Submitting request com.assylias.jbloomberg.ReferenceRequestBuilder@7692d86e
2013-09-23 19:29:44,815 DEBUG [Bloomberg Session # 1 - 1] [DefaultBloombergSession.java:225] Waiting for session to start while opening service REFERENCE_DATA
2013-09-23 19:30:36,812 DEBUG [Thread-4] [BloombergEventHandler.java:46] [SESSION_STATUS] SessionStartupFailure = {
reason = {
}
}
From section 5.9 of the Core Developer Guide:
The Market List Service (//blp/mktlist) is used to perform two types of list data operations. The first is to subscribe to of instruments, known as “chains,” using the “chain” (i.e., //blp/mktlist/chain). The second is to a list of all the instruments that match a given topic key using the “secids” (i.e., /mktlist/secids). The //blp/mktlist service is available to both BPS (Bloomberg Professional service) and NONBPS .
When subscribing twice to an expired security (e.g. VGZ14 Index
), the following exception is thrown:
com.bloomberglp.blpapi.NotFoundException: CorrelationID: Internal: 3 not found
This is because the SubscriptionManager tries to resubscribe to the security but the initial subscription was declined.
Hi assylias,
I m not a Java expert and a bit stuck. I like you library a lot but can not use it so far.
The error i get is:
Usage: java org.joda.time.tz.ZoneInfoCompiler
Do you have any suggestions?
Kind regards
Fons
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.