Bloomberg FTP Calendar Data

In this example, we are going to retrieve holiday schedules for several securities via Bloomberg FTP, starting from a generic ticker. With Bloomberg, we cannot make a single request to retrieve specific holiday data for a ticker. We need to know it calendar code first. Calendar codes can later be saved in a database to avoid multiple requests. Thus, we will make two requests:

  1. First, we retrieve calendar codes corresponding to generic tickers
  2. Next, we use calendar codes to holiday schedules (non-settlement dates)

Here is the first file we are going to send:

START-OF-FILE
FIRMNAME=XXXXX
SECID=TICKER
PROGRAMFLAG=oneshot
PROGRAMNAME=getdata
REPLYFILENAME=calendar_codes.out
COLUMNHEADER=yes
SECMASTER=yes
DERIVED=yes
COMPRESS=no
DELIMITER=,
HEADER=no

START-OF-FIELDS
CALENDAR_CODE
END-OF-FIELDS

START-OF-DATA
ES1 Index
TY1 Comdty
...
END-OF-DATA
END-OF-FILE

For the detailed description of common request parameters, refer to the Bloomberg FTP Intro.

The parameters relevant to the calendar data request are the following:

  • PROGRAMNAME — we need to use getdata program here since we are looking for reference data.
  • FIELDS/CALENDAR_CODE — this is a bloomberg field that will get us calendar codes for each of the requested instruments.

The response file should look like the following:

START-OF-FILE
"SECURITIES","ERROR CODE","NUM FLDS","CALENDAR_CODE"
"ES1 Index",0,1,"CE",
"TY1 Comdty",0,1,"CB",
...
  

Now we have the data to send a second request to Bloomberg to get the holiday data for each of the calendars:

START-OF-FILE
START-OF-FILE
FIRMNAME=XXXXX
SECID=TICKER
PROGRAMFLAG=oneshot
PROGRAMNAME=getdata
REPLYFILENAME=holidays.out
COLUMNHEADER=yes
SECMASTER=yes
CLOSINGVALUES=yes
DERIVED=yes
COMPRESS=no
DELIMITER=,
HEADER=no

START-OF-FIELDS
CALENDAR_NON_SETTLEMENT_DATES
SETTLEMENT_CALENDAR_CODE
END-OF-FIELDS

START-OF-DATA
ES1 Index|TICKER|3|SETTLEMENT_CALENDAR_CODE|CALENDAR_START_DATE|CALENDAR_END_DATE|CE|20221231|20241231|
...
END-OF-DATA
END-OF-FILE

In requested fields, CALENDAR_NON_SETTLEMENT_DATES will returns the non-settlement dates on the exchange, which is usually what you need to know when not to trade, and SETTLEMENT_CALENDAR_CODE just repeats the calendar code in case we need it. Data part is a bit tricky here, since we have to specify the date ranges for the calendars, and it has the following syntax:

  • ES1 Index|TICKER — name of the generic index and its type
  • 3|SETTLEMENT_CALENDAR_CODE|CALENDAR_START_DATE|CALENDAR_END_DATE — here we say that there will be three more fields, and the names of those fields.
  • CE|20221231|20241231| — and we follow with three corresponding values for those fields. Here we request holidays from the end of 2022 till the end of 2024.

The response file should look like the following:

START-OF-FILE
"SECURITIES","ERROR CODE","NUM FLDS","CALENDAR_NON_SETTLEMENT_DATES","SETTLEMENT_CALENDAR_CODE"
"ES1 Index",0,2,";2;18;1;5;01/02/2023;5;01/16/2023;5...;","CE",
...