如何从Bloomberg API获得交易假期

时间:2011-10-26 17:09:07

标签: java api bloomberg

我正在使用Bloomberg Java api下载交易数据。我需要有人告诉我是否存在可以返回交易假期列表的功能。我查看了手册但找不到一个。如果没有这样的东西,有没有一种方法可以创造一个?感谢。

5 个答案:

答案 0 :(得分:6)

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"));

答案 1 :(得分:1)

对于给定的安全性,Bloomberg API会告诉您使用DS853(CALENDAR_CODE)的相​​应日历代码。鉴于日历代码,我不相信彭博提供下载假日日历的方法。您可能需要使用第三方供应商,例如Financial Calendar

答案 2 :(得分:0)

我在获得公认的答案时遇到了问题。原来不需要SETTLEMENT_CALENDAR_CODE。以下工作:

{
securities[] = {
    /bbgid/BBG00HZZLBT7
}
fields[] = {
    CALENDAR_NON_SETTLEMENT_DATES
}
overrides[] = {
    overrides = {
        fieldId = "CALENDAR_START_DATE"
        value = "20180101"
    }
    overrides = {
        fieldId = "CALENDAR_END_DATE"
        value = "20190101"
    }
}
tableOverrides[] = {
}
}

响应:

{
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 = ...
                }
                ...
            }
        }
    }
}
}

答案 3 :(得分:0)

有时缺乏彭博假期数据。您可以尝试专门交易假期数据的服务,例如 TradingHours.com。

https://www.tradinghours.com/docs/3.x/enterprise/market-holidays.html

答案 4 :(得分:0)

Python 实现如下。请注意,我们在阿姆斯特丹使用日历“AM”,将复活节的第二天标记为国定假日。

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)