How do I get trading holidays from the Bloomberg API
Asked Answered
C

5

6

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.

Croatia answered 26/10, 2011 at 17:9 Comment(0)
O
9
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"));
Overweening answered 30/8, 2012 at 16:51 Comment(0)
S
2

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.

Septavalent answered 26/10, 2011 at 19:3 Comment(0)
M
2

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)
Mincemeat answered 24/2, 2021 at 12:5 Comment(0)
J
1

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 = ...
                }
                ...
            }
        }
    }
}
}
Jujube answered 18/7, 2018 at 8:10 Comment(2)
Although this gives a list of dates, this gives every holiday in every country. Add the "Settlement_calender_code" (EG "AM" for Amsterdam) to get the list of holidays in a specific country.Mincemeat
@Jelmer, BB defaults to US if no calendar code is passed in, which works for the UXA and AAPL examples here since they're both US securities. It seems the security passed in is somewhat irrelevant, and AM (or NE rather) would do Dutch holidays, and JN the Japan ones.Mersey
E
1

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

Evapotranspiration answered 6/1, 2021 at 15:25 Comment(2)
Where can I get weekend convention per market/country?Wigwag
That information is available through tradinghours.com's API. (I run tradinghours.com). Reach out through the website and we'll get in touchEvapotranspiration

© 2022 - 2024 — McMap. All rights reserved.