Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have the following code:

Read all the DOW jones financial instruments

instruments = FinancialData["^DJI", "Members"]

Then I create a dynamic variable called ticker

Dynamic[ticker]

ticker =.

And I create a popup menu with

{PopupMenu[Dynamic[ticker], instruments], Dynamic[ticker]}

So far it all works. I have my list of stock instruments in variable instruments and the popup menu comes up and when I pick a stock from it, the ticker (displayed to the right of the menu) updates to show the ticker I chose from the drop down list

My problem is that I would like to have a chart automatically updated once I pick a ticker. For now I have:

data = FinancialData[ticker, "OHLCV", {{2008, 7, 3}, {2008, 9, 30}}]

And I use

InteractiveTradingChart[data]

To display the chart

This works if I hit Shift enter on the last line. However, if I go to the popup menu and select a different stock (say INTC for Intel) the chart is not updated. I am new to Mathematica and I am sure that my problem is not understanding how Dynamic works.

What I don't understand

InteractiveTradingChart[data]
share|improve this question
    
Indeed, welcome Henrick. You might have missed the question mark at the top right of your question entry box. This is a link that leads you to a short course in MarkDown, the layout system used here to prettify your text. –  Sjoerd C. de Vries Feb 13 '12 at 20:10
    
If you change your "data" definition to data = Dynamic[ FinancialData[ticker, "OHLCV", {{2008, 7, 3}, {2008, 9, 30}}]] then the data will update automatically. If you change the chart to InteractiveTradingChart[data[[1, All]]] then it will recognize the new data when that line is evaluated. However, I can't figure out how to make the chart update automatically. –  Tim Mayes Feb 13 '12 at 21:51
add comment

1 Answer 1

I believe the easiest way to accomplish this is with Manipulate.

Manipulate[
 InteractiveTradingChart[
  FinancialData[ticker, 
   "OHLCV", {{2008, 7, 3}, {2008, 9, 30}}]], {ticker, instruments}]

enter image description here

share|improve this answer
1  
I'm falling in love with Mathematica. Simple, effective. –  CHM Feb 13 '12 at 20:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.