AFFA II

From EIK wiki

Meeskond

  • Madis Allikmaa
  • Ranno Rass
  • Marek Leinjärv

XML

XML fail on loodud õppeaines Programmeerimine C# keeles loodud projekti AFFA (Automated Financial and Fundamental Analysis) jaoks sobilikus formaadis. Antud XML-i suudab automaatselt genereerida AFFA edasiarendatud versioon, mis tõmbab andmed internetist andmepakkujalt (antud juhul YCharts.com) ning genereerib vastavalt tõmmatud andmetele XML faili.

Andmete näol on tegemist ettevõtte finantsandmetega (antud näite puhul Microsoft). Finantsaruanded võivad sisaldada ühte või mitut aruannet (tavapärane on kasumiaruanne, bilanss ja rahavoogude aruanne või tulenevalt algallikast saadetakse need üksikult eraldi failides, mistõttu on osade allikate (nagu YCharts) puhul tavaline, et finantsaruanded sisaldavad vaid ühte aruannet korraga). Finantsaruannetel on tüüp, mis määrab kindlaks, kas tegemist on konsolideeritud (kõik ettevõtete grupi andmed kokku võetult - antud juhul on kõik konsolideeritud), emaettevõtte või hoopis mõne tütarettevõtte andmetega. Kuna saadud andmeid tuleb järeltöödelda, on vaja, et iga aruanne eraldi sisaldaks viidet ettevõtte aktsiasümbolile ning ka aruande kuupäevale (finantsaruanded võivad teoreetiliselt sisaldada mitut sama üksikut aruannet lihtsalt erineva perioodi kohta). Iga aruanne koosneb erinevatest kirjetest (sisuliselt read), mis on aga andmebaasi salvestamiseks vaja transformeerida veergudeks, et hilisemad päringud ja töötlus oleks lihtsam. Antud XML fail sisaldab kogu kättesaadavat finantsandmestikku ettevõtte Microsoft kohta ning demonstreerib juhtumeid, kus finantsaruanded võivad sisaldada mitut või vaid ühte aruannet ning iga aruanne võib sisaldada erineval hulgal kirjeid.

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="style.xslt"?>
<database>
  <financial_statements type="consolidated">
    <income_statement symbol="MSFT" date="2012-09-30">
      <column name="is_revenue" multiplier="million" unit="monetary" currency="USD">16008</column>
      <column name="is_cost_of_revenue" multiplier="million" unit="monetary" currency="USD">4168</column>
      <column name="is_gross_profit" multiplier="million" unit="monetary" currency="USD">11840</column>
      <column name="is_rd_expense" multiplier="million" unit="monetary" currency="USD">2460</column>
      <column name="is_selling_general_admin_expense" multiplier="million" unit="monetary" currency="USD">4072</column>
      <column name="is_total_operating_expenses" multiplier="million" unit="monetary" currency="USD">10700</column>
      <column name="is_operating_income" multiplier="million" unit="monetary" currency="USD">5308</column>
      <column name="is_non_operating_income" multiplier="million" unit="monetary" currency="USD">226</column>
      <column name="is_pretax_income" multiplier="million" unit="monetary" currency="USD">5534</column>
      <column name="is_provision_for_income_taxes" multiplier="million" unit="monetary" currency="USD">1068</column>
      <column name="is_income_after_tax" multiplier="million" unit="monetary" currency="USD">4466</column>
      <column name="is_income_before_disc_operations" multiplier="million" unit="monetary" currency="USD">4466</column>
      <column name="is_net_income" multiplier="million" unit="monetary" currency="USD">4466</column>
      <column name="is_average_shares_diluted_eps" multiplier="million" unit="count">8494</column>
      <column name="is_average_shares_basic_eps" multiplier="million" unit="count">8396</column>
      <column name="is_eps_basic" multiplier="none" unit="monetary" currency="USD">0.53</column>
      <column name="is_eps_diluted" multiplier="none" unit="monetary" currency="USD">0.53</column>
    </income_statement>
    <balance_sheet symbol="MSFT" date="2012-09-30">
      <column name="bs_cash_short_term_investments" multiplier="million" unit="monetary" currency="USD">66644</column>
      <column name="bs_receivables" multiplier="million" unit="monetary" currency="USD">9871</column>
      <column name="bs_inventory" multiplier="million" unit="monetary" currency="USD">1624</column>
      <column name="bs_other_current_assets" multiplier="million" unit="monetary" currency="USD">3860</column>
      <column name="bs_total_current_assets" multiplier="million" unit="monetary" currency="USD">84051</column>
      <column name="bs_gross_property_plant_equipment" multiplier="million" unit="monetary" currency="USD">19730</column>
      <column name="bs_accumulated_depreciation" multiplier="million" unit="monetary" currency="USD">11401</column>
      <column name="bs_net_property_plant_equipment" multiplier="million" unit="monetary" currency="USD">8329</column>
      <column name="bs_long_term_investments" multiplier="million" unit="monetary" currency="USD">10038</column>
      <column name="bs_goodwill_intangibles" multiplier="million" unit="monetary" currency="USD">17889</column>
      <column name="bs_other_long_term_assets" multiplier="million" unit="monetary" currency="USD">1569</column>
      <column name="bs_total_long_term_assets" multiplier="million" unit="monetary" currency="USD">37825</column>
      <column name="bs_total_assets" multiplier="million" unit="monetary" currency="USD">121876</column>
      <column name="bs_current_portion_of_long_term_debt" multiplier="million" unit="monetary" currency="USD">2236</column>
      <column name="bs_accounts_payable" multiplier="million" unit="monetary" currency="USD">3631</column>
      <column name="bs_accrued_expenses" multiplier="million" unit="monetary" currency="USD">2666</column>
      <column name="bs_other_current_liabilities" multiplier="million" unit="monetary" currency="USD">21607</column>
      <column name="bs_total_current_liabilities" multiplier="million" unit="monetary" currency="USD">31402</column>
      <column name="bs_total_long_term_debt" multiplier="million" unit="monetary" currency="USD">9714</column>
      <column name="bs_deferred_income_tax" multiplier="million" unit="monetary" currency="USD">2209</column>
      <column name="bs_other_long_term_liabilities" multiplier="million" unit="monetary" currency="USD">9715</column>
      <column name="bs_total_long_term_liabilities" multiplier="million" unit="monetary" currency="USD">21638</column>
      <column name="bs_total_liabilities" multiplier="million" unit="monetary" currency="USD">53040</column>
      <column name="bs_common_shares_outstanding" multiplier="million" unit="count">8422</column>
      <column name="bs_common_stock_net" multiplier="million" unit="monetary" currency="USD">66084</column>
      <column name="bs_retained_earnings" multiplier="million" unit="monetary" currency="USD">932</column>
      <column name="bs_shareholders_equity1" multiplier="million" unit="monetary" currency="USD">68836</column>
      <column name="bs_total_liabilities_shareholders_equity" multiplier="million" unit="monetary" currency="USD">121876</column>
    </balance_sheet>
    <cash_flow_statement symbol="MSFT" date="2012-09-30">
      <column name="cfs_net_income" multiplier="million" unit="monetary" currency="USD">4466</column>
      <column name="cfs_depreciation_depletion_amortization" multiplier="million" unit="monetary" currency="USD">710</column>
      <column name="cfs_other_non_cash_items" multiplier="million" unit="monetary" currency="USD">-86</column>
      <column name="cfs_total_non_cash_items" multiplier="million" unit="monetary" currency="USD">624</column>
      <column name="cfs_total_changes_in_assets_liabilities" multiplier="million" unit="monetary" currency="USD">3394</column>
      <column name="cfs_net_cash_from_operating_activities" multiplier="million" unit="monetary" currency="USD">8484</column>
      <column name="cfs_capital_expenditures" multiplier="million" unit="monetary" currency="USD">-603</column>
      <column name="cfs_acquisitions_divestitures" multiplier="million" unit="monetary" currency="USD">-1145</column>
      <column name="cfs_investments" multiplier="million" unit="monetary" currency="USD">-5572</column>
      <column name="cfs_other_investing_activities" multiplier="million" unit="monetary" currency="USD">-399</column>
      <column name="cfs_net_cash_from_investing_activities" multiplier="million" unit="monetary" currency="USD">-7719</column>
      <column name="cfs_equity_issued" multiplier="million" unit="monetary" currency="USD">-1215</column>
      <column name="cfs_dividends_paid" multiplier="million" unit="monetary" currency="USD">-1676</column>
      <column name="cfs_other_financing_activities" multiplier="million" unit="monetary" currency="USD">177</column>
      <column name="cfs_net_cash_from_financing_activities" multiplier="million" unit="monetary" currency="USD">-2714</column>
      <column name="cfs_foreign_exchange_effects" multiplier="million" unit="monetary" currency="USD">47</column>
      <column name="cfs_net_change_in_cash_equivalents" multiplier="million" unit="monetary" currency="USD">-1902</column>
      <column name="cfs_cash_beginning_of_period" multiplier="million" unit="monetary" currency="USD">6938</column>
      <column name="cfs_cash_end_of_period" multiplier="million" unit="monetary" currency="USD">5036</column>
    </cash_flow_statement>
  </financial_statements>
