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

Manipulating FinancialData[]

12 views
Skip to first unread message

Syd Geraghty

unread,
Jan 8, 2010, 4:17:47 AM1/8/10
to
Hi all,

I have got stuck trying to play around with manipulating FinancialData[]!

Manipulate[Column[{
Row[{"FinancialData[", ToString[financialInstrumentName], "] = ",
FinancialData[financialInstrumentName]}],
Row[{"\nProperty = ", ToString[property]}],
Row[{"\nfinancialDataExchange = ", ToString[financialDataExchange]}],
Row[{"\nFinancialData[", ToString[financialInstrumentName],
"," ToString[property], "] = ",
FinancialData[financialInstrumentName, property]}]
}],
{{financialDataExchange, "NASDAQ", "Exchange List"},
FinancialData["Exchanges"]}, {{financialInstrumentName, "NASDAQ:AAPL",
"Financial Instrument List"},
FinancialData["NASDAQ:*", "Lookup"]}, {{property, "Close", "Property List"},
FinancialData["Properties"]}]


is a simple example which enables me to select an Exchange List, Financial Instrument List, and a Property List.

But I really want the Financial Instrument List to be derived from the selected Exchange List when I subsequently select a member of that List. (e.g. "ExchangeList Selection:Stock Name").

So I tried variants of the following without success:

Manipulate[Column[{
Row[{"FinancialData[", ToString[financialInstrumentName], "] = ",
FinancialData[financialInstrumentName]}],
Row[{"\nProperty = ", ToString[property]}],
Row[{"\nfinancialDataExchange = ", ToString[financialDataExchange]}],
Row[{"\nFinancialData[", ToString[financialInstrumentName],
"," ToString[property], "] = ",
FinancialData[financialInstrumentName, property]}]
}],
{{financialDataExchange, "NASDAQ", "Exchange List"},
FinancialData["Exchanges"]}, {{financialInstrumentName, "NASDAQ:AAPL",
"Financial Instrument List"},
FinancialData[ToString[financialDataExchange <> ":" <> "*"],
"Lookup"]}, {{property, "Close", "Property List"},
FinancialData["Properties"]}]


What I am trying to do probably becomes clearer after using the Manipulate output from the 1st piece of code:

After the 1st evaluation, which by default selects NASDAQ:AAPL, then select another member of the Exchange List, say Singapore.

What I want is for the Financial Instrument List to then allow selections from the revised list such as Singapore:AAPL, Singapore:AATI, Singapore: .....

I would appreciate help in solving this seemingly simple requirement.


Cheers .... Syd

Syd Geraghty B.Sc, M.Sc.

sydge...@mac.com

Mathematica 7.0.1.0 for Mac OS X x86 (64 - bit) (12th September 2009)
MacOS X V 10.6.1 Snow Leopard
MacBook Pro 2.33 GHz Intel Core 2 Duo 2GB RAM


Drago Ganic

unread,
Jan 11, 2010, 5:26:29 AM1/11/10
to
Hi Syd,
to retrieve the financial instruments You should use the "Members" property
of the group "Exchanges" and not the "Lookup" command.

So, this does not work:
FinancialData["exchangeCode:*", "Lookup"]

but this
FinancialData["exchangeName", "Members"]

