2017年7月3日 星期一

Using the Yahoo Finance API for CSV(Yahoo已關閉服務--不能用了)



EXCEL 的讀法

在儲存格使用下面函式

台股

=NUMBERVALUE(WEBSERVICE("http://download.finance.yahoo.com/d/quotes.csv?s=2412.TW&f=l1"))

美股


=NUMBERVALUE(WEBSERVICE("http://download.finance.yahoo.com/d/quotes.csv?s=KO&f=l1"))


上面 f=XXX 即為格式,可以參考


--------------------------------
文章來源:
https://www.ptt.cc/bbs/Foreign_Inv/M.1498653773.A.3BA.html



------------------

How the Free Yahoo Finance API Works
Yahoo finance provides a great and simple way to download free stock quotes. This service returns stock data in a CSV. (comma delimited format, you can just open it in Excel if you like)
The service Yahoo finance provides for free stock quotes is REST based. (love REST based stuff) So all you need to do is assemble the URL you want and it will give you the data your looking for.
The API lets you specify multiple symbols to download with a maximum of 200 per call. (You can make multiple calls, but if you call too fast it will lock your IP so be warned)

How to call the free Yahoo Finance API
The base url your going to call is http://finance.yahoo.com/d/quotes.csv
Then you add a ?s= and the stock symbols your interested in such as APPL, GOOG and MSFT like so
http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+MSFT
Then you specify the info you want. There is a large list of stuff you can specify, just look at the list below for more info.
http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+MSFT&f=nab
This will get the name of the stock, the ask price and bid price (the “nab” = name,ask and bid)

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






沒有留言:

張貼留言