Skip to content

Instantly share code, notes, and snippets.

@AustinMatherne
Created March 16, 2024 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AustinMatherne/f9a101ff48298f5b97b26e7f6e28833b to your computer and use it in GitHub Desktop.
Save AustinMatherne/f9a101ff48298f5b97b26e7f6e28833b to your computer and use it in GitHub Desktop.
Detect Filer Cash Flows LinkRole
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