Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / VBA

Gathering Bloomberg Data with Synchronous VBA Calls to the API

0.00/5 (No votes)
4 Oct 2012CPOL 46.1K  
This article illustrates the simplest possible way of retrieving data from Bloomberg via the VBA API.

Introduction 

Developers often need to retrieve data from Bloomberg programmatically. Bloomberg has provided examples of how to do this, but I found that these were too verbose. The following code is a short and simple demonstration of how to acquire data from Bloomberg 

Using the code 

Before you enter this code into your VBA, make sure that you add a Reference to the ‘Bloomberg Data Type Library’.

VBScript
Public Sub BloombergExample()
    Dim bbgDataControl As New BLP_DATA_CTRLLib.BlpData
    Dim price As Variant
    price = bbgDataControl.BLPSubscribe("IBM US Equity", "PX LAST")
    Debug.Print price(0, 0)
End Sub

The first parameter in the call to BLPSubscribe is the mnemonic or ‘ticker’, and the second parameter is the field that you want data for. The BLPSubscribe function has more parameters to cater for other situations. 

Points of iterest

One thing to bear in mind is that this is a synchronous call to Bloomberg, so your program will halt until you get some response from Bloomberg.

The Bloomberg API is extensive and can cater for most requirements. Hopefully this article gave you a simple base from which to increase your knowledge of the API.

To find out more about the Bloomberg API, go to <WAPI> on your Bloomberg Terminal. 

History

Initial article.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)