<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pablo Martínez on Medium]]></title>
        <description><![CDATA[Stories by Pablo Martínez on Medium]]></description>
        <link>https://medium.com/@pabloompg?source=rss-95aa21580d26------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PevdBJxdtHLVJf7r</url>
            <title>Stories by Pablo Martínez on Medium</title>
            <link>https://medium.com/@pabloompg?source=rss-95aa21580d26------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 02:49:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pabloompg/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[XBRL at Clarity AI]]></title>
            <link>https://medium.com/clarityai-engineering/xbrl-at-clarity-ai-305f26624892?source=rss-95aa21580d26------2</link>
            <guid isPermaLink="false">https://medium.com/p/305f26624892</guid>
            <dc:creator><![CDATA[Pablo Martínez]]></dc:creator>
            <pubDate>Thu, 08 Jul 2021 08:48:54 GMT</pubDate>
            <atom:updated>2021-07-08T10:19:02.820Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*-Kmy96P747JZlLjbIgkXYw.png" /></figure><p>At <a href="https://clarity.ai/">Clarity AI</a>, we want to make it easier for investors to allocate their capital towards companies which have a positive impact on society. To achieve this goal, we need data to feed our AI models and web app. Thus, we are always searching for new, good quality data sources. That is where XBRL enters into the equation.</p><p>XBRL (eXtensible Business Reporting Language) is a freely available and global framework for exchanging business information. It is XML-based and uses the XML syntax and related XML technologies. <a href="https://www.sec.gov/">SEC</a> (US Securities and Exchange Commission) requires all American public companies to fill their reports using XBRL and makes this information available to the public.</p><p>XBRL is a standard that can be tough to understand for beginners. The standard specifications can be found here:</p><ul><li><a href="https://specifications.xbrl.org/specifications.html">https://specifications.xbrl.org/specifications.html</a>.</li></ul><p>I also found this book by the creators of the standard very useful:</p><ul><li><a href="https://www.springer.com/gp/book/9783642014369">https://www.springer.com/gp/book/9783642014369</a></li></ul><p>Our goal in this article is to share some of our learnings while incorporating XBRL into our data pipelines. Hopefully, you will find this article a good starting point to further progress on your understanding of XBRL and how to access all this publicly available, good quality data.</p><p>Let’s first try to understand a specific filing. Let’s take Apple’s annual report from 2020, which can be found <a href="https://www.sec.gov/Archives/edgar/data/0000320193/000032019320000096/0000320193-20-000096-index.htm">here</a>. As you can see, this report has 6 xml documents attached:</p><ul><li><a href="https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926_htm.xml"><strong>Instance document</strong></a>: This is the document containing the information. The information is divided into <em>concepts</em>. A <em>concept </em>is a small piece of information containing a value, concept name, etc. (we’ll dive further into concepts later on).</li><li><a href="https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926_cal.xml"><strong>Calculation linkbase</strong></a>: The xml document containing formulas to verify <em>concepts</em> that are not direct. For example, GrossProfit is a calculated <em>concept</em>: GrossProfit = Revenue — CostOfGoodsSold. The instance document contains all three concepts, and the calculation linkbase is used to verify that the GrossProfit <em>concept</em> reported in the instance document is right.</li><li><a href="https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926_def.xml"><strong>Definition linkbase</strong></a>: This linkbase is used to create associations between <em>concepts</em>. We might have a generic concept like performanceMeasureswith 3 children: NetIncome, NetIncomeBeforeTaxand NetIncomeAfterTax.</li><li><a href="https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926_pre.xml"><strong>Presentation linkbase</strong></a>: The presentation linkbase is used as a guide for the creation of user interfaces, rendering, or visualization. It also creates associations between concepts. This linkbase specifies how a user interface should display the <em>concepts</em> so that it follows the conventions and standards of business reporting.</li><li><a href="https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926_lab.xml"><strong>Label linkbase</strong></a>: The label linkbase provides a human readable label for most common concepts. There cannot be duplicated labels for the same concept. An example would be the <em>concept</em> with name RevenueFromContractWithCustomerExcludingAssesedTax, whose label is NetSales.</li><li><a href="https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/aapl-20200926.xsd"><strong>Schema document</strong></a>: The schema document expresses how instance documents and taxonomies are to be built. The schema document inherits and extends other taxonomies. Two compulsory taxonomies that companies need to report to SEC are <a href="https://xbrl.sec.gov/dei/2020/dei-2020-01-31.xsd"><em>dei</em></a> (used for company-related information such as address or trading symbol) and <a href="https://xbrl.fasb.org/us-gaap/2021/elts/us-gaap-2021-01-31.xsd"><em>us-gaap</em></a><em> </em>(used for financial reporting)<em>. </em>Companies can also create their own taxonomies to report <em>concepts</em> which are unique to their business. As an example, Apple has its own taxonomy called <em>appl.</em></li></ul><h3>Warning</h3><p>We are mainly going to focus on understanding the <strong>instance document</strong>. However, to make a good parsing of XBRL you should understand all 6 xml files. Explaining all 6 files is beyond the scope of this article and we suggest that you dive into the official standards if your goal is to incorporate XBRL data into your systems after reading this article. Some other good article reads are:</p><ul><li><a href="https://manusimidt.dev/2021-07/xbrl-explained">https://manusimidt.dev/2021-07/xbrl-explained</a></li><li><a href="https://manusimidt.dev/2021-05/what-is-xlink">https://manusimidt.dev/2021-05/what-is-xlink</a></li><li><a href="https://manusimidt.dev/2021-05/xbrl-from-the-bottom-up">https://manusimidt.dev/2021-05/xbrl-from-the-bottom-up</a></li></ul><h3>Namespaces and schemas</h3><p>Let’s see a few examples of how all this data is related. The <strong>instance document</strong> starts defining the <a href="https://en.wikipedia.org/wiki/XML_namespace">namespaces</a> it will use:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsnipit.io%2Fembed%2F54649&amp;dntp=1&amp;display_name=Snipit&amp;url=https%3A%2F%2Fsnipit.io%2Flists%2F17014%2F54649&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=snipit" width="800" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf4b7f1e5a89aeb7a35417c6d52d2fad/href">https://medium.com/media/cf4b7f1e5a89aeb7a35417c6d52d2fad/href</a></iframe><p>Bare in mind these are not links, they are <a href="https://en.wikipedia.org/wiki/XML_namespace">namespaces</a>. To be able to download the taxonomy related to each namespace, we need to go to the schemaRef or <strong>Schema document</strong>, which imports the taxonomies:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsnipit.io%2Fembed%2F54650&amp;dntp=1&amp;display_name=Snipit&amp;url=https%3A%2F%2Fsnipit.io%2Flists%2F17014%2F54650&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=snipit" width="800" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa8faa6a03af4899e6b00b5642bc2dd4/href">https://medium.com/media/aa8faa6a03af4899e6b00b5642bc2dd4/href</a></iframe><h3>Concepts and data</h3><p>Let’s come back to the <strong>instance document. </strong>Just after defining the namespaces, we have <em>context items </em>and<em> concepts:</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsnipit.io%2Fembed%2F54651&amp;dntp=1&amp;display_name=Snipit&amp;url=https%3A%2F%2Fsnipit.io%2Flists%2F17014%2F54651&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=snipit" width="800" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0c5805a7cb617e681e7ef600d4865e8/href">https://medium.com/media/a0c5805a7cb617e681e7ef600d4865e8/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsnipit.io%2Fembed%2F54654&amp;dntp=1&amp;display_name=Snipit&amp;url=https%3A%2F%2Fsnipit.io%2Flists%2F17014%2F54654&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=snipit" width="800" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf60dc373cea13a222ce06d28135e546/href">https://medium.com/media/bf60dc373cea13a222ce06d28135e546/href</a></iframe><p>Each concept can only have one context, while contexts can have many concepts associated with them. We can later on link the <em>concept</em> with the rest of the xml files to get more information regarding a specific concept.</p><p>So far so good. We now understand the structure of an XBRL submission. What now? We would like to transform all this sparse data throughout different xml files into a pandas dataframe we can work with. At the end of the day, our goal is to generate a pandas dataframe which looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtmlBTv-yiM2dfw1dkTtZw.png" /></figure><p>To achieve this goal we have used an open source library to which we have contributed: <a href="https://github.com/manusimidt/py-xbrl">https://github.com/manusimidt/py-xbrl.</a> This library simplifies the parsing of XBRL submissions substantially.</p><h3>The tricky part</h3><p>However there is one tricky part we have not yet spoken about. The most difficult part when parsing an XBRL submission and where most people fail to accomplish their goals (even the SEC itself has not been able to do it yet) is when dimensional concepts appear. Dimensional concepts can be better understood using an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*IGIKwiWYj5uHp7cwcqBMFQ.png" /></figure><p>Apple divides its Nate Sales by 5 different business lines. This information is shown in the <em>concept</em> as follows:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsnipit.io%2Fembed%2F54665&amp;dntp=1&amp;display_name=Snipit&amp;url=https%3A%2F%2Fsnipit.io%2Flists%2F17014%2F54665&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=snipit" width="800" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/98f0a85057473952d509bdf526d4688f/href">https://medium.com/media/98f0a85057473952d509bdf526d4688f/href</a></iframe><p>which references the following <em>context:</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsnipit.io%2Fembed%2F54661&amp;dntp=1&amp;display_name=Snipit&amp;url=https%3A%2F%2Fsnipit.io%2Flists%2F17014%2F54661&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=snipit" width="800" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c88bdd2f6118fd2b8cde0763d0d7fe73/href">https://medium.com/media/c88bdd2f6118fd2b8cde0763d0d7fe73/href</a></iframe><p>The <em>context</em> has a segment attribute which specifies that the <em>concepts</em> which reference this <em>context</em> are part of a dimension. This gets even more complicated as Apple then divides each Revenue not only by business but by continent too.</p><h3><strong>Verify XBRL data quality</strong></h3><p>You can verify that the data you get after parsing a submission is right. To do so you can either use SEC’s <a href="https://www.sec.gov/cgi-bin/viewer?action=view&amp;cik=320193&amp;accession_number=0000320193-20-000096&amp;xbrl_type=v">interactive data</a> or search it on Yahoo Financials or any other freely available data source.</p><p>SEC offers free XBRL generated datasets every quarter <a href="https://www.sec.gov/dera/data/financial-statement-data-sets.html">here</a>. I can imagine their data set generation process uses some of the same ideas as the open source library we have used. However, their datasets fail to determine if a concept is part of a dimension (a child) or not. For example, they provide 6 different values for Net Sales for Apple’s 2020 report, without specifying the segments anywhere. This makes most of the data provided in this datasets useless for many use-cases, as there is no way to differentiate which of the 6 values is the parent.</p><p>At this moment, if you want to access all this data you can either buy it from data vendors or parse all XBRL fillings yourself, for which we, once again, suggest to use this open source library:</p><ul><li><a href="https://github.com/manusimidt/py-xbrl">https://github.com/manusimidt/py-xbrl</a></li></ul><h3>Thank you</h3><p>At Clarity AI we want to thank <a href="https://manusimidt.dev/">Manuel Schmidt</a>, who has not only created a great XBRL parsing library, but also helped us understood the hidden details of XBRL. Without him, we would have struggled a lot more to accomplish our goals.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=305f26624892" width="1" height="1" alt=""><hr><p><a href="https://medium.com/clarityai-engineering/xbrl-at-clarity-ai-305f26624892">XBRL at Clarity AI</a> was originally published in <a href="https://medium.com/clarityai-engineering">Clarity AI Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>