Two jobs we have to do.
1) to get a specific company financial data
2) to show several companies' financial ratio
--------------------------------------------------------------
Let's start do the first job.
#basic setting and get an object
library(quantmod)
nvdia=getFinancials("NVDA", auto.assign = FALSE)
#Annual and Quarter Balance sheet
nvdia.BS.A=viewFinancials(nvdia, type='BS', period='A')
nvdia.BS.Q=viewFinancials(nvdia, type='BS', period='Q')
#Income Statement
nvdia.IS.A = viewFinancials(nvdia, type='IS', period='A')
nvdia.IS.Q = viewFinancials(nvdia, type='IS', period='Q')
#cash flow
nvdia.CF.A = viewFinancials(nvdia, type='CF', period='A')
nvdia.CF.Q = viewFinancials(nvdia, type='CF', period='Q')
#check netincome
rownames(nvdia.IS.A)
[1] "Revenue"
[2] "Other Revenue, Total"
[3] "Total Revenue"
[4] "Cost of Revenue, Total"
[5] "Gross Profit"
------
[25] "Net Income"
-------
[48] "Basic Normalized EPS"
[49] "Diluted Normalized EPS"
Now, number 25 abbreviates netincome
nvdia.IS.A[25,]
2017-01-29 2016-01-31 2015-01-25 2014-01-26
1666.00 614.00 630.59 439.99
------------------------------------------------------------------------------
2) Let's show several companies' financial status using yahooQF
#make a list you want to find out
Ratios <- ales="" c="" div="" nbsp="" rice="" yahooqf="">->
"P/E Ratio",
"Price/EPS Estimate Next Year",
"PEG Ratio",
"Dividend Yield",
"Market Capitalization"))
#make a list of companies you want to look at
codes <- c="" div="">->
#combine and get rid of date
FinancialRatio<- codes="" collapse=";" getquote="" paste="" sep="" what="Ratios)</div">->
FinancialRatio <- data.frame="" div="" financialratio="" inancialratio="" length="" ymbol="codes,">->
FinancialRatio
Symbol Price.Sales P.E.Ratio
GOOG GOOG 6.57 30.31
IBM IBM 1.90 13.06
MSFT MSFT 6.06 30.64
ORCL ORCL 4.94 21.31
NVDA NVDA 8.89 41.49
AAPL AAPL 3.46 17.60
Price.EPS.Estimate.Next.Year PEG.Ratio
GOOG 23.29 1.38
IBM 11.39 4.57
MSFT 21.16 2.41
ORCL 15.92 1.95
NVDA 31.55 3.14
AAPL 14.26 1.74
Dividend.Yield Market.Capitalization
GOOG N/A 627.25B
IBM 3.74 149.23B
MSFT 2.28 536.05B
ORCL 1.42 185.37B
NVDA 0.54 62.81B
AAPL 1.59 769.04B
That's all
-reference-
http://blog.naver.com/htk1019/220913777513
0 Comment to "How to collect financial data in R"
Post a Comment