Click here to Skip to main content
Click here to Skip to main content

Tagged as

Gathering Bloomberg Data with Synchronous VBA Calls to the API

, 4 Oct 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
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.

License

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

Share

About the Author

Chris Spicer
CEO Technicana
United Kingdom United Kingdom
I am the founder and lead developer for Technicana, a software firm that builds tools for Office Developers. I have ten years experience as a C#/VBA Developer for Investment Banks.
 
My main product is VbaDiff, a Power Tool for Vba Developers.
Follow on   Twitter

Comments and Discussions

 
QuestionBLP_DATA_CTRLLib.BlpData Pinmembermcc131217-Feb-13 1:49 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 4 Oct 2012
Article Copyright 2012 by Chris Spicer
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid