Created
March 16, 2024 19:21
-
-
Save AustinMatherne/f9a101ff48298f5b97b26e7f6e28833b to your computer and use it in GitHub Desktop.
Detect Filer Cash Flows LinkRole
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
baseTaxonomyCashFlowLinkRole = 'https://www.esma.europa.eu/xbrl/role/all/...' | |
baseTaxonomyCashFlowRels = baseTaxonomyModelXbrl.relationshipSet(XbrlConst.parentChild, baseTaxonomyCashFlowLinkRole) | |
baseTaxonomyCashFlowClarks = { | |
rel.toModelObject.qname.clarkNotation | |
for rel in baseTaxonomyCashFlowRels.modelRelationships | |
} | |
for root in baseTaxonomyCashFlowRels.rootConcepts: | |
baseTaxonomyCashFlowClarks.add(root.qname.clarkNotation) | |
maxScore = 0 | |
filerCashFlowRole = '' | |
for role in filerModelXbrl.roleTypes.keys(): | |
rolePresRels = filerModelXbrl.relationshipSet(XbrlConst.parentChild, role) | |
roleConceptClarks = { | |
rel.toModelObject.qname.clarkNotation | |
for rel in rolePresRels.modelRelationships | |
} | |
for root in rolePresRels.rootConcepts: | |
roleConceptClarks.add(root.qname.clarkNotation) | |
score = len(roleConceptClarks & baseTaxonomyCashFlowClarks) | |
if score > maxScore: | |
maxScore = score | |
filerCashFlowRole = role | |
print(f"filer's cash flow linkrole is {filerCashFlowRole}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment