R

從 SEC.gov 自動導入 XBRL 格式的 10-Q 和 10-K 語句

  • December 27, 2018

我想從 SEC 網站自動讀取 XBRL 格式的財務報表。

例如來自 Apple 的 10-Q 文件: http ://www.sec.gov/Archives/edgar/data/320193/000119312515259935/aapl-20150627.xml

對於 XBRL 數據的轉換,我想使用 R 包 XBRL。

問題:

  1. SEC的文件名稱和網址是否標準化,以便我可以在工作中自動下載文件?還是我還需要在完整索引中查找網路地址(請參閱使用 SEC 文件結構的自動 10-K XBRL 數據抓取)?
  2. XBRL 標籤是否以這種方式與 10-Q /10-K 要求相結合,是標準化的,我可以期待標準化的標籤嗎?尤其是不是第一家公司標籤“銷售成本”,下一家公司“COGS”和第三家公司“收入成本”。
  3. 10-Q文件的時間段是標準化的3個月嗎?
  4. 10-Q 和 10-K 中有多少是 XBRL 格式的文件(大約百分比)?
  5. 是否有類似 XBRL 定義的東西在某處可用?申請時

inst <-“ http://www.sec.gov/Archives/edgar/data/320193/000119312515259935/aapl-20150627.xml

aapl_10q=xbrlDoAll(inst,詳細=真)

str(aapl_10q)

出現了這麼多奇怪的數據!

十條

  1. 沒有標準。公司可以隨意命名欄位。至少它似乎是可以容忍的。
  2. 我不了解 XBRL,但它可能會幫助您了解在送出的html版本的財務報表中,您可以通過查看表格單元格標籤中的欄位名稱來了解哪些行符合 GAAP。所有這些都以 gaap 開頭gaap_costOfGoodsSold。但這僅適用於 2011 年左右之後的報告。幸運的是,GAAP 的命名似乎在各公司之間是一致的。

首先,您不需要閱讀/解析 XBRL 格式的財務報表。

