All Projects → drkane → Ixbrl Parse

drkane / Ixbrl Parse

Licence: mit
A python library for getting useful data out of ixbrl files.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ixbrl Parse

Arch
ARCH models in Python
Stars: ✭ 660 (+2257.14%)
Mutual labels:  finance
Scrapy Finance
[OUTDATED] scrapy spiders to crawl the financial text data 📚 📜 pertinent to train word vectors 🚀
Stars: ✭ 17 (-39.29%)
Mutual labels:  finance
Moneymanagerex
Money Manager Ex is an easy to use, money management application built with wxWidgets
Stars: ✭ 836 (+2885.71%)
Mutual labels:  finance
Xalpha
基金投资管理回测引擎
Stars: ✭ 683 (+2339.29%)
Mutual labels:  finance
Twstock
台灣股市股票價格擷取 (含即時股票資訊) - Taiwan Stock Opendata with realtime
Stars: ✭ 763 (+2625%)
Mutual labels:  finance
Gofast
Go implementation of the FAST Protocol (FIX Adapted for STreaming)
Stars: ✭ 24 (-14.29%)
Mutual labels:  finance
Tda Api
A TD Ameritrade API client for Python. Includes historical data for equities and ETFs, options chains, streaming order book data, complex order construction, and more.
Stars: ✭ 608 (+2071.43%)
Mutual labels:  finance
Contractmanager
ContractManager is a contract management software for the Jameica platform.
Stars: ✭ 10 (-64.29%)
Mutual labels:  finance
Awesome Streamlit
The purpose of this project is to share knowledge on how awesome Streamlit is and can be
Stars: ✭ 769 (+2646.43%)
Mutual labels:  finance
Awesome Investing
💸💸 Curated list of investment & finance related resources
Stars: ✭ 935 (+3239.29%)
Mutual labels:  finance
Fecon235
Notebooks for financial economics. Keywords: Jupyter notebook pandas Federal Reserve FRED Ferbus GDP CPI PCE inflation unemployment wage income debt Case-Shiller housing asset portfolio equities SPX bonds TIPS rates currency FX euro EUR USD JPY yen XAU gold Brent WTI oil Holt-Winters time-series forecasting statistics econometrics
Stars: ✭ 708 (+2428.57%)
Mutual labels:  finance
Awesome Quant
A curated list of insanely awesome libraries, packages and resources for Quants (Quantitative Finance)
Stars: ✭ 8,205 (+29203.57%)
Mutual labels:  finance
R actuarial
El objetivo de este repositorio es brindar un apoyo a la comunidad interesada en mejorar sus técnicas en el lenguaje de programación R o emprenderlo desde un punto de vista muy aplicado. Un repositorio con códigos de R para aplicaciones actuariales: probabilidad, estadística, riesgo y finanzas.
Stars: ✭ 25 (-10.71%)
Mutual labels:  finance
Iex Api
The IEX API provides any individual or academic, public or private institution looking to develop applications that require stock market data to access near real-time quote and trade data for all stocks trading on IEX.
Stars: ✭ 683 (+2339.29%)
Mutual labels:  finance
Finance4py
股市技術分析小工具
Stars: ✭ 8 (-71.43%)
Mutual labels:  finance
Trace
Modern crypto portfolio & market explorer. Built with @Flutter
Stars: ✭ 655 (+2239.29%)
Mutual labels:  finance
Tradier Options Plotter
Python CLI tool for plotting options price history. Powered by Tradier's Sandbox API.
Stars: ✭ 24 (-14.29%)
Mutual labels:  finance
Cymbology
Identifies and validates financial security ids such as Sedol, Cusip, Isin numbers.
Stars: ✭ 13 (-53.57%)
Mutual labels:  finance
Mintable
🍃 Automate your personal finances – for free, with no ads, and no data collection.
Stars: ✭ 849 (+2932.14%)
Mutual labels:  finance
Axistradecult
Assist tool for trading on stock market, automatic download historical stock data, technical research, chart and analysis.
Stars: ✭ 26 (-7.14%)
Mutual labels:  finance

