Search code examples
bloomberg

Bloomberg C# API - How to Call BDP with different options/Fields


I am trying to migrate from Excel add-in to Bloomberg C# Desktop API. For simple calls like BDP("AB IB Equity","best_analyst_rating") I am able to do without issues using something like this:

    private void sendRefDataRequest(Session session)
    {            
        Service refDataService = session.GetService("//blp/refdata");
        Request request = refDataService.CreateRequest("ReferenceDataRequest");

        // Add securities to request
        Element securities = request.GetElement("securities");
        securities.AppendValue("AB IB Equity");
        Element fields = request.GetElement("fields");
        fields.AppendValue("best_analyst_rating");
        System.Console.WriteLine("Sending Request: " + request);
        session.SendRequest(request, null);
    }

But for more complex calls involving additional options to BDP like BDP("AB IB Equity","bs_tot_asset","EQY_Consolidated","Y","EQY_FUND_Relative_Period","-0FY") I have no clue how to translate it to C# calls. Appreciate any help on this.


Solution

  • You need to set the overrides. For any given field you can find these using FLDS in the Bloomberg terminal.

    Element overrides = request.GetElement("overrides");
    

    Then loop through the necessary overrides, setting the fieldId to the Mnemonic from FLDS and the value to your specific request:

    Element override = overrides.AppendElement();
    override.SetElement("fieldId","EQY_CONSOLIDATED");
    override.SetElement("value","Y");