存在getFundamentals(ticker)由包 eodhistoricaldata-api ( https://www.npmjs.com/package/eodhistoricaldata-api ) 提供的方法。

圖書館返回季度(和年度)財務報表(損益表、資產負債表和現金流量表)。數據是標準化的,並以 JSON 格式提供。

例如:

"Highlights": {
   "MarketCapitalization": 54915055616,
   "MarketCapitalizationMln": "54915.0556",
   "EBITDA": 616286976,
   "PERatio": null,
   "PEGRatio": "-1.5700",
   "WallStreetTargetPrice": "321.8900",
   "BookValue": "26.2790",
   "DividendShare": null,
   "DividendYield": null,
   "EarningsShare": "-4.8500",
   "EPSEstimateCurrentYear": "-6.5600",
   "EPSEstimateNextYear": "-2.0000",
   "EPSEstimateNextQuarter": "-1.6700",
   "MostRecentQuarter": "2018-09-30",
   "ProfitMargin": "-0.1022",
   "OperatingMarginTTM": "-0.0710",
   "ReturnOnAssetsTTM": "-0.0271",
   "ReturnOnEquityTTM": "-0.3397",
   "RevenueTTM": "17523644416.00",
   "RevenuePerShareTTM": "103.3240",
   "QuarterlyRevenueGrowthYOY": "1.2860",
   "GrossProfitTTM": "2222487000.00",
   "DilutedEpsTTM": "-10.5600",
   "QuarterlyEarningsGrowthYOY": null
},
// ...
"Income_Statement": {
       "currency_symbol": "USD",
       "quarterly": {
           "2018-09-30": {
               "date": "2018-09-30",
               "filing_date": "2018-11-02",
               "researchDevelopment": "350848000.00",
               "effectOfAccountingCharges": null,
               "incomeBeforeTax": "271320000.00",
               "minorityInterest": "1344731000.00",
               "netIncome": "311516000.00",
               "sellingGeneralAdministrative": "729876000.00",
               "grossProfit": "1523665000.00",
               "ebit": "442941000.00",
               "operatingIncome": "442941000.00",
               "otherOperatingExpenses": null,
               "interestExpense": "-169858000.00",
               "extraordinaryItems": null,
               "nonRecurring": null,
               "otherItems": null,
               "incomeTaxExpense": "16647000.00",
               "totalRevenue": "6824413000.00",
               "totalOperatingExpenses": "6381472000.00",
               "costOfRevenue": "5300748000.00",
               "totalOtherIncomeExpenseNet": "-171621000.00",
               "discontinuedOperations": null,
               "netIncomeFromContinuingOps": "254673000.00",
               "netIncomeApplicableToCommonShares": "311516000.00"
           },
           // ...
"Balance_Sheet": {
       "currency_symbol": "USD",
       "quarterly": {
           "2018-09-30": {
               "date": "2018-09-30",
               "filing_date": "2018-11-02",
               "intangibleAssets": "291476000.00",
               "totalLiab": "23409144000.00",
               "totalStockholderEquity": "4508838000.00",
               "deferredLongTermLiab": "0.00",
               "otherCurrentLiab": "2266778000.00",
               "totalAssets": "29262713000.00",
               "commonStock": "171000.00",
               "otherCurrentAssets": "158627000.00",
               "retainedEarnings": "-5457315000.00",
               "otherLiab": "2285172000.00",
               "goodWill": "65226000.00",
               "otherAssets": "1233979000.00",
               "cash": "2967504000.00",
               "totalCurrentLiabilities": "9775324000.00",
               "shortLongTermDebt": "2106538000.00",
               "otherStockholderEquity": "8271000.00",
               "propertyPlantEquipment": "19733969000.00",
               "totalCurrentAssets": "7920491000.00",
               "longTermInvestments": "17572000.00",
               "netTangibleAssets": "4152136000.00",
               "shortTermInvestments": "0.00",
               "netReceivables": "1155001000.00",
               "longTermDebt": "9726589000.00",
               "inventory": "3314127000.00",
               "accountsPayable": "3596984000.00",
               "totalPermanentEquity": "0.00",
               "noncontrollingInterestInConsolidatedEntity": "0.00",
               "temporaryEquityRedeemableNoncontrollingInterests": "0.00",
               "accumulatedOtherComprehensiveIncome": "0.00",
               "additionalPaidInCapital": "0.00",
               "commonStockTotalEquity": "0.00",
               "preferredStockTotalEquity": "0.00",
               "retainedEarningsTotalEquity": "0.00",
               "treasuryStock": "0.00"
           },
           // ...
"Cash_Flow": {
       "currency_symbol": "USD",
       "quarterly": {
           "2018-09-30": {
               "date": "2018-09-30",
               "filing_date": "2018-11-02",
               "investments": null,
               "changeToLiabilities": "895197000.00",
               "totalCashflowsFromInvestingActivities": "-560965000.00",
               "netBorrowings": "-221931000.00",
               "totalCashFromFinancingActivities": "-84218000.00",
               "changeToOperatingActivities": "98770000.00",
               "netIncome": "311516000.00",
               "changeInCash": "739728000.00",
               "totalCashFromOperatingActivities": "1391281000.00",
               "depreciation": "502825000.00",
               "otherCashflowsFromInvestingActivities": "128600000.00",
               "dividendsPaid": "0.00",
               "changeToInventory": "-55055000.00",
               "changeToAccountReceivables": "-587594000.00",
               "salePurchaseOfStock": "0.00",
               "otherCashflowsFromFinancingActivities": "42839000.00",
               "changeToNetincome": "179168000.00",
               "capitalExpenditures": "-559765000.00"
           },

該包支持客戶端(React、React Native、Angular、Vue 等)和伺服器端(Node.js 等)JavaScript。

引用自:https://quant.stackexchange.com/questions/20649