ixbrl-parse

Test status PyPI version PyPI - Python Version PyPI - License

A python module for getting useful data out of ixbrl files. Developed for a project with Power to Change looking at how to extract data from financial documents of community businesses. The library is at an early stage.

Requirements

The module requires BeautifulSoup and lxml to parse the documents.

word2number is used to process the numeric items with the numsenwords format.

How to install

You can install from pypi using pip:

pip install ixbrlparse

How to use

Run the python module

You can run the module directly to extract data from an IXBRL file.

python -m ixbrlparse example_file.html

The various options for using this can be found through:

python -m ixbrlparse -h
# optional arguments:
#   -h, --help            show this help message and exit
#   --outfile OUTFILE     Where to output the file
#   --format {csv,json,jsonlines,jsonl}
#                         format of the output
#   --fields {numeric,nonnumeric,all}
#                         Which fields to output

Use as a python module

An example of usage is shown in test.py.

Import the IXBRL class which parses the file.

from ixbrlparse import IXBRL

Initialise an object and parse the file

You need to pass a file handle or other object with a .read() method.

with open('sample_ixbrl.html', encoding="utf8") as a:
  x = IXBRL(a)

If your IXBRL data comes as a string then use a io.StringIO wrapper to pass it to the class:

import io
from ixbrlparse import IXBRL

content = '''<some ixbrl content>'''
x = IXBRL(io.StringIO(content))

Get the contexts and units used in the data

These are held in the object. The contexts are stored as a dictionary with the context id as the key, and a ixbrlContext object as the value.

print(x.contexts)
# {
#    "cfwd_2018_03_31": ixbrlContext(
#       id="cfwd_2018_03_31",
#       entity="0123456", # company number
#       segments=[], # used for hypercubes
#       instant="2018-03-31",
#       startdate=None, # used for periods
#       enddate=None, # used for periods
#    ),
#    ....
# }

The units are stored as key:value dictionary entries

print(x.units)
# {
#    "GBP": "ISO4107:GBP"
#    "shares": "shares"
# }

Get financial facts

Numeric facts are stored in x.numeric as a list of ixbrlNumeric objects. The ixbrlNumeric.value object contains the value as a parsed python number (after the sign and scale formatting values have been applied).

ixbrlNumeric.context holds the context object relating to this value. The .name and .schema values give the key of this value, according to the applied schema.

Non-numeric facts are stored in x.nonnumeric as a list of ixbrlNonnumeric objects, with similar .value, .context, .name and .schema values. The value of .value will be a string for non-numeric facts.

Check for any parsing errors

By default, the parser will throw an exception if it encounters an error when processing the document.

You can parse raise_on_error=False to the initial object to suppress these exceptions. You can then access a list of the errors (and the element) that created them through the .errors attribute. For example:

with open('sample_ixbrl.html', encoding="utf8") as a:
  x = IXBRL(a, raise_on_error=False)
  print(x.errors) # populated with any exceptions found
  # [ eg...
  #   {
  #     "error": <NotImplementedError>,
  #     "element": <BeautifulSoupElement>
  #   }
  # ]

Note that the error catching is only available for parsing of .nonnumeric and numeric items in the document. Any other errors with parsing will be thrown as normal no matter what raise_on_error is set to.

Run tests

Tests can be run with pytest:

pip install -e . # install the package
pytest tests

Linting

Black and isort should be run before committing any changes.

isort ixbrlparse tests
black ixbrlparse tests

Install development version

The development requirements are installed using pip install -r dev-requirements.txt.

Any additional requirements for the module itself must be added to install_requires in setup.py. You should then generate a new requirements.txt using using pip-tools (pip-compile). You can then run pip-sync to install the requirement.

Any additional development requirements must be added to dev-requirements.in and then the dev-requirements.txt should be generated using pip-compile dev-requirements.in. You can then install the development requirements using pip-sync dev-requirements.txt.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].