I'm using Bloomberg Java api to download trading data. I need somebody to tell me if there exists a function which can return a list of trading holidays. I looked through the manual but couldn't find one. If there's no such a thing, is there a good way that I can create one? Thanks.
String field = "CALENDAR_HOLIDAYS";
//String field = "CALENDAR_NON_SETTLEMENT_DATES";
Request request = this._refDataServiceM.CreateRequest("ReferenceDataRequest");
Element securities = request.GetElement("securities");
securities.AppendValue("AAPL US Equity");
Element fields = request.GetElement("fields");
fields.AppendValue(field);
Element overridefields = request.GetElement("overrides");
Element overrides = request.GetElement("overrides");
Element override1 = overrides.AppendElement();
override1.SetElement("fieldId", "SETTLEMENT_CALENDAR_CODE");
override1.SetElement("value", calendar_code);
Element override2 = overrides.AppendElement();
override2.SetElement("fieldId", "CALENDAR_START_DATE");
override2.SetElement("value", startDate.ToString("yyyyMMdd"));
Element override3 = overrides.AppendElement();
override3.SetElement("fieldId", "CALENDAR_END_DATE");
override3.SetElement("value", endDate.ToString("yyyyMMdd"));
The Bloomberg API will tell you, for a given security, the appropriate calendar code using DS853 (CALENDAR_CODE). Given a calendar code, I do not believe that Bloomberg provides a way to download a holiday calendar. You may need to use a third party vendor such as Financial Calendar.
The Python implementation is as follows. Note that we are using calendar "AM" for Amsterdam, marking the second day of easter as a national holiday.
refDataService = session.getService("//blp/refdata")
request = refDataService.createRequest("ReferenceDataRequest")
request.append("securities", "AAPL US Equity")
request.append("fields", "CALENDAR_HOLIDAYS")
overrides = request.getElement("overrides")
override2 = overrides.appendElement()
override2.setElement("fieldId", "CALENDAR_START_DATE")
override2.setElement("value", "20200101")
override3 = overrides.appendElement()
override3.setElement("fieldId", "CALENDAR_END_DATE")
override3.setElement("value", "20210501")
override4 = overrides.appendElement()
override4.setElement("fieldId", "SETTLEMENT_CALENDAR_CODE")
override4.setElement("value", "AM")
session.sendRequest(request)
I had issues getting the accepted answer to work. Turned out the SETTLEMENT_CALENDAR_CODE isn't needed. The following worked:
{
securities[] = {
/bbgid/BBG00HZZLBT7
}
fields[] = {
CALENDAR_NON_SETTLEMENT_DATES
}
overrides[] = {
overrides = {
fieldId = "CALENDAR_START_DATE"
value = "20180101"
}
overrides = {
fieldId = "CALENDAR_END_DATE"
value = "20190101"
}
}
tableOverrides[] = {
}
}
Response:
{
securityData[] = {
securityData = {
security = "UXA INDEX"
eidData[] = {
}
fieldExceptions[] = {
}
sequenceNumber = 0
fieldData = {
CALENDAR_NON_SETTLEMENT_DATES[] = {
CALENDAR_NON_SETTLEMENT_DATES = {
Holiday Date = ...
}
CALENDAR_NON_SETTLEMENT_DATES = {
Holiday Date = ...
}
...
}
}
}
}
}
The Bloomberg holiday data is lacking sometimes. You could try a service that specializes in trading holidays data like TradingHours.com.
https://www.tradinghours.com/docs/3.x/enterprise/market-holidays.html
© 2022 - 2024 — McMap. All rights reserved.