Ejemplo n.º 1
0
def ex():
    print 'Calculating key accounting figures for Apple (2012 filing)'
    ticker = 'aapl'
    # filings = edgar.get_filings(symbol=ticker, filing_type='10-Q')
    # filing = filings[filings.bisect(date(2013, 1, 23)) - 1]
    # print filing

    url = 'http://www.sec.gov/Archives/edgar/data/320193/000119312513022339/aapl-20121229.xml'
    doc = XBRLDocument.gets_XBRL_from_edgar(xbrl_url=url)
    # filing = Filing(filing_date=None, document=xbrl_document, next_filing=None)

    tags = [
        # short-name, tagname, 'd/i' = duration or instance
        ['assets', 'us-gaap:Assets', 'i'],
        ['liabilites', 'us-gaap:Liabilities', 'i'],
        ['shares', 'dei:EntityCommonStockSharesOutstanding', 'i'],
        ['equity', 'us-gaap:StockholdersEquity', 'i'],
        ['eps', 'us-gaap:EarningsPerShareDiluted', 'd']
    ]
    out = {}
    for tag in tags:
        context = DurationContext if tag[2] == 'd' else InstantContext
        metric_params = XBRLMetricParams(possible_tags=[tag[1]],
                                         context_type=context)
        out[tag[0]] = doc.latest_metric_value(metric_params=metric_params)
    out['book'] = out['assets'] - out['liabilites']
    out['book-ps'] = out['book'] / out['shares']
    for k in out:
        print k, ': ', out[k]
Ejemplo n.º 2
0
def ex():
    print 'Calculating key accounting figures for Apple (2012 filing)'
    ticker = 'aapl'
    # filings = edgar.get_filings(symbol=ticker, filing_type='10-Q')
    # filing = filings[filings.bisect(date(2013, 1, 23)) - 1]
    # print filing

    url = 'http://www.sec.gov/Archives/edgar/data/320193/000119312513022339/aapl-20121229.xml'
    doc = XBRLDocument.gets_XBRL_from_edgar(xbrl_url=url)
    # filing = Filing(filing_date=None, document=xbrl_document, next_filing=None)

    tags = [
        # short-name, tagname, 'd/i' = duration or instance
        ['assets', 'us-gaap:Assets', 'i'],
        ['liabilites', 'us-gaap:Liabilities', 'i'],
        ['shares', 'dei:EntityCommonStockSharesOutstanding', 'i'],
        ['equity', 'us-gaap:StockholdersEquity', 'i'],
        ['eps', 'us-gaap:EarningsPerShareDiluted', 'd']
        ]
    out = {}
    for tag in tags:
        context = DurationContext if tag[2] == 'd' else InstantContext
        metric_params = XBRLMetricParams(possible_tags=[tag[1]],
            context_type=context
            )
        out[tag[0]] = doc.latest_metric_value(metric_params=metric_params)
    out['book'] = out['assets'] - out['liabilites']
    out['book-ps'] = out['book'] / out['shares']
    for k in out:
        print k, ': ', out[k]
Ejemplo n.º 3
0
 def test_document_downloading(self):
     url = 'http://www.sec.gov/Archives/edgar/data/320193/000119312513022339/aapl-20121229.xml'
     test_filing_path = tests.asset_file_path('aapl-20121229.xml')
     with open(test_filing_path) as f:
         test_statement_xml_dict = xmltodict.parse(f.read())
         xbrl_dict = test_statement_xml_dict['xbrl']
     doc = XBRLDocument.gets_XBRL_from_edgar(xbrl_url=url)
     self.assertDictEqual(doc._xbrl_dict, xbrl_dict)
 def from_xbrl_url(cls, filing_date, xbrl_url):
     """constructor."""
     document = XBRLDocument.gets_XBRL_from_edgar(xbrl_url=xbrl_url)
     return cls(filing_date=filing_date, document=document)
Ejemplo n.º 5
0
 def from_xbrl_url(cls, filing_date, xbrl_url):
     '''constructor.'''
     document = XBRLDocument.gets_XBRL_from_edgar(xbrl_url=xbrl_url)
     return cls(filing_date=filing_date, document=document)