Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Financial Data - Currencies

73 views
Skip to first unread message

robert prince-wright

unread,
Dec 31, 2009, 3:18:28 AM12/31/09
to
Does anyone know how to get the names corresponding to the currencies available from FinancialData? If you use the command below you get a list of 153 currencies - some of which are obscure so i was hoping to generate the names!

currencyTickers = FinancialData["Currencies"]

Also, why does FinancialData not give historical data for say GBP/USD? EUR/USD works, albeit over a limited time span, so you would think the data would be there for sterling. Several others don't work either.... perhaps this is a data server issue?

R


Chris Degnen

unread,
Jan 1, 2010, 5:33:47 AM1/1/10
to
On 31 Dec, 08:18, robert prince-wright <robertprincewri...@yahoo.com>
wrote:

Here's some code for getting exchange rate history. Note the pages on
the Fed have slightly differing formats and are parsed accordingly.
Fortunately they don't change over time.
(If you're reading this post on the MathGroup beware the posting
program may have inserted semi-colons after the URLs. If so, they
should be deleted.)

(* Extract EUR/USD exhange rate *)
euData1=Import["http://www.federalreserve.gov/releases/h10/hist/
dat00_eu.txt","Data"];
euData2={StringReplace[#," "<>" "..->","]}&/@euData1;
euData3=Select[euData2,StringLength[#]=={16}&];
euData4=First[StringSplit[#,","]]&/@euData3;
euData5={DateList[#[[1]]],ToExpression[#[[2]]]}&/@euData4;
(* Extract GBP/USD exhange rate *)
ukData1=Import["http://www.federalreserve.gov/releases/h10/hist/
dat00_uk.txt","Data"];
ukData2={StringReplace[#[[1]]," "<>" "..->","]}&/@ukData1;
ukData3=Select[ukData2,StringLength[#]=={17}&];
ukData4=First[StringSplit[#,", "]]&/@ukData3;
ukData5={DateList[#[[1]]],ToExpression[#[[2]]]}&/@ukData4;
(* Plot exchange rates *)
Print[DateListPlot[{euData5,ukData5},ImageSize->600,PlotLabel->Style
["\nExchange Rate History",20],Joined->True,Epilog->{Inset[Style["GBP/
USD",12,Bold,Hue[106/117,0.6,0.6]],Automatic,{6,-7}],
Inset[Style["EUR/GBP",12,Bold,Hue[0.67,0.6,0.6]],Automatic,{-4,1}]}]];

Bob Hanlon

unread,
Jan 1, 2010, 5:34:42 AM1/1/10
to

cd[x_] :=
CountryData[x, #] & /@
{"Name", "CurrencyName", "CurrencyCode"}

Module[
{data = cd /@ CountryData[]},
Manipulate[
Grid[
SortBy[
Select[data, StringTake[#[[sb]], 1] == sel &],
#[[sb]] &],
Alignment -> Left],
{{sb, 1, SortBy},
{1 -> "Country", 2 -> "Currency", 3 -> "Code"}},
{{sel, "A", "Select"}, CharacterRange["A", "Z"]}]]


Bob Hanlon

---- robert prince-wright <robertpri...@yahoo.com> wrote:

=============

E. Martin-Serrano

unread,
Jan 1, 2010, 5:36:42 AM1/1/10
to
Hi,

Three years span

(* It works for several years span. See a good example from the David Park's
"Presentation" package *)

ClearAll[GetFinancialData];
GetFinancialData::usage =
"GetFinancialData[name, {property1,property2...},iterator] will
generate a data set where each record will contain {datelist,
propertyvalues..}. The iterator is the standard {start,end, period}
used in FinancialData. This is basically a method of retrieving a
number of property values at once.";
SyntaxInformation[
GetFinancialData] = {"ArgumentsPattern" -> {_, {_, __}, _}};
GetFinancialData[name_String, {first_String, rest__String},
iterator_List] :=
Module[{work, other},
work = Transpose@FinancialData[name, first, iterator];
other = FinancialData[name, #, iterator, "Value"] & /@ {rest};
Transpose[Join[work, other]]
]

(* Test *)

GetFinancialData["EUR/USD", {"Open", "Close", "Low",
"High"}, {"Dec 1 2006", "Dec 30 2009", "Day"}]


(* Remark *)


Works perfect. Anyway, the data so obtained does not seem to be reliable, I
mean the source does not seem to be reliable. It does not coincide with
other series that I got fromm other sources. Does anyone know how these
series are being generated?


E. Martin-SErrano
_________________________________________

DrMajorBob

unread,
Jan 2, 2010, 5:06:38 AM1/2/10
to
> (* It works for several years span. See a good example from the David
> Park's "Presentation" package *)

Yes, it works... if you don't mind most of the data being missing,
including a gap of 297 days:

data = FinancialData["EUR/USD", {2000, 1, 1}];
dates = data[[All, 1]];
differences = DateDifference @@@ Partition[dates, 2, 1];
Length@dates
DateDifference @@ dates[[{1, -1}]]
{Median@#, Length@#} & /@ Split[differences, Max[##] < 6 &]

339

789

{{1, 102}, {297, 1}, {1, 235}}

DateListPlot@data

First@data

{{2007, 9, 27}, 1.42}

Your code attempts to get data beginning Dec 1 2006, but there isn't any
until Sept 27 2007... this for a currency about which Wiki says:

"The name euro was officially adopted on 16 December 1995. The euro was
introduced to world financial markets as an accounting currency on 1
January 1999..."

and

"As of November 2008, with more than �751 billion in circulation, the euro
is the currency with the highest combined value of cash in circulation in
the world, having surpassed the U.S. dollar."

Bobby


--
DrMaj...@yahoo.com

DrMajorBob

unread,
Jan 2, 2010, 5:07:00 AM1/2/10
to
Very nice!

Bobby

On Fri, 01 Jan 2010 04:34:06 -0600, Chris Degnen <deg...@cwgsy.net> wrote:

> On 31 Dec, 08:18, robert prince-wright <robertprincewri...@yahoo.com>
> wrote:


--
DrMaj...@yahoo.com

robert prince-wright

unread,
Jan 2, 2010, 5:07:43 AM1/2/10
to
hi - I am curious about your comment that the data are not accurate. WRI say the data comes from Yahoo Finance so I am wondering why this would be wrong. Can you post some examples?

Robert


________________________________
From: E. Martin-Serrano <eMartin...@telefonica.net>
Sent: Fri, January 1, 2010 4:37:07 AM
Subject: Re: Financial Data - Currencies

Hi,

Three years span

(* Test *)


(* Remark *)


E. Martin-SErrano
_________________________________________

E. Martin-Serrano

unread,
Jan 2, 2010, 5:07:54 AM1/2/10
to
Hi,

Hi,

The Import/connection

euData1 = Import["http://www.federalreserve.gov/releases/h10/hist/
dat00_eu.txt", "Data"]

fails to work in my computer and returns $Failed plus the following message:

**FetchURL::conopen: The connection to URL
http://www.federalreserve.gov/releases/h10/hist/
dat00_eu.txt cannot be opened. If the URL is correct, you might need
to configure your firewall program, or you might need to set a proxy
in the Internet Connectivity tab of the Preferences dialog (or by
calling SetInternetProxy).**

My SetInternetProxy setting in the *preferences* tab is: *Use Proxy settings
from my system or browser*

However, the direct connection via browser works fine, so it should work
inside the Mathematica expression too, I think. And I do not see any
semicolon after the URL, as you warn, in the MathGroup post.

E. Martin-Serrano

-----Original Message-----
From: Chris Degnen [mailto:deg...@cwgsy.net]
Sent: Friday, January 01, 2010 11:34 AM
Subject: Re: Financial Data - Currencies

On 31 Dec, 08:18, robert prince-wright <robertprincewri...@yahoo.com>
wrote:

Here's some code for getting exchange rate history. Note the pages on

E. Martin-Serrano

unread,
Jan 2, 2010, 5:08:59 AM1/2/10
to
Thank you Bob,

Here, one can get every exchange rate for the Euro against most of the
currencies (up to 32) from 1999/4/1 to the present date. It comes in
Excel CSV and other formats from the ECB website.

http://www.ecb.eu/stats/exchange/eurofxref/html/index.en.html

The problem is that one needs the *High*, *Low*, *Opening* and *Closing*
trading values for the EURO/USD rate serie and not just the closing
value as given by the ECB. The data available from WRI does not seem to
be accurate (only two decimal positions, the gap you have showed, and
*High*, *Low*, *Opening* and *Closing* "confusing" values, since for
most days the four values are equal, which is imposible for at least the
*High*, *Low* and pretty rare for the *Opening* and *Closing*. The
candlestick charts for trade analiysys are just based in the intra-day
differences in value of all those magnitudes.

Thanks again

E. Martin-Serrano

-----Original Message-----
From: DrMajorBob [mailto:btr...@austin.rr.com]
Sent: Saturday, January 02, 2010 12:30 AM
To: E. Martin-Serrano; math...@smc.vnet.net
Subject: Re: Re: Financial Data - Currencies

> (* It works for several years span. See a good example from the David
> Park's "Presentation" package *)

Yes, it works... if you don't mind most of the data being missing,

including a gap of 297 days:

data FinancialData["EUR/USD", {2000, 1, 1}];


dates = data[[All, 1]];
differences = DateDifference @@@ Partition[dates, 2, 1];
Length@dates
DateDifference @@ dates[[{1, -1}]]
{Median@#, Length@#} & /@ Split[differences, Max[##] < 6 &]

339

789

{{1, 102}, {297, 1}, {1, 235}}

DateListPlot@data

First@data

{{2007, 9, 27}, 1.42}

Your code attempts to get data beginning Dec 1 2006, but there isn't any
until Sept 27 2007... this for a currency about which Wiki says:

"The name euro was officially adopted on 16 December 1995. The euro was
introduced to world financial markets as an accounting currency on 1
January 1999..."

and

"As of November 2008, with more than =E2=82=AC751 billion in circulation, the euro

is the currency with the highest combined value of cash in circulation in
the world, having surpassed the U.S. dollar."

Bobby

> Does anyone know how to get the names corresponding to the currencies
> available from FinancialData? If you use the command below you get a
> list of
> 153 currencies - some of which are obscure so i was hoping to generate
> the
> names!
>
> currencyTickers = FinancialData["Currencies"]
>
> Also, why does FinancialData not give historical data for say GBP/USD?
> EUR/USD works, albeit over a limited time span, so you would think the
> data
> would be there for sterling. Several others don't work either.... perhaps
> this is a data server issue?
>
>
>
> R
>
>
>


--
DrMaj...@yahoo.com


DrMajorBob

unread,
Jan 3, 2010, 3:39:04 AM1/3/10
to
I was getting spurious spaces at the end of lines, not semicolons.

Getting rid of those spaces fixed the code.

Bobby

On Sat, 02 Jan 2010 04:08:17 -0600, E. Martin-Serrano
<eMartin...@telefonica.net> wrote:

> Hi,
>


> Hi,
>
> The Import/connection
>
> euData1 = Import["http://www.federalreserve.gov/releases/h10/hist/
> dat00_eu.txt", "Data"]
>
> fails to work in my computer and returns $Failed plus the following
> message:
>
> **FetchURL::conopen: The connection to URL
> http://www.federalreserve.gov/releases/h10/hist/
> dat00_eu.txt cannot be opened. If the URL is correct, you might need
> to configure your firewall program, or you might need to set a proxy
> in the Internet Connectivity tab of the Preferences dialog (or by
> calling SetInternetProxy).**
>
> My SetInternetProxy setting in the *preferences* tab is: *Use Proxy
> settings
> from my system or browser*
>
> However, the direct connection via browser works fine, so it should work
> inside the Mathematica expression too, I think. And I do not see any
> semicolon after the URL, as you warn, in the MathGroup post.
>

> E. Martin-Serrano


>
> -----Original Message-----
> From: Chris Degnen [mailto:deg...@cwgsy.net]
> Sent: Friday, January 01, 2010 11:34 AM
> To: math...@smc.vnet.net
> Subject: Re: Financial Data - Currencies
>
> On 31 Dec, 08:18, robert prince-wright <robertprincewri...@yahoo.com>
> wrote:


--
DrMaj...@yahoo.com

Chris Degnen

unread,
Jan 5, 2010, 1:45:24 AM1/5/10
to
DrMajorBob wrote:
>
>> (If you're reading this post on the MathGroup beware the posting
>> program may have inserted semi-colons after the URLs. If so, they
>> should be deleted.)

> I was getting spurious spaces at the end of lines, not semicolons.

I reposted the code via math...@smc.vnet.net and the semi-colons
duly appeared.
I.e.
http://forums.wolfram.com/mathgroup/archive/2010/Jan/msg00081.html


They aren't on the Google group post.
http://groups.google.co.uk/group/comp.soft-sys.math.mathematica/browse_frm/thread/a748e84b4dae1355?hl=en#

0 new messages