Hourly Data using Bloomberg .Net API

我怕爱的太早我们不能终老 提交于 2019-12-04 12:04:52

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

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.

Happy coding.

EDITED:

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.

You may worked this out already, but you need to be careful with the time zone of your times.

Bloomberg intraday times are all be in GMT - I think it says this in the docs somewhere. This applies to both "IntradayBarRequest" and "IntradayTickRequest".

N.b. this is different from a subscription to live data (e.g. using Subscription and Session), which uses your local time zone (as set in your Bloomberg Terminal). That is, of course, unless you use the override "useGMT".

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!