Bloomberg API

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,832
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
The following code is taken from here:

Code:
https://data.bloomberglp.com/professional/sites/10/2017/03/BLPAPI-Core-Developer-Guide.pdf

This is one such snippet taken from page 90:

Code:
'Bloomberg Excel Formula:
'BDP("IBM US Equity", "LAST_PRICE")
'
'Equivalent COM v3 Data Control Subscription Code:

Dim WithEvents session As blpapicomLib.session

Sub SomeSub

Set session = New blpapicomLib2.session
session.QueueEvents = True
session.Start
session.OpenService "//blp/mktdata"
Dim sub As blpapicomLib2.SubscriptionList
Dim cid As blpapicomLib2.CorrelationId
Set sub = session.CreateSubscriptionList()
Set cid = session.CreateCorrelationId(1)
sub.Add "IBM US Equity", "LAST_PRICE", cid ' To set an update interval of, for e.g. 4 seconds, ' use this syntax instead: ' sub.AddEx "IBM US Equity", "LAST_PRICE", "interval=4.0"
session.Subscribe sub

I assume this code ought to be placed in a class module because of Dim WithEvents.

The code doesn't compile. I think this line is faulty:

Code:
Dim sub As blpapicomLib2.SubscriptionList

as Sub is a keyword.

If I changed the Sub to abc for example, it does compile.

Then in a regular module, I write:

Code:
Dim a As Class1
Set a = New Class1

a.SomeSub

It doesn't crash but it appears nothing happens when the code runs all the way to the end.

I thought it was meant to return the equivalent of BDP("IBM US Equity", "LAST_PRICE").

Can someone please help.

Thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,214,523
Messages
6,120,031
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top