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 am trying to plot stocks showing some of the local maxima. As an exercise I first tried to load Apple's stock data from Wolfram Alpha with the following code:

appledata =TimeSeries[WolframAlpha["AAPL", {{"History", 1}, "ComputableData"}][[1]]];
  Show[DateListPlot[appledata],DateListPlot[FindPeaks[TimeSeriesResample[appledata], 12], 
  Joined -> False,PlotStyle -> Directive[PointSize[0.03], Red]]] 

However, I am returning the following errors:

DateListPlot::ldata: TimeSeries[NotAvailable] is not a valid dataset or list of datasets. >>
FindPeaks::arg: The argument TimeSeriesResample[TimeSeries[NotAvailable]] at position 1 is not a consistent list of real values. >>
DateListPlot::ldata: FindPeaks[TimeSeriesResample[TimeSeries[NotAvailable]],12] is not a valid dataset or list of datasets. >>
Show::gcomb: Could not combine the graphics objects in Show[DateListPlot[TimeSeries[NotAvailable]],DateListPlot[FindPeaks[TimeSeriesResample[TimeSeries[NotAvailable]],12],Joined->False,PlotStyle->Directive[PointSize[0.03],\!\(\*GraphicsBox[{{GrayLevel[0], RectangleBox[{0, 0}]},{GrayLevel[0], RectangleBox[{1, -1}]},{RGBColor[1, 0, 0], RectangleBox[{0, -1}, {2, 1}]}},AspectRatio->1,Frame->True,FrameStyle-RGBColor[0.6666666666666666, 0., 0.],FrameTicks->None,ImageSize->{Automatic, 10.8},PlotRangePadding->None]\)]]]. >>

I'd like to move beyond just searching stocks such as Apple and be able to search tickers, maybe something like https://www.google.com/webhp?sourceid=chrome-instant&rlz=1C1LENP_enUS562US562&ion=1&espv=2&ie=UTF-8#q=ugaz&safe=off

share|improve this question
    
Before stacking all the functions just try to get the W|A call to return something useful on its own. Financial data is obtained through Yahoo finance (well, at least FinancialData does that) and the results can be less than stable. Sometimes the same call that worked 5 minutes ago doesn't work now. –  Sjoerd C. de Vries Jul 12 at 1:09

1 Answer 1

up vote 8 down vote accepted

Calling Wolfram|Alpha is not generally an efficient way to retrieve bulk data; where possible, it is better to use a built in data function.

Part of the problem is figuring out what to submit to Wolfram|Alpha. In the code you supplied, the issue begins with Wolfram|Alpha returning Missing[NotAvailable]. WolframAlpha["AAPL history",{{"HistoryDaily:Close:FinancialData",1},"ComputableData"}] worked for me, however.

In this case it is easier to use FinancialData, which at least has a documented syntax. So:

FinancialData["UGAZ","High",{{2000,1,1},DateList@Now}];
%//TimeSeries;
Show[
  DateListPlot[%],
  DateListPlot[
    FindPeaks[TimeSeriesResample[%],12],
    Joined->False,PlotStyle->Directive[PointSize[0.03],Red]]]

enter image description here

share|improve this answer

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.