Tools for working with Securities and Exchange Commission (SEC) indices, SGML header files, filing archives and individual filing documents.
Project description
sectoolkit
Tools for working with Securities and Exchange Commission (SEC) indices, SGML header files, filing archives and individual filing documents.
This package supports working with SEC indexes, SGML header files and filings, including individual or bulk downloading and local caching of these items.
Package architecture supports form parsers as plug-in classes that accept the file body and optional key word arguments as inputs and implement a _parsing_work_function(self) method that populates the self.parsed dictionary object with items that are of interest for a particular form type. Users can develop their own custom parsers and register them as the default for a particular form type. Alternatively, an instance of a custom parser can be registered under the self.parser attribute of an instance of the filingDocument class. Calls to the self.parse() method of the filingDocument class will first check the self.parser instance attribute for a parser and will then check the parsers dictionary to see whether there is a default parser for the form type in question.
Parsing filing text
Parsing of filings is currently only supported for forms SC 13D and SC 13D/A, however, support for forms 8-K and 8-K/A will be added shortly.
Adding a custom parser
To implement a custom parser, sub-class the following parser base class, which is exposed in the package level namespace.
class parser_base(object):
def __init__(self, file_body, **kwargs):
#
self.body = file_body
# Include any optional key word arguments that were provided in
# the instance dictionary
self.__dict__.update(kwargs)
# Initialize the dictionary that will receive parsed items
self.parsed = {}
# Override this in parser subclasses to implement parsers for different form types.
def _parsing_work_function(self):
# Get all the real work done here and in other internal functions
# For example, set a test entry in the self.parsed dictionary
# self.parsed['test'] = 'pass'
pass
def parse(self):
# Call one or more internal functions that will populate the
# self.parsed dictionary
self._parsing_work_function()
# Return the dictionary of parsed items.
return self.parsed
You can then add it to the parsers dictionary as the default for particular form types as follows:
`sectoolkit.parsers['8-K'] = parser_8K`
`sectoolkit.parsers['8-K/A'] = parser_8K`
Also, note the support for optional keyword arguments when instantiating the parser class. These items are added to the instance __dict__
for the parser and are then available to be accessed by the parsing code included in the body of the parser class.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sectoolkit-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78aa76b11a6d8fc271005653c34a0c317cfeae8d08067e3f968cb007c13d4908 |
|
MD5 | 66a9c6c03a4062a3a7f7e0f710075f12 |
|
BLAKE2b-256 | cadb315c6ed27f66cab95ea75d1511343371e3779ead58bc23e61e3c58f4030f |