MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Bloomberg and Mathematica

  • To: mathgroup at
  • Subject: [mg46582] Re: Bloomberg and Mathematica
  • From: "Hans Michel" <hansjm at>
  • Date: Tue, 24 Feb 2004 21:04:31 -0500 (EST)
  • References: <c0qik3$k5i$>
  • Reply-to: "Hans Michel" <hansjm at>
  • Sender: owner-wri-mathgroup at


I am going to make an assumption that the Bloomberg historical data is in a
similar format as that of the free historical data. So I
took the opportunity to play around with getting data as
CSV file from the internet through HTTP without saving the file to disk
first. I think that the Bloomberg data also provides a CSV file which is
what they used to if not still provided for import into Excel. For example,
sites like InsiderInsights, EdgarOnline provide data in the native Excel
(Microsoft Excel Binary File Format [ Perl Module, PHP, and even free
Microsoft C++ code, is available online that can write Excel file format
with out the use of Excel)

Now your job would probably be much easier if you saved your data to a file
then used Mathematica's many Import, ReadList, or the like functions.
However, I was bothered that no where in the help files did it say that you
can upload CSV data straight from the a web site through HTTP.

Christopher Purcell suggested using the GetURL function which is hard to
find in the Help files but easier if you go to So this gave me
impetus to say well can this be done in Mathematica without using (overtly)

So I came up with the following code

getYahooHistoricalData[ticker_] := Module[ {hist, s, result},
   hist = ImportString["<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE
historical [<!ENTITY text SYSTEM
'"; <> ToString[ticker] <>
=.csv'><!ELEMENT historical (#PCDATA)>]><historical>&text;</historical>",
"XML", ConversionOptions -> {"NormalizeWhitespace" -> False}];
   s = StringToStream[First[Cases[hist, XMLElement["historical",{}, ___],
   result = ReadList[s,  Word, RecordSeparators -> {"\n"}, RecordLists ->
True, WordSeparators -> ","];

This is still cheating I am using the New XML import features of
Mathematica. In brief  the XML string is a Well formed valid XML document
with declaration, embedded DTD, one ENTITY whose source is the CSV file on Now since  the "AllowUnrecognizedEntities"
ConversionOption is defaulted to Automatic I don't included it. When the
entity gets resolved voila you get the source data. But I avoided Java in
place of XML. One language over another. If you are more comfortable with
Java then GetURL is fine. Also Wolfram site state J/Link as a solution to
Bloomberg data  . But
then what is the purpose of getting the data in Mathematica?

Since you where not precise as to what you will do with the data once it is
in Mathematica I left it as a List of Strings. The rest is up to you.

If your problem is similar then, the pitfalls you will have to look out for
are date formats and plotting.

Wolfram Research sells a financial analysis Add-On toolkit, and there are
many books for example, .

This all assumes you have an internet connection.


"Vlad Grubman" <vgrubman at> wrote in message
news:c0qik3$k5i$1 at
> Hello everyone,
> this is my first post, so don't kick me yet if I do something wrong.
> I have a task at hand to retrieve Bloomberg's historical data into
> Mathematica. I'm not even sure where to start looking, so any advice
> will be highly appreciated. I'm pretty much an experienced programmer,
> but just saw Mathematica for the first time, so consider me as a total
> newbie :)
> Thanks in advance and hope to hear some responses soon.
> -- 
> Best regards,
>  Vlad                          mailto:vgrubman at

  • Prev by Date: RE: How to set y always greater than or equal to x for a function?
  • Next by Date: RE: Re: corrected RE: Re: Computing sets of equivalences
  • Previous by thread: RE: Bloomberg and Mathematica
  • Next by thread: Solve or LinearSolve or ...?