Update EDGAR resolutions.
This commit is contained in:
@@ -17,19 +17,15 @@ class CompanyToCIK:
|
||||
parameters = {}
|
||||
|
||||
def resolution(self, entityJsonList, parameters):
|
||||
import re
|
||||
from bs4 import BeautifulSoup
|
||||
from playwright.sync_api import sync_playwright, TimeoutError, Error
|
||||
|
||||
returnResults = []
|
||||
index_of_child = []
|
||||
cikRegex = re.compile(r'CIK=\d{4,10}', re.IGNORECASE)
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.firefox.launch()
|
||||
context = browser.new_context(
|
||||
viewport={'width': 1920, 'height': 1080},
|
||||
user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0'
|
||||
viewport={'width': 1920, 'height': 1080}
|
||||
)
|
||||
page = context.new_page()
|
||||
for entity in entityJsonList:
|
||||
@@ -51,30 +47,31 @@ class CompanyToCIK:
|
||||
continue
|
||||
|
||||
soup = BeautifulSoup(page.content(), 'lxml')
|
||||
cikIDs = cikRegex.findall(soup.get_text())
|
||||
|
||||
links_with_text = []
|
||||
count = 0
|
||||
temp = None
|
||||
for td_element in soup.find_all('td'):
|
||||
if td_element.text:
|
||||
try:
|
||||
text = td_element.text
|
||||
split = text.split('SIC')[0]
|
||||
links_with_text.append(split)
|
||||
except IndexError:
|
||||
links_with_text.append(td_element.text)
|
||||
text = td_element.text
|
||||
splitText = text.split('SIC')[0]
|
||||
if count == 0:
|
||||
temp = [{'CIK': splitText,
|
||||
'Entity Type': 'Edgar ID'},
|
||||
{len(returnResults): {'Resolution': 'CIK Edgar ID',
|
||||
'Notes': ''}}]
|
||||
elif count == 1:
|
||||
returnResults.append([{'Company Name': splitText,
|
||||
'Entity Type': 'Company'},
|
||||
{uid: {'Resolution': 'Edgar Company',
|
||||
'Notes': ''}}])
|
||||
returnResults.append(temp)
|
||||
elif count == 2:
|
||||
returnResults.append([{'Phrase': "State: " + splitText,
|
||||
'Entity Type': 'Phrase'},
|
||||
{len(returnResults) - 1: {'Resolution': 'Edgar Company State',
|
||||
'Notes': ''}}])
|
||||
count = (count + 1) % 3
|
||||
|
||||
for link in links_with_text:
|
||||
if search_term.lower() in link.lower():
|
||||
index_of_child.append(len(returnResults))
|
||||
returnResults.append([{'Company Name': link,
|
||||
'Entity Type': 'Company'},
|
||||
{uid: {'Resolution': 'Edgar Company',
|
||||
'Notes': ''}}])
|
||||
for code in cikIDs:
|
||||
returnResults.append([{'CIK': code.split('=')[1],
|
||||
'Entity Type': 'Edgar ID'},
|
||||
{index_of_child[cikIDs.index(code)]: {'Resolution': 'CIK Edgar ID',
|
||||
'Notes': ''}}])
|
||||
page.close()
|
||||
browser.close()
|
||||
return returnResults
|
||||
|
||||
@@ -61,7 +61,7 @@ class Get10KForms:
|
||||
for j in range(linkNumbers):
|
||||
if '10-K' in data['facts'][form][i]['units']['USD'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['USD'][::-1][j]
|
||||
returnResults.append([{'Field Name': '10-K: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 10-K: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
@@ -80,7 +80,7 @@ class Get10KForms:
|
||||
for j in range(linkNumbers):
|
||||
if '10-K' in data['facts'][form][i]['units']['shares'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['shares'][::-1][j]
|
||||
returnResults.append([{'Field Name': '10-K: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 10-K: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
|
||||
@@ -61,7 +61,7 @@ class Get10QForms:
|
||||
for j in range(linkNumbers):
|
||||
if '10-Q' in data['facts'][form][i]['units']['USD'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['USD'][::-1][j]
|
||||
returnResults.append([{'Field Name': '10-Q: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 10-Q: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
@@ -79,7 +79,7 @@ class Get10QForms:
|
||||
for j in range(linkNumbers):
|
||||
if '10-Q' in data['facts'][form][i]['units']['shares'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['shares'][::-1][j]
|
||||
returnResults.append([{'Field Name': '10-Q: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 10-Q: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
|
||||
@@ -60,7 +60,7 @@ class Get20FForms:
|
||||
for j in range(linkNumbers):
|
||||
if '20-F' in data['facts'][form][i]['units']['USD'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['USD'][::-1][j]
|
||||
returnResults.append([{'Field Name': '20-F: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 20-F: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
@@ -79,7 +79,7 @@ class Get20FForms:
|
||||
for j in range(linkNumbers):
|
||||
if '20-F' in data['facts'][form][i]['units']['shares'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['shares'][::-1][j]
|
||||
returnResults.append([{'Field Name': '20-F: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 20-F: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
|
||||
@@ -61,7 +61,7 @@ class Get40FForms:
|
||||
for j in range(linkNumbers):
|
||||
if '40-F' in data['facts'][form][i]['units']['USD'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['USD'][::-1][j]
|
||||
returnResults.append([{'Field Name': '40-F: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 40-F: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
@@ -80,7 +80,7 @@ class Get40FForms:
|
||||
for j in range(linkNumbers):
|
||||
if '40-F' in data['facts'][form][i]['units']['shares'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['shares'][::-1][j]
|
||||
returnResults.append([{'Field Name': '40-F: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 40-F: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
|
||||
@@ -63,7 +63,7 @@ class Get6KForms:
|
||||
for j in range(linkNumbers):
|
||||
if '6-K' in data['facts'][form][i]['units']['USD'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['USD'][::-1][j]
|
||||
returnResults.append([{'Field Name': '6-K: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 6-K: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
@@ -82,7 +82,7 @@ class Get6KForms:
|
||||
for j in range(linkNumbers):
|
||||
if '6-K' in data['facts'][form][i]['units']['shares'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['shares'][::-1][j]
|
||||
returnResults.append([{'Field Name': '6-K: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 6-K: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
|
||||
@@ -63,7 +63,7 @@ class Get8KForms:
|
||||
for j in range(linkNumbers):
|
||||
if '8-K' in data['facts'][form][i]['units']['USD'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['USD'][::-1][j]
|
||||
returnResults.append([{'Field Name': '8-K: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 8-K: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
@@ -82,7 +82,7 @@ class Get8KForms:
|
||||
for j in range(linkNumbers):
|
||||
if '8-K' in data['facts'][form][i]['units']['shares'][j]['form']:
|
||||
value = data['facts'][form][i]['units']['shares'][::-1][j]
|
||||
returnResults.append([{'Field Name': '8-K: ' + i + ' ' + value['filed'],
|
||||
returnResults.append([{'Field Name': cik + ' 8-K: ' + i + ' ' + value['filed'],
|
||||
'Account Number': value['accn'],
|
||||
'Fiscal Year': value['fy'],
|
||||
'Fiscal Period': value['fp'],
|
||||
|
||||
@@ -139,7 +139,7 @@ class GetNMFP2Forms:
|
||||
|
||||
for field in liquidAssets:
|
||||
if 'Daily' in field:
|
||||
returnResults.append([{'Field Name': f'N-MFP2:({field})' + ' '
|
||||
returnResults.append([{'Field Name': cik + f' N-MFP2:({field})' + ' '
|
||||
+ f'ID: {seriesId} Date: {date}',
|
||||
'Friday 1': fieldPath[field][
|
||||
'ns3:fridayDay1'],
|
||||
@@ -154,7 +154,7 @@ class GetNMFP2Forms:
|
||||
{uid: {'Resolution': field,
|
||||
'Notes': ''}}])
|
||||
else:
|
||||
returnResults.append([{'Field Name': f'N-MFP2:({field})' + ' '
|
||||
returnResults.append([{'Field Name': cik + f' N-MFP2:({field})' + ' '
|
||||
+ f'ID: {seriesId} Date: {date}',
|
||||
'Friday 1': fieldPath[field][
|
||||
'ns3:fridayWeek1'],
|
||||
@@ -177,7 +177,7 @@ class GetNMFP2Forms:
|
||||
[{'Phrase': classInfo['classesId'],
|
||||
'Entity Type': 'Phrase'},
|
||||
{uid: {'Resolution': 'Classes Id', 'Notes': ''}}])
|
||||
returnResults.append([{'Field Name': f'N-MFP2:(Net Asset Per Share)' + ' '
|
||||
returnResults.append([{'Field Name': cik + f' N-MFP2:(Net Asset Per Share)' + ' '
|
||||
+ f'ID: {seriesId} Date: {date}',
|
||||
'Friday 1': classInfo['netAssetPerShare'][
|
||||
'ns3:fridayWeek1'],
|
||||
@@ -211,7 +211,8 @@ class GetNMFP2Forms:
|
||||
{index_of_child: {'Resolution': value,
|
||||
'Notes': ''}}])
|
||||
|
||||
scheduleOfPortfolioSecurities = data['edgarSubmission']['formData']['scheduleOfPortfolioSecuritiesInfo']
|
||||
scheduleOfPortfolioSecurities = data['edgarSubmission']['formData'][
|
||||
'scheduleOfPortfolioSecuritiesInfo']
|
||||
instance = 0
|
||||
for securitiesInfo in scheduleOfPortfolioSecurities:
|
||||
index_of_child = len(returnResults)
|
||||
@@ -259,7 +260,8 @@ class GetNMFP2Forms:
|
||||
returnResults.append([{'Name': issuer['nameOfCollateralIssuer'],
|
||||
'Coupon or Yield': issuer['couponOrYield'],
|
||||
'Principal Amount': issuer['principalAmountToTheNearestCent'],
|
||||
'Value of Collateral': issuer['valueOfCollateralToTheNearestCent'],
|
||||
'Value of Collateral': issuer[
|
||||
'valueOfCollateralToTheNearestCent'],
|
||||
'Ctgry Investments Rprsnts Collateral':
|
||||
issuer['ctgryInvestmentsRprsntsCollateral'],
|
||||
'Entity Type': 'Collateral Issuer'},
|
||||
|
||||
Reference in New Issue
Block a user