如何从 Bloomberg API 获取交易假期

发布于 2024-12-11 22:52:05 字数 104 浏览 0 评论 0原文

我正在使用 Bloomberg Java api 下载交易数据。我需要有人告诉我是否存在可以返回交易假期列表的函数。我翻阅了手册但没有找到。如果没有这样的东西,有什么好方法可以创建一个吗?谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

皓月长歌 2024-12-18 22:52:05
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"));
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"));
邮友 2024-12-18 22:52:05

对于给定的证券,彭博 API 将使用 DS853 (CALENDAR_CODE) 告诉您适当的日历代码。给定日历代码,我不相信彭博社提供了下载假日日历的方法。您可能需要使用第三方供应商,例如财经日历

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.

终止放荡 2024-12-18 22:52:05

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)

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)
梦忆晨望 2024-12-18 22:52:05

我在获得接受的答案时遇到了问题。结果发现不需要 SETTLMENT_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 = ...
                }
                ...
            }
        }
    }
}
}

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 = ...
                }
                ...
            }
        }
    }
}
}
も让我眼熟你 2024-12-18 22:52:05

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文