股票API之----------雅虎财经频道

本文介绍Yahoo财经频道获取股票数据的API。可以通过此API获取实时数据。

实时数据请求

请求地址

http://finance.yahoo.com/d/quotes.csv?s=<股票名称>&f=<数据列选项>

参数

  • s — 表示股票名称,多个股票之间使用英文加号分隔,如“XOM+BBDb.TO+JNJ+MSFT”,罗列了四个公司的股票:XOM, BBDb.TO, JNJ, MSFT。
  • f — 表示返回数据列,如“snd1l1yr”。更详细的参见附录。

示例

http://finance.yahoo.com/d/quotes.csv?s=XOM+BBDb.TO+JNJ+MSFT&f=snd1l1yr

返回:

"XOM","Exxon Mobil Corpo","10/7/2010",63.85,2.69,12.33
"BBD-B.TO","BOMBARDIER INC., ","10/7/2010",5.27,1.90,N/A
"JNJ","Johnson & Johnson","10/7/2010",63.22,3.26,13.06
"MSFT","Microsoft Corpora","10/7/2010",24.53,2.12,11.68

历史数据请求

上述是获取当前最新的数据,若需要获得历史数据,请使用下面API。

请求地址

http://ichart.yahoo.com/table.csv?s=<string>&a=<int>&b=<int>&c=<int>&d=<int>&e=<int>&f=<int>&g=d&ignore=.csv

参数

  • s — 股票名称
  • a — 起始时间,月
  • b — 起始时间,日
  • c — 起始时间,年
  • d — 结束时间,月
  • e — 结束时间,日
  • f — 结束时间,年
  • g — 时间周期。Example: g=w, 表示周期是‘周’。d->‘日’(day), w->‘周’(week),m->‘月’(mouth),v->‘dividends only’

一定注意月份参数,其值比真实数据-1。如需要9月数据,则写为08。

示例

查询浦发银行2010.09.25 – 2010.10.8之间日线数据

http://ichart.yahoo.com/table.csv?s=600000.SS&a=08&b=25&c=2010&d=09&e=8&f=2010&g=d

返回:

Date,Open,High,Low,Close,Volume,Adj Close
2010-09-30,12.37,12.99,12.32,12.95,76420500,12.95
2010-09-29,12.20,12.69,12.12,12.48,79916400,12.48
2010-09-28,12.92,12.92,12.57,12.58,63988100,12.58
2010-09-27,13.00,13.02,12.89,12.94,43203600,12.94

深沪股票代码

yahoo的api是国际性的,是支持国内沪深股市的,但代码稍微变动一下,如浦发银行的代号是:600000.SS。规则是:上海市场末尾加.ss,深圳市场末尾加.sz。

—— EOF ——

参考

  • http://code.google.com/p/yahoo-finance-managed/
  • http://finance.yahoo.com/
  • http://www.gummy-stuff.org/Yahoo-data.htm
  • Python API Class http://www.goldb.org/ystockquote.html
  • Ruby API Class http://www.transparentech.com/opensource/yahoofinance

附录

雅虎股票API f参数对照表

a Ask a2 Average Daily Volume a5 Ask Size
b Bid b2 Ask (Real-time) b3 Bid (Real-time)
b4 Book Value b6 Bid Size c Change & Percent Change
c1 Change c3 Commission c6 Change (Real-time)
c8 After Hours Change (Real-time) d Dividend/Share d1 Last Trade Date
d2 Trade Date e Earnings/Share e1 Error Indication (returned for symbol changed / invalid)
e7 EPS Estimate Current Year e8 EPS Estimate Next Year e9 EPS Estimate Next Quarter
f6 Float Shares g Day’s Low h Day’s High
j 52-week Low k 52-week High g1 Holdings Gain Percent
g3 Annualized Gain g4 Holdings Gain g5 Holdings Gain Percent (Real-time)
g6 Holdings Gain (Real-time) i More Info i5 Order Book (Real-time)
j1 Market Capitalization j3 Market Cap (Real-time) j4 EBITDA
j5 Change From 52-week Low j6 Percent Change From 52-week Low k1 Last Trade (Real-time) With Time
k2 Change Percent (Real-time) k3 Last Trade Size k4 Change From 52-week High
k5 Percebt Change From 52-week High l Last Trade (With Time) l1 Last Trade (Price Only)
l2 High Limit l3 Low Limit m Day’s Range
m2 Day’s Range (Real-time) m3 50-day Moving Average m4 200-day Moving Average
m5 Change From 200-day Moving Average m6 Percent Change From 200-day Moving Average m7 Change From 50-day Moving Average
m8 Percent Change From 50-day Moving Average n Name n4 Notes
o Open p Previous Close p1 Price Paid
p2 Change in Percent p5 Price/Sales p6 Price/Book
q Ex-Dividend Date r P/E Ratio r1 Dividend Pay Date
r2 P/E Ratio (Real-time) r5 PEG Ratio r6 Price/EPS Estimate Current Year
r7 Price/EPS Estimate Next Year s Symbol s1 Shares Owned
s7 Short Ratio t1 Last Trade Time t6 Trade Links
t7 Ticker Trend t8 1 yr Target Price v Volume
v1 Holdings Value v7 Holdings Value (Real-time) w 52-week Range
w1 Day’s Value Change w4 Day’s Value Change (Real-time) x Stock Exchange
y Dividend Yield

 

你可能感兴趣的:(api,python,Yahoo,Microsoft,Class,2010)