65.9K
CodeProject is changing. Read more.
Home

Gathering Bloomberg Data with Synchronous VBA Calls to the API

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Sep 8, 2012

CPOL
viewsIcon

46113

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’.

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.