문제

I would like to get averages values from Yahoo!'s stock feed.

In my example, I used:

http://finance.yahoo.com/d/quotes.csv?s=ANZ.AX&f=spm3m4

As of writing, the m3 (50SMA) is 20.8167, and m4 (200SMA) is 20.7455. This does not seem to match the chart in any timeframe (1D to 5Y).

Why am I getting wrong figures?

도움이 되었습니까?

해결책

First a big caveat: These Yahoo Finance CSV feeds are not an official API and you would probably not want to build a real app using them.

If you want to figure out the data sources used by Yahoo Finance you can watch the dynamic HTTP calls as you make changes to the chart. Using Firebug, I watched as I added the 50 & 200 day moving averages to the chart and found these files being fetched:

http://chartapi.finance.yahoo.com/instrument/1.0/goog/chartdata;type=sma;ys=2010;yz=2;ts=1234567890/csv?period=50
http://chartapi.finance.yahoo.com/instrument/1.0/goog/chartdata;type=sma;ys=2010;yz=2;ts=1234567890/csv?period=200

The files have the moving averages for each day (or x-axis point) on the chart.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top