MathGroup Archive 2010

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

Search the Archive

Re: Manipulating FinancialData[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106379] Re: [mg106330] Manipulating FinancialData[]
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 11 Jan 2010 05:29:15 -0500 (EST)
  • Reply-to: hanlonr at cox.net

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 <sydgeraghty at me.com> wrote: 

=============
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.

sydgeraghty at 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



  • Prev by Date: Re: NonlinearModelFit and ParameterTable
  • Next by Date: Re: Manipulating FinancialData[]
  • Previous by thread: Re: Re: Manipulating FinancialData[]
  • Next by thread: Re: Manipulating FinancialData[]