Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a3ddf6d

Browse filesBrowse files
committed
Add Issuers Service
1 parent 4284be1 commit a3ddf6d
Copy full SHA for a3ddf6d

4 files changed

+142Lines changed: 142 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎edgar/client.py‎

Copy file name to clipboardExpand all lines: edgar/client.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from edgar.datasets import Datasets
88
from edgar.filings import Filings
99
from edgar.current_events import CurrentEvents
10+
from edgar.issuers import Issuers
1011

1112

1213
class EdgarClient():
@@ -139,4 +140,18 @@ def current_events(self) -> CurrentEvents:
139140
# Grab the `CurrentEvents` object.
140141
object = CurrentEvents(session=self.edgar_session)
141142

143+
return object
144+
145+
def issuers(self) -> Issuers:
146+
"""Used to access the `Issuers` services.
147+
148+
### Returns
149+
---
150+
Users:
151+
The `Issuers` services Object.
152+
"""
153+
154+
# Grab the `Issuers` object.
155+
object = Issuers(session=self.edgar_session)
156+
142157
return object
Collapse file

‎edgar/issuers.py‎

Copy file name to clipboard
+107Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
from typing import Dict
2+
from edgar.session import EdgarSession
3+
from edgar.utilis import EdgarUtilities
4+
from edgar.parser import EdgarParser
5+
6+
7+
class Issuers():
8+
9+
"""
10+
## Overview:
11+
----
12+
"""
13+
14+
def __init__(self, session: EdgarSession) -> None:
15+
"""Initializes the `Issuers` object.
16+
17+
### Parameters
18+
----
19+
session : `EdgarSession`
20+
An initialized session of the `EdgarSession`.
21+
22+
### Usage
23+
----
24+
>>> edgar_client = EdgarClient()
25+
>>> issuers_services = edgar_client.issuers()
26+
"""
27+
28+
# Set the session.
29+
self.edgar_session: EdgarSession = session
30+
self.edgar_utilities: EdgarUtilities = EdgarUtilities()
31+
self.edgar_parser: EdgarParser = EdgarParser()
32+
33+
# Set the endpoint.
34+
self.browse_endpoint = '/cgi-bin/own-disp'
35+
36+
# define the arguments of the request
37+
self.params = {
38+
'count': '100',
39+
'CIK': '',
40+
'action': 'getissuer',
41+
'output': 'atom'
42+
}
43+
44+
def _reset_params(self) -> None:
45+
"""Resets the params for the next request."""
46+
47+
# define the arguments of the request
48+
self.params = {
49+
'count': '100',
50+
'CIK': '',
51+
'action': 'getissuer',
52+
'output': 'atom'
53+
}
54+
55+
def __repr__(self) -> str:
56+
"""String representation of the `EdgarClient.Issuers` object."""
57+
58+
# define the string representation
59+
str_representation = '<EdgarClient.Issuers (active=True, connected=True)>'
60+
61+
return str_representation
62+
63+
def get_issuers_by_cik(self, cik: str, number_of_issuers: int = 100) -> list:
64+
"""Returns all the issuers for a given CIK number.
65+
66+
### Arguments:
67+
----
68+
cik : str
69+
The CIK you want to query for issuers.
70+
71+
number_of_issuers : int (optional, Default=100)
72+
Specifices the number of issuers to return. If you want all issuers
73+
then set to `None`. Be cautious though becuase you may be requesting
74+
100s of URLs.
75+
76+
### Returns:
77+
----
78+
dict :
79+
A collection of `Issuers` resources.
80+
81+
### Usage:
82+
----
83+
>>> edgar_client = EdgarClient()
84+
>>> issuers_services = edgar_client.issuers()
85+
>>> issuers_services.get_issuers_by_cik(
86+
cik=''
87+
)
88+
"""
89+
90+
self.params['CIK'] = cik
91+
92+
# Grab the Data.
93+
response = self.edgar_session.make_request(
94+
method='get',
95+
endpoint=self.browse_endpoint,
96+
params=self.params
97+
)
98+
99+
# Parse it.
100+
response = self.edgar_parser.parse_issuer_table(
101+
response_text=response,
102+
num_of_items=number_of_issuers
103+
)
104+
105+
self._reset_params()
106+
107+
return response
Collapse file

‎samples/use_issuers_service.py‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pprint import pprint
2+
from edgar.client import EdgarClient
3+
from edgar.enums import StateCodes
4+
from edgar.enums import CountryCodes
5+
from edgar.enums import StandardIndustrialClassificationCodes
6+
7+
# Initialize the Edgar Client
8+
edgar_client = EdgarClient()
9+
10+
# Initialize the Issuers Services.
11+
issuers_service = edgar_client.issuers()
12+
13+
# Grab all the companies that are based in Texas.
14+
pprint(issuers_service.get_issuers_by_cik(cik='0001084869'))
Collapse file

‎tests/test_edgar_client.py‎

Copy file name to clipboardExpand all lines: tests/test_edgar_client.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from edgar.datasets import Datasets
1616
from edgar.current_events import CurrentEvents
1717
from edgar.filings import Filings
18+
from edgar.issuers import Issuers
1819

1920
class Edg(TestCase):
2021

@@ -77,6 +78,11 @@ def test_creates_instance_of_filings(self):
7778
# Make sure it matches.
7879
self.assertIsInstance(self.edgar_client.filings(), Filings)
7980

81+
def test_creates_instance_of_issuers(self):
82+
"""Create an instance and make sure it's a `Issuers` object."""
83+
84+
# Make sure it matches.
85+
self.assertIsInstance(self.edgar_client.issuers(), Issuers)
8086

8187
def tearDown(self) -> None:
8288
"""Teardown the `Edgar` Client."""

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.