Click here to Skip to main content
15,886,362 members
Articles / VBA
Tip/Trick

Gathering Bloomberg Data with Synchronous VBA Calls to the API

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
4 Oct 2012CPOL 45.4K   2   2
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)


Written By
CEO Technicana
United Kingdom United Kingdom
This member doesn't quite have enough reputation to be able to display their biography and homepage.

Comments and Discussions

 
QuestionBLPSubscribe equivalent in COM v3.5 library Pin
Member 1202329930-Sep-15 5:22
Member 1202329930-Sep-15 5:22 
QuestionBLP_DATA_CTRLLib.BlpData Pin
mcc131217-Feb-13 0:49
mcc131217-Feb-13 0:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.