Author Topic: Excel Addin to pull prices from Bloomberg  (Read 303 times)

rukawa

  • Hero Member
  • *****
  • Posts: 513
Excel Addin to pull prices from Bloomberg
« on: August 12, 2017, 12:38:39 PM »
I wanted to pull prices from Japanese stocks automagically in an Excel spread sheet. The SMF addin doesn't really work for Japan. I looked at thread on Google tips:
http://www.cornerofberkshireandfairfax.ca/forum/general-discussion/google-spreadsheet-tips-and-tricks/40/

Its pretty great but I ran into problems with ImportXML and I preferred to use Excel. So I created my own addin using ExcelDNA and C#. The attached addin was meant to pull prices from Bloomberg but it also has functionality to pull data from any site using xpath selectors. There are two xll addins: one for 32-bit Excel and one for 64-bit Excel. In addition the Examples.xlsx contains examples of how the functions are called and the attached word document provides some documentation. I've also include a zip of my full visual studio project for those who want to modify it.

getPrice(ticker) – goes to Bloomberg page https://www.bloomberg.com/quote/ticker and grabs the price from that page using the selector //div[@class=’price’]

getName(ticker) – same as get price except that it grabs the name using the selector //h1[@class=’name’]

getBloombergAttribute(ticker, selector) - goes to Bloomberg page https://www.bloomberg.com/quote/ticker and grab text from xpath selector specified in function call

getAttribute(url, selector) – goes to arbitrary url and grabs text from whatever selector is specified in function call argument

The easiest and most useful one is getPrice. And an example call is:

=getPrice("7922:JP")
« Last Edit: August 12, 2017, 12:45:46 PM by rukawa »