Michael Mathews
Michael Mathews

Reputation: 21

VBA code to get live stock index values

I'm looking to get live values for stock indexes, such as the Dow (DJIA) or Hang Seng Index (HSI).

These need to be generated from a (configurable) set of index symbols, and saved to VBA variables without any interaction with the sheets. Ideally this would be from Bloomberg, or Yahoo if need be (though any other source would be ok too, as long as it's live).

I understand this is a simple task, though I can't find any direct way of doing it- only examples of getting option price or stock data etc. I understand I start with a reference to the Bloomberg API, but I can't seem to get further than this.

Thanks for your help

Upvotes: 0

Views: 2178

Answers (2)

assylias
assylias

Reputation: 328679

If you want to retrieve live data using the Bloomberg API, you need to be a Bloomberg subscriber ($$$). As you also mention Yahoo, which is free, I suspect it is not what you want.

Upvotes: 1

Uri Goren
Uri Goren

Reputation: 13690

This isn't a simple task.

You'll need to initiate an HTTP GET request for http://www.google.com/finance?q=GOOG, and parse the return string you self.

The HTTP Request is sent with this code:

     Set HttpReq = CreateObject("MSXML2.ServerXMLHTTP")
     HttpReq.Open "GET", "http://www.google.com/finance?q=GOOG", False
     HttpReq.send
     MsgBox HttpReq.responseText

Upvotes: 0

Related Questions