datamule 0.422__cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. datamule/__init__.py +71 -0
  2. datamule/data/company_former_names.csv +8148 -0
  3. datamule/data/company_metadata.csv +10049 -0
  4. datamule/data/company_tickers.csv +9999 -0
  5. datamule/data/sec-glossary.csv +728 -0
  6. datamule/data/xbrl_descriptions.csv +10024 -0
  7. datamule/dataset_builder/dataset_builder.py +259 -0
  8. datamule/document.py +130 -0
  9. datamule/downloader/downloader.py +364 -0
  10. datamule/downloader/premiumdownloader.py +332 -0
  11. datamule/helper.py +123 -0
  12. datamule/monitor.py +236 -0
  13. datamule/mulebot/__init__.py +1 -0
  14. datamule/mulebot/helper.py +35 -0
  15. datamule/mulebot/mulebot.py +130 -0
  16. datamule/mulebot/mulebot_server/__init__.py +1 -0
  17. datamule/mulebot/mulebot_server/server.py +87 -0
  18. datamule/mulebot/mulebot_server/static/css/minimalist.css +174 -0
  19. datamule/mulebot/mulebot_server/static/scripts/artifacts.js +68 -0
  20. datamule/mulebot/mulebot_server/static/scripts/chat.js +92 -0
  21. datamule/mulebot/mulebot_server/static/scripts/filingArtifacts.js +56 -0
  22. datamule/mulebot/mulebot_server/static/scripts/listArtifacts.js +15 -0
  23. datamule/mulebot/mulebot_server/static/scripts/main.js +57 -0
  24. datamule/mulebot/mulebot_server/static/scripts/prefilledPrompt.js +27 -0
  25. datamule/mulebot/mulebot_server/static/scripts/suggestions.js +47 -0
  26. datamule/mulebot/mulebot_server/static/scripts/tableArtifacts.js +129 -0
  27. datamule/mulebot/mulebot_server/static/scripts/utils.js +28 -0
  28. datamule/mulebot/mulebot_server/templates/chat-minimalist.html +91 -0
  29. datamule/mulebot/search.py +52 -0
  30. datamule/mulebot/tools.py +82 -0
  31. datamule/packageupdater.py +207 -0
  32. datamule/parser/document_parsing/basic_10k_parser.py +82 -0
  33. datamule/parser/document_parsing/basic_10q_parser.py +73 -0
  34. datamule/parser/document_parsing/basic_13d_parser.py +58 -0
  35. datamule/parser/document_parsing/basic_13g_parser.py +61 -0
  36. datamule/parser/document_parsing/basic_8k_parser.py +84 -0
  37. datamule/parser/document_parsing/form_d_parser.py +70 -0
  38. datamule/parser/document_parsing/generalized_item_parser.py +78 -0
  39. datamule/parser/document_parsing/generalized_xml_parser.py +0 -0
  40. datamule/parser/document_parsing/helper.py +75 -0
  41. datamule/parser/document_parsing/information_table_parser_13fhr.py +41 -0
  42. datamule/parser/document_parsing/insider_trading_parser.py +158 -0
  43. datamule/parser/document_parsing/mappings.py +95 -0
  44. datamule/parser/document_parsing/n_port_p_parser.py +70 -0
  45. datamule/parser/document_parsing/sec_parser.py +73 -0
  46. datamule/parser/document_parsing/sgml_parser.py +94 -0
  47. datamule/parser/sgml_parsing/sgml_parser_cy.c +19082 -0
  48. datamule/parser/sgml_parsing/sgml_parser_cy.cpython-312-x86_64-linux-gnu.so +0 -0
  49. datamule/portfolio.py +21 -0
  50. datamule/submission.py +67 -0
  51. datamule-0.422.dist-info/METADATA +31 -0
  52. datamule-0.422.dist-info/RECORD +54 -0
  53. datamule-0.422.dist-info/WHEEL +6 -0
  54. datamule-0.422.dist-info/top_level.txt +1 -0
