Karan Sharma
15th November 2016
10k forms scraped from: https://www.sec.gov/.
# To parse XML documents
library(XBRL)
# To visualize results
library(plotly)
library(ggplot2)
# To analyze balance sheets
library(finstr)
# Data munging
library(dplyr)
# HTML Tables
library(htmlTable)
setwd("~/Work/BigDataAssignments/secgovanalyze")
#AMZN forms
amzn_url2015<-'http://localhost:8000/amzn/2015/amzn-20141231.xml'
amzn_url2016<- 'http://localhost:8000/amzn/2016/amzn-20151231.xml'
old_o <- options(stringsAsFactors = FALSE)
amzn_2015 <- xbrlDoAll(amzn_url2015)
amzn_2016 <- xbrlDoAll(amzn_url2016)
options(old_o)
amzn2015 <- xbrl_get_statements(amzn_2015)
amzn2016 <- xbrl_get_statements(amzn_2016)
amzn <- merge(amzn2015,amzn2016)
amznSOP <- merge(amzn2015$ConsolidatedStatementsOfOperations,amzn2016$ConsolidatedStatementsOfOperations)
amznBalanceSheet<- merge(amzn2015$ConsolidatedBalanceSheets,amzn2016$ConsolidatedBalanceSheets)
amznCashflow <- merge(amzn2015$ConsolidatedStatementsOfCashFlows,amzn2016$ConsolidatedStatementsOfCashFlows)
It's the ratio of current assests / current liabilities.
amznBalanceSheet %>% transmute(
date = endDate,
CurrentRatio = AssetsCurrent / LiabilitiesCurrent
)
date CurrentRatio
1 2013-12-31 1.071584
2 2014-12-31 1.115276
3 2015-12-31 1.075961
Inference : Amazon consistently had a ratio of 1.0 or greater which indicates that Amazon possesed more assets than liablities, which is a good sign for company's growth.
Consolidated Statement of Operations.
This dataset highlights the Revenue earned by Amazon v/s amount spent in activities like
marketing, admnistration expense, cost of goods and services sold, amazon fulfillment expense and other ops costs.
amznSOP_simple <- expose( amznSOP,
`Revenue` = 'SalesRevenueNet',
`Expenditure` = 'CostsAndExpenses'
)
print(amznSOP_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | 2012 | |
|---|---|---|---|---|
| Net Income (Loss) Attributable to Parent | 596 | -241 | 274 | -39 |
| Revenue | 107,006 | 88,988 | 74,452 | 61,093 |
| Expenditure | -104,773 | -88,810 | -73,707 | -60,417 |
| OtherNetIncomeLoss_ | -1,637 | -419 | -471 | -715 |
Inference: Amazon as a company is increasing it's revenue every year, but this is only possible with greater expenditure.
Bottomline: More the expenditure more is the revenue
This dataset highlights how the money is used in Amazon.
amznCashflow_simple <- expose( amznCashflow,
`Ops Activities` = 'NetCashProvidedByUsedInOperatingActivities',
`Investing` = 'NetCashProvidedByUsedInInvestingActivities',
`Financing` = 'NetCashProvidedByUsedInFinancingActivities'
)
print(amznCashflow_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | 2012 | |
|---|---|---|---|---|
| Cash and Cash Equivalents, Period Increase (Decrease) | 1,333 | 5,899 | 574 | 2,815 |
| Ops Activities | 10,728 | 7,324 | 4,927 | 4,258 |
| Investing | -6,450 | -7,607 | -7,102 | -3,595 |
| Financing | -3,763 | 4,432 | -539 | 2,259 |
| OtherCashAndCashEquivalentsPeriodIncreaseDecrease_ | -374 | -310 | -86 | -29 |
Inference: Amazon spends most of the money in Day to day operational activities, but invests some money in acquiring property plant, equipment, business interests, marketable services
This dataset highlights core components of Balance sheet of Amazon
amznBalanceSheet_simple<- expose( amznBalanceSheet,
# Assets
`Current Assets` = "AssetsCurrent",
`Noncurrent Assets` = other("Assets"),
# Liabilites and equity
`Current Liabilities` = "LiabilitiesCurrent",
`Stockholders Equity` = "StockholdersEquity"
)
print(amznBalanceSheet_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | |
|---|---|---|---|
| Assets | 654.44 | 545.05 | 401.59 |
| Current Assets | 364.74 | 313.27 | 246.25 |
| Noncurrent Assets | 289.70 | 231.78 | 155.34 |
| Liabilities and Equity | 654.44 | 545.05 | 401.59 |
| Current Liabilities | 338.99 | 280.89 | 229.80 |
| Stockholders Equity | 133.84 | 107.41 | 97.46 |
| OtherLiabilitiesAndStockholdersEquity_ | 181.61 | 156.75 | 74.33 |
plot_double_stacked_bar(amznBalanceSheet_simple)
plot_double_stacked_bar(proportional(amznBalanceSheet_simple))
#AAPL forms
aapl_url2015<-'http://localhost:8000/aapl/2015/aapl-20140927.xml'
aapl_url2016<- 'http://localhost:8000/aapl/2016/aapl-20150926.xml'
old_o <- options(stringsAsFactors = FALSE)
aapl_2015 <- xbrlDoAll(aapl_url2015)
aapl_2016 <- xbrlDoAll(aapl_url2016)
options(old_o)
aapl2015 <- xbrl_get_statements(aapl_2015)
aapl2016 <- xbrl_get_statements(aapl_2016)
aapl <- merge(aapl2015,aapl2016)
aaplBalanceSheet <- merge(aapl2015$StatementOfFinancialPositionClassified,aapl2016$StatementOfFinancialPositionClassified)
aaplCashFlow <- merge(aapl2015$StatementOfCashFlowsIndirect,aapl2016$StatementOfCashFlowsIndirect)
It's the ratio of current assests / current liabilities.
aaplBalanceSheet %>% transmute(
date = endDate,
CurrentRatio = AssetsCurrent / LiabilitiesCurrent
)
date CurrentRatio
1 2013-09-28 1.678639
2 2014-09-27 1.080113
3 2015-09-26 1.108771
Inference : Apple consistently had a ratio of 1.0 or greater which indicates that Apple possesed more assets than liablities, which is a good sign for company's growth.
Consolidated Statement of Income.
This dataset highlights the gross profit and operating expenses at Apple.
aaplIncome <- expose( aapl$StatementOfIncome,
`Op Exp` = 'OperatingIncomeLoss',
`Non Ops Exp` = 'NonoperatingIncomeExpense'
)
print(aaplIncome, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | 2012 | |
|---|---|---|---|---|
| Net Income (Loss) Attributable to Parent | 53,394 | 39,510 | 37,037 | 41,733 |
| Op Exp | 71,230 | 52,503 | 48,999 | 55,241 |
| Non Ops Exp | 1,285 | 980 | 1,156 | 522 |
| OtherNetIncomeLoss_ | -19,121 | -13,973 | -13,118 | -14,030 |
Inference: Apple as a company is increasing the net income while also increasing gross expenditure
This dataset highlights how the money is used in Amazon.
aaplCashflow_simple <- expose( aaplCashFlow,
`Ops Activities` = 'NetCashProvidedByUsedInOperatingActivitiesContinuingOperations',
`Investing` = 'NetCashProvidedByUsedInInvestingActivitiesContinuingOperations',
`Financing` = 'NetCashProvidedByUsedInFinancingActivitiesContinuingOperations'
)
print(aaplCashflow_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | 2012 | |
|---|---|---|---|---|
| Cash and Cash Equivalents, Period Increase (Decrease) | 7,276 | -415 | 3,513 | 931 |
| Ops Activities | -25,522 | -19,307 | -20,408 | -32,610 |
| Investing | -56,274 | -22,579 | -33,774 | -48,227 |
| Financing | -17,716 | -37,549 | -16,379 | -1,698 |
Inference: Apple has reduced the amount spent in Ops which is a good thing, indicating that a lot of automation is happening inside the company to reduce this cost. Apple has varied it's amount of investing in other avenues. Apple also earns a tiny amount from a lot of it's patents as shown in the last column.
This dataset highlights core components of Balance sheet of Apple
aaplBalanceSheet_simple<- expose( aaplBalanceSheet,
# Assets
`Current Assets` = "AssetsCurrent",
`Noncurrent Assets` = other("Assets"),
# Liabilites and equity
`Current Liabilities` = "LiabilitiesCurrent",
`Noncurrent Liabilities` = other(c("Liabilities", "CommitmentsAndContingencies")),
`Stockholders Equity` = "StockholdersEquity"
)
print(aaplBalanceSheet_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | |
|---|---|---|---|
| Assets | 290,479 | 231,839 | 207,000 |
| Current Assets | 89,378 | 68,531 | 73,286 |
| Noncurrent Assets | 201,101 | 163,308 | 133,714 |
| Liabilities and Equity | 290,479 | 231,839 | 207,000 |
| Current Liabilities | 80,610 | 63,448 | 43,658 |
| Noncurrent Liabilities | 90,514 | 56,844 | 39,793 |
| Stockholders Equity | 119,355 | 111,547 | 123,549 |
plot_double_stacked_bar(aaplBalanceSheet_simple)
plot_double_stacked_bar(proportional(aaplBalanceSheet_simple))
#Pepsi forms
pep_url2015 <-'http://localhost:8000/pep/2015/pep-20141227.xml'
pep_url2016 <-'http://localhost:8000/pep/2016/pep-20151226.xml'
old_o <- options(stringsAsFactors = FALSE)
pep_2015 <- xbrlDoAll(pep_url2015)
pep_2016 <- xbrlDoAll(pep_url2016)
options(old_o)
pep2015 <- xbrl_get_statements(pep_2015)
pep2016 <- xbrl_get_statements(pep_2016)
pepCashFlow <- merge(pep2015$ConsolidatedStatementOfCashFlows,pep2016$ConsolidatedStatementOfCashFlows)
pepIncomeStatement <- merge(pep2015$ConsolidatedStatementOfIncome,pep2016$ConsolidatedStatementOfIncome)
Consolidated Statement of Income.
This dataset highlights the gross income loss and operating expenses at Pepsi
pepIncomeStatement_simple <- expose( pepIncomeStatement,
`Op Exp` = 'OperatingIncomeLoss',
`Non Ops Exp` = 'pep_InterestIncomeAndOther'
)
print(pepIncomeStatement_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | 2012 | |
|---|---|---|---|---|
| Income (Loss) from Continuing Operations before Income Taxes, Extraordinary Items, Noncontrolling Interest | 7.442 | 8.757 | 8.891 | 8.304 |
| Op Exp | 8.353 | 9.581 | 9.705 | 9.112 |
| Non Ops Exp | 0.059 | 0.085 | 0.097 | 0.091 |
| OtherIncomeLossFromContinuingOperationsBeforeIncomeTaxesExtraordinaryItemsNoncontrollingInterest_ | -0.970 | -0.909 | -0.911 | -0.899 |
| Net Income (Loss) Attributable to Parent | 5.452 | 6.513 | 6.740 | 6.178 |
| OtherNetIncomeLoss_ | 5.452 | 6.513 | 6.740 | 6.178 |
Inference: Pepsi as a company is making losses
There's an interesting data point which is observed in the statements of Pepsi, which is $pep_Venezuelaimpairmentcharges.
Pepsi had to suffered huge losses due to this allegation.
pepIncomeStatement$pep_Venezuelaimpairmentcharges
[1] 0.000e+00 0.000e+00 0.000e+00 1.359e+09
This dataset highlights how the money is used in Pepsi.
pepCashflow_simple <- expose( pepCashFlow)
print(pepCashflow_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | 2012 | |
|---|---|---|---|---|
| Net Cash Provided by (Used in) Investing Activities | -35.69 | -49.37 | -26.25 | -30.05 |
| Net Cash Provided by (Used in) Financing Activities | -38.28 | -82.64 | -37.89 | -33.06 |
| Net Cash Provided by (Used in) Operating Activities | 105.80 | 105.06 | 96.88 | 84.79 |
Inference: Pepsi has not been able to minimise it's expenditure on Ops Activities. Perhaps if Pepsi focus on reducing this, it can generate more profits.
#NFLX forms
nflx_url2015<-'http://localhost:8000/nflx/2015/nflx-20131231.xml'
nflx_url2016<- 'http://localhost:8000/nflx/2016/nflx-20141231.xml'
old_o <- options(stringsAsFactors = FALSE)
nflx_2015 <- xbrlDoAll(nflx_url2015)
nflx_2016 <- xbrlDoAll(nflx_url2016)
options(old_o)
nflx2015 <- xbrl_get_statements(nflx_2015)
nflx2016 <- xbrl_get_statements(nflx_2016)
nflx <- merge(nflx2015,nflx2016)
nflxSOP <- merge(nflx2015$ConsolidatedStatementsOfOperations,nflx2016$ConsolidatedStatementsOfOperations)
nflxBalanceSheet<- merge(nflx2015$ConsolidatedBalanceSheets,nflx2016$ConsolidatedBalanceSheets)
nflxCashflow <- merge(nflx2015$ConsolidatedStatementsOfCashFlows,nflx2016$ConsolidatedStatementsOfCashFlows)
It's the ratio of current assests / current liabilities.
nflxBalanceSheet %>% transmute(
date = endDate,
CurrentRatio = AssetsCurrent / LiabilitiesCurrent
)
date CurrentRatio
1 2012-12-31 1.337047
2 2013-12-31 1.419905
3 2014-12-31 1.479625
Inference : Netflix consistently had a ratio of 1.0 or greater which indicates that Netflix possesed more assets than liablities, which is a good sign for company's growth.
Consolidated Statement of Operations.
This dataset highlights the Revenue earned by Netflix v/s amount spent in activities like
marketing, admnistration expense and other ops costs.
nflxSOP_simple <- expose( nflxSOP,
`Revenue` = 'Revenues',
`Expenditure` = 'NonoperatingIncomeExpense'
)
print(nflxSOP_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2014 | 2013 | 2012 | 2011 | |
|---|---|---|---|---|
| Net Income (Loss) Attributable to Parent | 2,667.99 | 1,124.03 | 171.52 | 2,261.26 |
| Revenue | 55,046.56 | 43,745.62 | 36,092.82 | 32,045.77 |
| Expenditure | -30.60 | -30.02 | 4.74 | 34.79 |
| OtherNetIncomeLoss_ | -52,347.97 | -42,591.57 | -35,926.04 | -29,819.30 |
Inference: Netflix as a company is increasing it's revenue every year, and the highlight is that expenditure hasn't increased significantly.
Bottomline: Netflix being purely an internet company, has the advantage of controlling the
expenditure while growing to lot of users and thus generating more revenue.
This dataset highlights how the money is used in Netflix.
nflxCashflow_simple <- expose( nflxCashflow,
`Ops Activities` = 'NetCashProvidedByUsedInOperatingActivities',
`Investing` = 'NetCashProvidedByUsedInInvestingActivities',
`Financing` = 'NetCashProvidedByUsedInFinancingActivities'
)
print(nflxCashflow_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2014 | 2013 | 2012 | 2011 | |
|---|---|---|---|---|
| Cash and Cash Equivalents, Period Increase (Decrease) | 5,086.43 | 3,146.74 | -2,177.62 | 3,135.54 |
| Ops Activities | -5,171.15 | -1,269.75 | -127.18 | -1,345.40 |
| Investing | -428.66 | -2,559.68 | -2,447.40 | -2,658.14 |
| Financing | 5,417.12 | 4,762.64 | 55.89 | 2,616.56 |
| OtherCashAndCashEquivalentsPeriodIncreaseDecrease_ | -66.86 | -34.53 | -1.97 | 0.00 |
Inference: Netflix spends most of the money in Day to day operational activities, but invests some money in acquiring content library, additions to streaming content and payment of equipments like servers.
This dataset highlights core components of Balance sheet of Netflix
nflxBalanceSheet_simple<- expose( nflxBalanceSheet,
# Assets
`Current Assets` = "AssetsCurrent",
`Noncurrent Assets` = other("Assets"),
# Liabilites and equity
`Current Liabilities` = "LiabilitiesCurrent",
`Stockholders Equity` = "StockholdersEquity"
)
print(nflxBalanceSheet_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2014 | 2013 | 2012 | |
|---|---|---|---|
| Assets | 70,566.51 | 54,125.63 | 39,678.90 |
| Current Assets | 39,404.69 | 30,587.63 | 22,407.91 |
| Noncurrent Assets | 31,161.82 | 23,538.00 | 17,270.99 |
| Liabilities and Equity | 70,566.51 | 54,125.63 | 39,678.90 |
| Current Liabilities | 26,631.54 | 21,542.03 | 16,759.26 |
| Stockholders Equity | 18,577.08 | 13,335.61 | 7,446.73 |
| OtherLiabilitiesAndStockholdersEquity_ | 25,357.89 | 19,247.99 | 15,472.91 |
plot_double_stacked_bar(nflxBalanceSheet_simple)
plot_double_stacked_bar(proportional(nflxBalanceSheet_simple))
#WMT forms
wmt_url2015<-'http://localhost:8000/wmt/2015/wmt-20140131.xml'
wmt_url2016<- 'http://localhost:8000/wmt/2016/wmt-20150131.xml'
old_o <- options(stringsAsFactors = FALSE)
wmt_2015 <- xbrlDoAll(wmt_url2015)
wmt_2016 <- xbrlDoAll(wmt_url2016)
options(old_o)
wmt2015 <- xbrl_get_statements(wmt_2015)
wmt2016 <- xbrl_get_statements(wmt_2016)
wmtCashFlow <- merge(wmt2015$ConsolidatedStatementsOfCashFlowsAudited, wmt2016$ConsolidatedStatementsOfCashFlows)
wmtIncomeStatement <- merge(wmt2015$ConsolidatedStatementsOfIncomeAudited,wmt2016$ConsolidatedStatementsOfIncome)
wmtBalanceSheet <- merge(wmt2015$ConsolidatedBalanceSheetsAudited,wmt2016$ConsolidatedBalanceSheets)

It's the ratio of current assests / current liabilities.
wmtBalanceSheet %>% transmute(
date = endDate,
CurrentRatio = AssetsCurrent / LiabilitiesCurrent
)
date CurrentRatio
1 2013-01-31 0.8346097
2 2014-01-31 0.8823275
3 2015-01-31 0.9694509
Inference : Walmart consistently had a ratio of less than 1.0 which indicates that Walmart possesed more liablities than assets, which is not a good sign for company's growth. But given Walmart, which is the largest employer in the world, this case is an exception as it even makes it to Rank 1 of Fortune500 list of companies.
This dataset highlights how the money is used in Netflix.
wmtCashflow_simple <- expose( wmtCashFlow,
`Ops Activities` = 'NetCashProvidedByUsedInOperatingActivities',
`Investing` = 'NetCashProvidedByUsedInInvestingActivities',
`Financing` = 'NetCashProvidedByUsedInFinancingActivities'
)
print(wmtCashflow_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | 2012 | |
|---|---|---|---|---|
| Cash and Cash Equivalents, Period Increase (Decrease) | 1.854 | -0.500 | 1.231 | -0.845 |
| Ops Activities | -5.064 | -9.845 | -9.817 | -8.561 |
| Investing | -11.125 | -12.298 | -12.611 | -16.609 |
| Financing | -15.071 | -11.017 | -11.972 | -8.458 |
| OtherCashAndCashEquivalentsPeriodIncreaseDecrease_ | -0.514 | -0.442 | 0.223 | -0.033 |
Inference: Netflix spends most of the money in finance activities, mainly because it's a high performant stock in the Wall Street and so there are regular payments of dividends by Walmart.
Walmart has managed to keep it's Ops expenditure to a minimum which is a good thing, indicating automating is slowly coming into picture to reduce costs.
This dataset highlights core components of Balance sheet of Netflix
wmtBalanceSheet_simple<- expose( wmtBalanceSheet,
# Assets
`Current Assets` = "AssetsCurrent",
`Noncurrent Assets` = other("Assets"),
# Liabilites and equity
`Current Liabilities` = "LiabilitiesCurrent",
`Stockholders Equity` = "StockholdersEquity"
)
print(wmtBalanceSheet_simple, html = TRUE, big.mark = ",", dateFormat = "%Y")
| 2015 | 2014 | 2013 | |
|---|---|---|---|
| Assets | 203,706 | 204,751 | 203,105 |
| Current Assets | 63,278 | 61,185 | 59,940 |
| Noncurrent Assets | 140,428 | 143,566 | 143,165 |
| Liabilities and Equity | 203,706 | 204,751 | 203,105 |
| Current Liabilities | 65,272 | 69,345 | 71,818 |
| Stockholders Equity | 81,394 | 76,255 | 76,343 |
| OtherLiabilitiesAndStockholdersEquity_ | 57,040 | 59,151 | 54,944 |
plot_double_stacked_bar(wmtBalanceSheet_simple)
plot_double_stacked_bar(proportional(wmtBalanceSheet_simple))