Implementing Equity Penetration: Graph Models and Multi-Layer Ownership Calculation

    Equity penetration traces ownership upward from a target company to ultimate natural-person or terminal shareholders and calculates each party’s effective ownership ratio. This article explains the core calculation rules, graph-based data modeling, a depth-first implementation with cycle detection and depth limits, precision and edge cases, and engineering practices for explainable and auditable results. The emphasis is on correctness, data quality, configurable rules, and testability rather than speed alone.

    1. What Equity Penetration Solves

    Equity penetration means starting from a target company, tracing upward through multi-layer shareholding relationships, identifying the ultimate natural-person shareholders or terminal entities that no longer continue holding shares, and calculating each terminal party’s actual ownership ratio in the target company.

    A direct shareholding relationship only shows “who my shareholders are”; it does not show “who really controls me.” For example, a company’s largest shareholder may be a holding company, and that holding company may itself be owned by several natural persons. Looking only at the first layer can lead to misjudging the actual controller. Equity penetration is designed to solve this type of problem.

    Common application scenarios include:

    • Due diligence in investment, financing, and M&A to verify the target company’s real ownership structure.
    • Anti-money laundering and customer identification to determine beneficial owners.
    • Related-party transaction identification to determine whether two companies are controlled by the same terminal shareholder.
    • Corporate credit and risk monitoring to discover hidden related guarantees and funding chains.

    These scenarios share a common requirement: results must be explainable, reviewable, and able to withstand auditing. Therefore, for a penetration module, correctness is more important than execution speed.

    2. Core Calculation Rules

    The mathematical rules of equity penetration are not complex, but real data contains many situations that require explicit conventions.

    2.1 Direct and Indirect Ownership

    Suppose A holds 60% of B, and B holds 50% of C. Then A indirectly holds C through B at:

    Indirect ownership ratio = 60% × 50% = 30%

    That is, multiply ratios layer by layer along the ownership path to obtain the effective ratio for that path.

    2.2 Multi-Path Aggregation

    The same shareholder may hold shares in the target company through multiple paths. In this case, the effective ratios of all paths should be summed.

    For example, if A directly holds 10% of C and also indirectly holds 30% of C through B, then A’s penetrated ownership ratio in C is 10% + 30% = 40%.

    Multi-path aggregation is the step most easily missed. If only the first path is recorded, the calculated result will be too low, which may lead to an incorrect conclusion that the control threshold has not been reached.

    2.3 Determining Terminal Entities

    Penetration must define when to stop. Common approaches are:

    • If the shareholder is a natural person, stop penetration.
    • If the shareholder is an entity whose upper-level ownership data cannot be obtained, record it as a terminal entity and mark the data as missing.
    • If the shareholder belongs to a type explicitly listed in business rules as a stopping point, such as certain publicly traded entities or specific types of state-owned entities, stop penetration and record the reason.

    Specific stopping conditions should be based on business rules and compliance requirements, and managed as configuration in code rather than hard-coded in the logic.

    3. Data Model Design

    An ownership relationship is essentially a directed weighted graph. Nodes are companies or natural persons, directed edges represent “shareholding,” and edge weights are ownership ratios.

    3.1 Node Identifiers

    Node identifiers are the foundation of penetration accuracy. Companies with the same name and natural persons with the same name are very common, and linking records by name alone can cause serious errors. Recommendations:

    • For companies, use a government-issued business registration identifier as the primary key, such as China’s unified social credit code.
    • For natural persons, use a masked and encrypted ID number or internal identifier as the primary key. Do not store plaintext identifiers in logs or intermediate results.
    • For entities whose identifiers cannot be obtained, create a separate temporary ID and mark it as pending verification. Do not merge it directly with other records.

    3.2 Edge Storage

    An edge should contain at least the following fields:

    Field Meaning
    holder_id Shareholder identifier
    company_id Identifier of the company being held
    ratio Ownership ratio
    effective_date Effective date
    source Data source

    With an effective date, penetration can be performed as of a specified point in time, which is important for historical review and auditing.

    3.3 Storage Choice

    If the data volume is small, a relational database can be used to store the edge table, with traversal performed in the application layer after reading the data. If multi-layer queries need to be executed frequently, a graph database can be selected, or appropriate indexes can be built on a relational database to reduce round trips per query. The choice should be based on query depth, concurrency, and data update frequency, not on technology preference.

    4. Algorithm Implementation

    Penetration is essentially a graph traversal starting from the target node. Both depth-first and breadth-first search can accomplish the task. Depth-first search is simple to implement and suitable for path calculation; breadth-first search makes it easier to control depth by layer. The following example is based on depth-first search and handles ratio multiplication, multi-path summation, and cycle detection at the same time.

    1. from collections import defaultdict
    2. def penetrate(holdings, target, max_depth=10):
    3. """
    4. Calculate the penetrated ownership ratios of terminal shareholders for target.
    5. holdings: {company_id: [(shareholder_id, ownership_ratio), ...]}, ratios are decimals between 0 and 1
    6. target: target company ID
    7. max_depth: maximum penetration depth to prevent infinite recursion caused by abnormal data
    8. returns: {terminal_shareholder_id: penetrated_ownership_ratio}
    9. """
    10. result = defaultdict(float)
    11. def dfs(company, ratio, depth, path):
    12. if depth >= max_depth:
    13. return
    14. for shareholder, share in holdings.get(company, []):
    15. if shareholder in path:
    16. # Circular ownership detected; skip this branch and record it for manual review.
    17. continue
    18. effective = ratio * share
    19. if shareholder in holdings:
    20. # The shareholder also has upper-level ownership data, so continue penetration.
    21. dfs(shareholder, effective, depth + 1, path | {shareholder})
    22. else:
    23. # Terminal entity; accumulate into the result (multi-path summation happens here).
    24. result[shareholder] += effective
    25. dfs(target, 1.0, 0, frozenset({target}))
    26. return dict(result)
    27. if __name__ == "__main__":
    28. holdings = {
    29. "C": [("A", 0.10), ("B", 0.50)],
    30. "B": [("A", 0.60)],
    31. }
    32. print(penetrate(holdings, "C")) # Output: {'A': 0.4}

    There are several points to note in this code:

    1. path records the nodes on the current recursion path and is used to identify circular ownership. If a global visited set were used directly, another legitimate path to the same terminal shareholder would be incorrectly skipped. Therefore, deduplication should be performed by path, not by global node.
    2. max_depth is a safety valve. Abnormally long chains are not uncommon in real data, and setting an upper limit helps avoid stack overflow.
    3. Terminal determination only checks whether the node has upper-level data. In actual business logic, the stopping rules from Section 2 also need to be applied. It is recommended to pass stopping rules in as parameters.

    5. Precision and Edge Cases

    5.1 Ratio Precision

    Floating-point numbers produce rounding errors during repeated multiplication. When ratios are close to control thresholds such as 50% or 25%, errors may change the judgment result. One of the following approaches is recommended:

    • Use a decimal type, such as Decimal in the Python standard library, and explicitly specify precision.
    • Store ratios as integer basis points (1 basis point equals one ten-thousandth, or 0.01%), with multiplication results rounded at each step or retained to a fixed number of digits.

    Whichever approach is used, the rounding rule should be documented and the same rule should be used when comparing thresholds.

    5.2 Circular Ownership

    Circular ownership means that A holds B, B holds A, or a path returns to the starting point after multiple nodes. Theoretically, exact ratios for such structures require solving a system of linear equations, but in compliance and due diligence scenarios, a more common approach is:

    • Upon detecting a cycle, abort that branch and mark the path as abnormal.
    • Perform manual review of abnormal paths and, when necessary, provide an approximate conclusion according to business rules.

    Do not silently ignore cycles; otherwise, the results may contain systematic bias.

    5.3 Missing Data and Point-in-Time Issues

    Missing data is one of the most common problems in penetration. Ownership information at a certain layer may be undisclosed, or only some shareholders may be disclosed. It is recommended that the result include two types of information: the calculated ratio and whether there are branches that were not fully penetrated. Only then can downstream users judge the reliability of the conclusion.

    Ownership changes over time. If no point in time is specified, the penetration result for the same company may differ at different times. Calculations should always specify a base date and retain historical versions.

    5.4 Different Identities of the Same Party

    The same natural person may hold shares in their own name, or indirectly through a spouse, relatives, or entities they control. Whether to merge these identities depends on the definition of the specific business and should be uniformly defined at the rule level rather than handled ad hoc in code.

    6. Engineering Implementation Recommendations

    6.1 Layered Design

    It is recommended to split the system into three layers:

    1. Data ingestion layer: responsible for importing, validating, and standardizing ownership data, and recording data sources and update times.
    2. Computation layer: implements the traversal logic from Section 4 and the edge-case handling from Section 5, with a point-in-time ownership snapshot as input.
    3. Output layer: returns penetration results, abnormal branch lists, and calculation parameters for use by reporting or risk control systems.

    With this layering, rule changes only require modifying the computation layer configuration and do not affect data ingestion.

    6.2 Test Strategy

    The penetration module should have systematic test cases covering at least the following situations:

    • Single-layer direct ownership.
    • Multi-layer single-path ownership.
    • Multi-path aggregation where path ratios cross a control threshold.
    • Circular ownership.
    • Depth exceeding the limit.
    • Missing data at a certain layer.
    • Same name but different entities.

    Each test case should provide manually calculated expected values. These expected values should be reviewed by business personnel rather than generated by the program and then treated directly as the correct answer.

    6.3 Security and Compliance

    Ownership data contains personal information and sensitive commercial information, so the principle of least privilege should be followed:

    • The computation service should read only the required fields and should not access unrelated personal information.
    • Logs should not output sensitive content such as full ID numbers or detailed ownership records; only request identifiers and count metrics should be recorded.
    • Access to penetration results should have audit records, including who queried which company and when.
    • Data storage and transmission should be encrypted, and keys should be hosted by a dedicated key management service rather than written into code or configuration files.

    6.4 Performance Considerations

    Ownership structures are usually not deep, but popular companies may be referenced by a large number of companies. The main cost of penetration comes from repeated queries. The following measures can be taken:

    • Cache upper-level shareholder results for nodes that have already been calculated, and invalidate related caches when ownership changes.
    • For batch queries, load the relevant subgraph once and then compute in memory to reduce database round trips.
    • For very large graphs, shard by industry or region, but ensure that cross-shard ownership relationships are not missed.

    7. Common Pitfalls

    • Looking only at first-layer shareholders and assuming penetration is complete.
    • Ignoring multi-path aggregation and using only the ratio from one path.
    • Linking records directly by company name, causing companies with the same name to be incorrectly merged.
    • Comparing thresholds directly with floating-point numbers and ignoring rounding errors.
    • Exiting with an error immediately upon encountering circular ownership without recording the anomaly, making the problem impossible to trace.
    • Treating penetration results as absolute conclusions without marking missing data and point in time.

    Avoiding these pitfalls is necessary for penetration results to support reliable judgments. The hard part of equity penetration is not the algorithm itself, but data quality, rule definition, and result explainability. Module design should prioritize these three aspects before considering performance and scalability.