Bloomberg API

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,402
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
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Watch MrExcel Video

Forum statistics

Threads
1,126,929
Messages
5,621,656
Members
415,849
Latest member
PhoenixRising2015

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
Top