</database>

XMLi skeem XSD

Tegemist on automaatselt genereeritud skeemifailiga.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="database">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="financial_statements">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" name="income_statement">
                <xs:complexType mixed="true">
                  <xs:sequence minOccurs="0">
                    <xs:element maxOccurs="unbounded" name="column">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:decimal">
                            <xs:attribute name="name" type="xs:string" use="required" />
                            <xs:attribute name="multiplier" type="xs:string" use="required" />
                            <xs:attribute name="unit" type="xs:string" use="required" />
                            <xs:attribute name="currency" type="xs:string" use="optional" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="symbol" type="xs:string" use="required" />
                  <xs:attribute name="date" type="xs:date" use="required" />
                </xs:complexType>
              </xs:element>
              <xs:element minOccurs="0" name="balance_sheet">
                <xs:complexType mixed="true">
                  <xs:sequence minOccurs="0">
                    <xs:element maxOccurs="unbounded" name="column">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:decimal">
                            <xs:attribute name="name" type="xs:string" use="required" />
                            <xs:attribute name="multiplier" type="xs:string" use="required" />
                            <xs:attribute name="unit" type="xs:string" use="required" />
                            <xs:attribute name="currency" type="xs:string" use="optional" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="symbol" type="xs:string" use="required" />
                  <xs:attribute name="date" type="xs:date" use="required" />
                </xs:complexType>
              </xs:element>
              <xs:element minOccurs="0" name="cash_flow_statement">
                <xs:complexType mixed="true">
                  <xs:sequence minOccurs="0">
                    <xs:element maxOccurs="unbounded" name="column">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:decimal">
                            <xs:attribute name="name" type="xs:string" use="required" />
                            <xs:attribute name="multiplier" type="xs:string" use="required" />
                            <xs:attribute name="unit" type="xs:string" use="required" />
                            <xs:attribute name="currency" type="xs:string" use="required" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="symbol" type="xs:string" use="required" />
                  <xs:attribute name="date" type="xs:date" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="type" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XMLi skeem DTD

