Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Bloomberg and Mathematica

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

Vlad:

I am going to make an assumption that the Bloomberg historical data is in a
similar format as that of the free finance.yahoo.com historical data. So I
took the opportunity to play around with getting finance.yahoo.com 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 Wolfram.com. So this gave me
impetus to say well can this be done in Mathematica without using (overtly)
J/Link.

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
'http://table.finance.yahoo.com/table.csv?s="; <> ToString[ticker] <>
"&amp;d=1&amp;e=24&amp;f=2004&amp;g=d&amp;a=3&amp;b=13&amp;c=1986&amp;ignore
=.csv'><!ELEMENT historical (#PCDATA)>]><historical>&text;</historical>",
"XML", ConversionOptions -> {"NormalizeWhitespace" -> False}];
   s = StringToStream[First[Cases[hist, XMLElement["historical",{}, ___],
Infinity]][[3]][[1]]];
   result = ReadList[s,  Word, RecordSeparators -> {"\n"}, RecordLists ->
True, WordSeparators -> ","];
   Close[s];
   TableForm[result]
   ];

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
finance.yahoo.com. 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 http://www.wolfram.com/solutions/finance/datafeed.html  . 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,
http://store.wolfram.com/view/book/ISBN0817641971.str .

This all assumes you have an internet connection.

Hans

"Vlad Grubman" <vgrubman at catbegemot.com> wrote in message
news:c0qik3$k5i$1 at smc.vnet.net...
> 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 catbegemot.com
>


  • 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 ...?