@@ -0,0 +1,95 @@
1
+ # I will liekely move this file to a more appropriate location in the future
2
+
3
+ mapping_dict_10k = {
4
+ 'filing_summary': 'Annual report providing comprehensive overview of company business, financial performance, risks, and operations. Contains audited financial statements, business description, risk analysis, and detailed operational metrics.',
5
+
6
+ 'structure': {
7
+ 'part1': {
8
+ 'summary': 'Overview of company operations, risks, and material business information. Contains key business strategy, market position, competitive landscape, and significant challenges.',
9
+ 'item1': {
10
+ 'summary': 'Detailed description of business operations including primary products/services, markets served, distribution methods, competitive conditions, regulatory environment, and business segments'
11
+ },
12
+ 'item1a': {
13
+ 'summary': 'Comprehensive list and explanation of significant risks and uncertainties that could affect business performance, financial condition, and stock value'
14
+ },
15
+ 'item1b': {
16
+ 'summary': 'Disclosure of any unresolved comments or issues raised by SEC staff regarding company filings'
17
+ },
18
+ 'item1c': {
19
+ 'summary': 'Information about cybersecurity risks, incidents, risk management, governance, and strategy'
20
+ },
21
+ 'item2': {
22
+ 'summary': 'Description of principal physical properties, including manufacturing facilities, offices, warehouses, and other significant real estate'
23
+ },
24
+ 'item3': {
25
+ 'summary': 'Description of material pending legal proceedings, including potential impacts on business'
26
+ },
27
+ 'item4': {
28
+ 'summary': 'Disclosure of mine safety violations, citations, and orders received under the Mine Act'
29
+ }
30
+ },
31
+ 'part2': {
32
+ 'summary': 'Detailed financial performance analysis, including management insights, market risks, and complete audited financial statements.',
33
+ 'item5': {
34
+ 'summary': 'Information about company stock, including market data, price history, dividends, share repurchases, and securities offerings'
35
+ },
36
+ 'item6': {
37
+ 'summary': 'Selected historical financial data showing trends in financial condition and results over past 5 years'
38
+ },
39
+ 'item7': {
40
+ 'summary': 'Management\'s analysis of financial condition, operations results, liquidity, capital resources, and future outlook'
41
+ },
42
+ 'item7a': {
43
+ 'summary': 'Discussion of exposure to market risk including interest rates, foreign exchange, commodities, and hedging activities'
44
+ },
45
+ 'item8': {
46
+ 'summary': 'Audited financial statements, including balance sheets, income statements, cash flows, and comprehensive notes'
47
+ },
48
+ 'item9': {
49
+ 'summary': 'Information about changes in independent auditors and any disagreements with them'
50
+ },
51
+ 'item9a': {
52
+ 'summary': 'Management\'s assessment of internal control effectiveness over financial reporting'
53
+ },
54
+ 'item9b': {
55
+ 'summary': 'Other significant information not reported elsewhere in the filing'
56
+ }
57
+ },
58
+ 'part3': {
59
+ 'summary': 'Information about company leadership, compensation structures, and corporate governance practices.',
60
+ 'item10': {
61
+ 'summary': 'Information about directors and executive officers, including their experience, qualifications, and corporate governance practices'
62
+ },
63
+ 'item11': {
64
+ 'summary': 'Detailed information about executive compensation, including salary, bonuses, stock awards, and compensation policies'
65
+ },
66
+ 'item12': {
67
+ 'summary': 'Information about beneficial ownership of securities by management and major shareholders, equity compensation plans'
68
+ },
69
+ 'item13': {
70
+ 'summary': 'Description of transactions with related parties and potential conflicts of interest'
71
+ },
72
+ 'item14': {
73
+ 'summary': 'Disclosure of fees paid for audit and non-audit services provided by independent accountants'
74
+ }
75
+ },
76
+ 'part4': {
77
+ 'summary': 'Supporting documentation and additional required disclosures.',
78
+ 'item15': {
79
+ 'summary': 'List of all exhibits, including material contracts, corporate documents, and supplementary financial information'
80
+ },
81
+ 'item16': {
82
+ 'summary': 'Optional summary of key information from the entire Form 10-K filing'
83
+ }
84
+ }
85
+ },
86
+
87
+ 'search_hints': {
88
+ 'financial_metrics': ['item6', 'item7', 'item8'],
89
+ 'risk_assessment': ['item1a', 'item1c', 'item7a'],
90
+ 'business_overview': ['item1', 'item2'],
91
+ 'leadership_info': ['item10', 'item11'],
92
+ 'material_events': ['item3', 'item9', 'item13'],
93
+ 'operational_data': ['item1', 'item7', 'item2']
94
+ }
95
+ }
@@ -0,0 +1,70 @@
1
+ from xml.etree import ElementTree as ET
2
+
3
+ def element_to_dict(elem):
4
+ """Convert an XML element to dict preserving structure."""
5
+ result = {}
6
+
7
+ # Add attributes directly to result
8
+ if elem.attrib:
9
+ result.update(elem.attrib)
10
+
11
+ # Add text content if present and no children
12
+ if elem.text and elem.text.strip():
13
+ text = elem.text.strip()
14
+ if not len(elem): # No children
15
+ return text
16
+ else:
17
+ result['text'] = text
18
+
19
+ # Process children
20
+ for child in elem:
21
+ child_data = element_to_dict(child)
22
+ child_tag = child.tag.split('}')[-1] # Remove namespace
23
+
24
+ if child_tag in result:
25
+ # Convert to list if multiple elements
26
+ if not isinstance(result[child_tag], list):
27
+ result[child_tag] = [result[child_tag]]
28
+ result[child_tag].append(child_data)
29
+ else:
30
+ result[child_tag] = child_data
31
+
32
+ return result
33
+
34
+ def parse_nport_p(filepath):
35
+ """Parse NPORT XML file into metadata and document sections."""
36
+ # Parse XML
37
+ tree = ET.parse(filepath)
38
+ root = tree.getroot()
39
+
40
+ # Remove namespaces for cleaner processing
41
+ for elem in root.iter():
42
+ if '}' in elem.tag:
43
+ elem.tag = elem.tag.split('}')[-1]
44
+
45
+ # Convert entire document to dict
46
+ full_dict = element_to_dict(root)
47
+
48
+ # Separate metadata and document content
49
+ result = {
50
+ 'metadata': {},
51
+ 'document': {}
52
+ }
53
+
54
+ # Extract metadata sections
55
+ if 'headerData' in full_dict:
56
+ result['metadata']['headerData'] = full_dict['headerData']
57
+
58
+ if 'formData' in full_dict and 'genInfo' in full_dict['formData']:
59
+ result['metadata']['genInfo'] = full_dict['formData']['genInfo']
60
+
61
+ # Everything else goes to document
62
+ result['document'] = full_dict
63
+
64
+ # Remove metadata sections from document to avoid duplication
65
+ if 'headerData' in result['document']:
66
+ del result['document']['headerData']
67
+ if 'formData' in result['document'] and 'genInfo' in result['document']['formData']:
68
+ del result['document']['formData']['genInfo']
69
+
70
+ return result
@@ -0,0 +1,73 @@
1
+ import xml.etree.ElementTree as ET
2
+ from .basic_8k_parser import parse_8k
3
+ from .basic_10k_parser import parse_10k
4
+ from .basic_10q_parser import parse_10q
5
+ from .information_table_parser_13fhr import parse_13f_hr_information_table_xml
6
+ from .insider_trading_parser import parse_form345
7
+ from .form_d_parser import parse_form_d
8
+ from .n_port_p_parser import parse_nport_p
9
+ from .basic_13d_parser import parse_13d
10
+ from .basic_13g_parser import parse_13g
11
+ from .generalized_item_parser import generalized_parser
12
+ from .mappings import *
13
+
14
+ class Parser:
15
+
16
+ def __init__(self):
17
+ pass
18
+
19
+ def parse_filing(self, filename, filing_type):
20
+ if filing_type == 'INFORMATION TABLE':
21
+ return parse_13f_hr_information_table_xml(filename)
22
+ elif filing_type == '8-K':
23
+ return parse_8k(filename)
24
+ elif filing_type == '10-K':
25
+ return parse_10k(filename)
26
+ elif filing_type == '10-Q':
27
+ return parse_10q(filename)
28
+ elif filing_type in ['3', '4', '5']:
29
+ return parse_form345(filename)
30
+ elif filing_type == 'D':
31
+ return parse_form_d(filename)
32
+ elif filing_type == 'NPORT-P':
33
+ return parse_nport_p(filename)
34
+ elif filing_type == 'SC 13D':
35
+ return parse_13d(filename)
36
+ elif filing_type == 'SC 13G':
37
+ return parse_13g(filename)
38
+ else:
39
+ raise ValueError(f'Filing type {filing_type} not supported')
40
+
41
+
42
+ def parse_company_concepts(self, data):
43
+
44
+ # get cik
45
+ cik = data['cik']
46
+ # get categories
47
+ categories = list(data['facts'].keys())
48
+
49
+ table_dict_list = []
50
+ for category in categories:
51
+ for fact in data['facts'][category]:
52
+ label = data['facts'][category][fact]['label']
53
+ description = data['facts'][category][fact]['description']
54
+ units = list(data['facts'][category][fact]['units'].keys())
55
+
56
+ for unit in units:
57
+ table = data['facts'][category][fact]['units'][unit]
58
+
59
+ # Find all unique keys across all rows
60
+ all_keys = set()
61
+ for row in table:
62
+ all_keys.update(row.keys())
63
+
64
+ # Ensure all rows have all keys
65
+ for row in table:
66
+ for key in all_keys:
67
+ if key not in row:
68
+ row[key] = None
69
+
70
+ table_dict = {'cik':cik, 'category': category, 'fact': fact, 'label': label, 'description': description, 'unit': unit, 'table': table}
71
+ table_dict_list.append(table_dict)
72
+
73
+ return table_dict_list
@@ -0,0 +1,94 @@
1
+ import os
2
+ import json
3
+ import uu
4
+ from io import BytesIO
5
+
6
+ class SimpleSGMLParser:
7
+ def _extract_tag_content(self, line: str) -> tuple[str, str] | None:
8
+ if not (line.startswith('<') and '>' in line):
9
+ return None
10
+
11
+ tag_end = line.index('>')
12
+ tag = line[1:tag_end]
13
+
14
+ if tag.startswith('/'):
15
+ return None
16
+
17
+ content = line[tag_end + 1:].strip()
18
+ return (tag, content)
19
+
20
+ def _write_document(self, content: str, document_info: dict, output_dir: str) -> None:
21
+ if not content:
22
+ return
23
+
24
+ output_path = os.path.join(output_dir, document_info.get('FILENAME', f"{document_info.get('SEQUENCE', 'unknown')}.txt"))
25
+
26
+ first_line = content.partition('\n')[0].strip()
27
+ if first_line.startswith('begin '):
28
+ with BytesIO(content.encode()) as input_file:
29
+ uu.decode(input_file, output_path,quiet=True)
30
+ else:
31
+ with open(output_path, 'w', encoding='utf-8') as f:
32
+ f.write(content)
33
+
34
+ def parse_file(self, filepath: str, output_dir: str) -> None:
35
+ os.makedirs(output_dir, exist_ok=True)
36
+
37
+ submission_data = {}
38
+ documents = []
39
+ current_document = {}
40
+ text_buffer = []
41
+
42
+ in_document = False
43
+ in_text = False
44
+ in_submission = True
45
+
46
+ with open(filepath, 'r', encoding='utf-8') as file:
47
+ for line in file:
48
+ stripped = line.strip()
49
+
50
+ if stripped == '<DOCUMENT>':
51
+ in_document = True
52
+ in_submission = False
53
+ current_document = {}
54
+
55
+ elif stripped == '</DOCUMENT>':
56
+ documents.append(current_document)
57
+ self._write_document(''.join(text_buffer), current_document, output_dir)
58
+ text_buffer = []
59
+ in_document = False
60
+
61
+ elif stripped == '<TEXT>':
62
+ in_text = True
63
+ text_buffer = []
64
+
65
+ elif stripped == '</TEXT>':
66
+ in_text = False
67
+
68
+ elif in_text:
69
+ if stripped not in ['<PDF>', '</PDF>']:
70
+ text_buffer.append(line)
71
+
72
+ else:
73
+ tag_content = self._extract_tag_content(stripped)
74
+ if tag_content:
75
+ key, value = tag_content
76
+ if in_submission:
77
+ submission_data[key] = value
78
+ elif in_document:
79
+ current_document[key] = value
80
+
81
+ metadata = {
82
+ 'submission': submission_data,
83
+ 'documents': documents
84
+ }
85
+
86
+ with open(os.path.join(output_dir, 'metadata.json'), 'w', encoding='utf-8') as f:
87
+ json.dump(metadata, f, indent=4)
88
+
89
+ def parse_sgml_submission(filepath: str, output_dir: str | None = None) -> None:
90
+ if output_dir is None:
91
+ output_dir = os.path.splitext(filepath)[0] + '_output'
92
+
93
+ parser = SimpleSGMLParser()
94
+ parser.parse_file(filepath, output_dir)