Tegemist on käsitsi loodud skeemifailiga.

<ELEMENT database (financial_statements+)>

<ELEMENT financial_statements (income_statement?, balance_sheet?, cash_flow_statement?)>

<ELEMENT income_statement (column*)>

<ELEMENT balance_sheet (column*)>

<ELEMENT cash_flow_statement (column*)>

<ELEMENT column (#PCDATA)>


<!ATTLIST financial_statements

    type #REQUIRED>

<!ATTLIST income_statement

    symbol (#PCDATA) #REQUIRED

    date (#PCDATA) #REQUIRED>

<!ATTLIST balance_sheet

    symbol (#PCDATA) #REQUIRED

    date (#PCDATA) #REQUIRED>

<!ATTLIST cash_flow_statement

    symbol (#PCDATA) #REQUIRED

    date (#PCDATA) #REQUIRED>

<!ATTLIST column

    name (#PCDATA) #REQUIRED

    multiplier (#PCDATA) #REQUIRED

    unit (#PCDATA) #REQUIRED
    currency (#PCDATA)>

XSLT

Antud stiilifail on loodud selleks, et kuvada kogu XML faili sisu HTML formaadis, kusjuures iga aruande kohta kuvatakse tabel, kus iga aruande olemasolev kirje moodustab tabelis ühe rea koos sinna juurde kuuluva infoga.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/">
    <html>
      <head>
        <title>Financial statements</title>
      </head>
      <body>
        
          <xsl:for-each select="/database/financial_statements">
            <h1>
              Financial statement type: <xsl:value-of select="@type"/>
            </h1>
            <xsl:for-each select="*">
              <h2>
                Statement: <xsl:value-of select="name()" />
              </h2>
              <h3>
                Symbol: <xsl:value-of select="@symbol" />
              </h3>
              <h4>
                Statement date: <xsl:value-of select="@date" />
              </h4>
              <table border="1">
                <tr>
                  <th>Row name</th>
                  <th>Value</th>
                  <th>Currency</th>
                  <th>Unit</th>
                  <th>Multiplier</th>
                </tr>
                <xsl:for-each select="*">
                  <tr>
                    <td>
                      <xsl:value-of select="@name" />
                    </td>
                    <td>
                      <xsl:value-of select="self::node()" />
                    </td>
                    <td>
                      <xsl:value-of select="@currency" />
                    </td>
                    <td>
                      <xsl:value-of select="@unit" />
                    </td>
                    <td>
                      <xsl:value-of select="@multiplier" />
                    </td>
                  </tr>
                </xsl:for-each>
              </table>
            </xsl:for-each>
            <hr />
          </xsl:for-each>
        
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Lõpptoode

Lõpptoode asub siin: [1]

Kasutusjuhend asub siin: [2]

Retsensioonid

Retsensioon meeskonna Bleh [3] XML faili kohta.
Retsensioon meeskonna REMS [4] XML faili kohta.
Retsensioon meeskonna X-Ladu [5] veebiteenuse kohta.
Retsensioon meeskonna V [6] veebiteenuse kohta.
Retsensioon meeskonna X-Ladu [7] klientrakenduse kohta.
Retsensioon meeskonna SaanEndagaHästiLäbi [8] klientrakenduse kohta.