使用 Bloomberg .Net API 的每小时数据 [英] Hourly Data using Bloomberg .Net API

查看:23
本文介绍了使用 Bloomberg .Net API 的每小时数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使用 .Net API 3.0 从彭博获取每小时 OPEN、HIGH、LOW 和 LAST_PRICE 快照的逻辑.我用谷歌搜索了很多次,但没有运气!对此的任何帮助将不胜感激.

I am struggling with the logic to get hourly OPEN, HIGH, LOW and LAST_PRICE snapshot from Bloomberg using .Net API 3.0. I have googled it many times but with no luck! Any help on this will be much appreciated.

我正在尝试在 Bloomberg .Net API (C#) 中找到与以下 VBA BDH 函数等效的函数.

I am trying to find equivalent of following VBA BDH function in Bloomberg .Net API (C#).

BDH(B5,C6:F6,TODAY()-30,"","BarTp=T","BarSz=120","days=T","Dir=V","Dts=S",,"Quot‌​e=C","UseDPDF=Y","Sort=D",,"cols=5;rows=271") 

其中 B5 是证券名称,C6:F6 包含 OPEN、HIGH、LOW 和 LAST_PRICE 字段.我尝试过 Intraday Bar 请求,但它返回的值与此 BDH 函数返回的值不同.此外,历史数据请求没有 HOURLY 间隔选项,它从 DAILY 间隔开始.

where B5 is security name and C6:F6 contain OPEN, HIGH, LOW and LAST_PRICE fields. I have tried Intraday Bar request but it does not return same values as returned by this BDH function. Also, Historical Data request does not have HOURLY interval option, it starts from DAILY interval.

以下是我迄今为止尝试过的代码:

Following is the code which I have tried so far:

BBService refDataService = session.GetService("//blp/refdata"); 
BBRequest request = refDataService.CreateRequest("IntradayBarRequest"); 
request.Set("security", "SPX INDEX"); 
request.Set("eventType", "TRADE"); 
request.Set("interval", 120); // bar interval in minutes
request.Set("startDateTime", new BBDateTime(2012, 08, 11, 07, 30, 0, 0)); 
request.Set("endDateTime", new BBDateTime(2012, 08, 20, 18, 30, 0, 0)); 
session.SendRequest(request, null);

推荐答案

在 Bloomberg API 发行版中,查看很棒的examples"文件夹.

in the Bloomberg API distribution, take a look at the great "examples" folder.

下面的示例应用程序实现了您的请求.:

The sample application below implements your request.:

\blp\API\APIv3\DotnetAPI\v3.2.9.0\examples\WinForm\C#\SimpleIntradayBarExample

\blp\API\APIv3\DotnetAPI\v3.2.9.0\examples\WinForm\C#\SimpleIntradayBarExample

基本上核心"是这样的:

Basically the "core" is like that:

        Service refDataService = d_session.GetService("//blp/refdata");
        // create intraday bar request 
        Request request = refDataService.CreateRequest("IntradayBarRequest");
        // set request parameters
        request.Set("eventType", "TRADE");
        request.Set("security", "SPX Index");
        DateTime startDate = dateTimePickerStartDate.Value;
        DateTime endDate = dateTimePickerEndDate.Value;
        request.Set("startDateTime", new BDateTime(startDate.Year, startDate.Month, startDate.Day,
                startDate.Hour, startDate.Minute, startDate.Second, 0));
        request.Set("endDateTime", new BDateTime(endDate.Year, endDate.Month, endDate.Day,
            endDate.Hour, endDate.Minute, endDate.Second, 0));
        request.Set("gapFillInitialBar", True);
        request.Set("interval",60);
        // create correlation id
        CorrelationID cID = new CorrelationID(1);
        d_session.Cancel(cID);
        // send request
        d_session.SendRequest(request, cID);
        toolStripStatusLabel1.Text = "Submitted request. Waiting for response...";

并且在提交之后,您必须接受彭博的回复,解析并使用它.

and after the Submission, you must take the Bloomberg response, parse it and use it.

快乐编码.

请找到示例 C# 代码的结果以及彭博社提出的等效请求.请记住时区的差异!当您使用 C# 编写代码时,Bloomberg 库使用 UTC,而使用 Excel 插件时,时区是您的本地时区.

Please find the result of the sample C# code and the equivalent request made by Bloomberg. Just keep in mind the difference in TimeZONE! When you code in C#, the Bloomberg library is in UTC, while using Excel addin the timezone is your Local Zone.

这篇关于使用 Bloomberg .Net API 的每小时数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