will work because FinancialData["Exchanges"] returns a list of Exchange
names (which work with "Members") and not Exchange codes (which work with
Lookup"). Unfortunatly there is no simple functionality in FinancialData to
extract the Exchange codes.

This code should work (except for bugs in FinancialData like
FinancialData["^ASIN"] etc.):
==================================================


Manipulate[
Column[{
Row[{"FinancialData[", ToString[financialInstrumentName], "] = ",
FinancialData[financialInstrumentName]}],
Row[{"\nProperty = ", ToString[property]}],
Row[{"\nfinancialDataExchange = ",
ToString[financialDataExchange]}],
Row[{"\nFinancialData[", ToString[financialInstrumentName],
"," ToString[property], "] = ",
FinancialData[financialInstrumentName, property]}]}
],
{{financialDataExchange, "NASDAQ", "Exchange List"},
FinancialData["Exchanges"]}, {{financialInstrumentName,
"NASDAQ:AAPL", "Financial Instrument List"},

FinancialData[financialDataExchange, "Members"]}, {{property,


"Close", "Property List"}, FinancialData["Properties"]}]

Greetings from Croatia,
Drago

"Syd Geraghty" <sydge...@me.com> wrote in message
news:hi6t7r$a7u$1...@smc.vnet.net...

Bob Hanlon

unread,
Jan 11, 2010, 5:29:03 AM1/11/10
to
Nesting Manipulate works.

Clear[fd];

fd[entity_String, property_String] :=
FinancialData[entity, property];

Note that not all of the exchanges have data available

exch = Select[FinancialData["Exchanges"],
Length[fd[# <> ":*", "Lookup"]] > 0 &]

{AMEX,CME,NASDAQ,NYSE}

prop = FinancialData["Properties"];

fd[exchange_?(MemberQ[exch, #] &)] :=
fd[exchange] =
StringDrop[#, StringLength[exchange] + 1] & /@

fd[exchange <> ":*", "Lookup"];

fd /@ exch; (* cache instruments *)

Updates are slow whenever the instrument changes due to the time required to determine valid properties for property list.

Off[FinancialData::notent] (* Quiet transient errors when switching *)

Manipulate[
Manipulate[
instruments = Select[fd[Exchange],
StringTake[#, 1] == InstrumentGroup &];
Manipulate[
ValidPropertiesList =
Select[prop,
AtomQ[fd[Exchange <> ":" <> Instrument, #]] &];
DefaultProperty = If[
MemberQ[ValidPropertiesList, "Close"],
"Close", "Name"];
Manipulate[
Column[{
fd[Exchange, "Name"], "",
fd[Exchange <> ":" <> Instrument, "Name"], "",
Property <> " = " <> ToString[
fd[Exchange <> ":" <> Instrument, Property]]}],
{{Property, DefaultProperty, "Property\n (" <>
ToString[Length[ValidPropertiesList]] <> ")"},
ValidPropertiesList},
ContentSize -> {300, 200}],
{{Instrument, instruments[[1]], "Instrument\n (" <>
ToString[Length[instruments]] <> ")"}, instruments},
FrameMargins -> -5],
{{InstrumentGroup, "A", "Instrument Group"},
Union[StringTake[#, 1] & /@ fd[Exchange]]},
FrameMargins -> -5],
{{Exchange, "NASDAQ"}, exch},
FrameMargins -> -5]


Bob Hanlon

---- Syd Geraghty <sydge...@me.com> wrote:

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

Syd Geraghty

unread,
Jan 11, 2010, 5:29:26 AM1/11/10
to
Thanks Bob,

I really appreciate this solution as well as hundreds more from you which over the years I have collected, analyzed, and learned from.


Cheers .... Syd

Syd Geraghty B.Sc, M.Sc.

sydge...@mac.com

Mathematica 7.0.1.0 for Mac OS X x86 (64 - bit) (12th September 2009)
MacOS X V 10.6.1 Snow Leopard
MacBook Pro 2.33 GHz Intel Core 2 Duo 2GB RAM

Syd Geraghty

unread,
Jan 12, 2010, 4:50:03 AM1/12/10
to
Thanks Drago,

I appreciate your pointing out FinancialData["exchangeName", "Members"] to me and for providing a soluyion using it.


Cheers .... Syd

Syd Geraghty B.Sc, M.Sc.

sydge...@mac.com

Mathematica 7.0.1.0 for Mac OS X x86 (64 - bit) (12th September 2009)
MacOS X V 10.6.1 Snow Leopard
MacBook Pro 2.33 GHz Intel Core 2 Duo 2GB RAM

0 new messages