Merge overlapping stock strategies into one funded portfolio
Two stock strategies can each be fully invested and both hold the same security. Combining their targets requires a shared capital budget and one security identity map before applying portfolio limits. Adding two full-weight vectors produces two units of exposure, not a funded one-account allocation, and separate strategy limits may leave the combined position too large.
This guide merges two long-only, same-currency sleeves, records a cap-to-cash adjustment and executes two synthetic rebalances. It is an external extension, not verified CoTrading shared-account routing. All prices, weights and zero-cost fills are invented; no real trading or historical-performance claim is made.
Define sleeve budgets before merging stocks
Assign each strategy a fraction of the one portfolio’s capital. Our budgets are 0.6 for S1 and 0.4 for S2. Each sleeve’s own stock weights sum to one, and the budgets themselves sum to one. Multiplying the two levels gives portfolio-level contributions.
If a real policy permits an unassigned capital reserve, represent that reserve explicitly. This sample requires a complete budget and rejects a total other than one; it does not silently normalize overallocated strategies. Borrowing, short targets and multiple currencies are outside its contract.
Freeze the target timestamps, strategy versions and missing-sleeve policy. A new S1 target combined with an unexplained stale S2 target is not the same experiment as synchronized outputs. The sample requires the available sleeve identities to match the budget list exactly.
Resolve security identity across strategies
S1 calls the shared security AAA, while S2 calls it A_ALIAS. The supplied identity map resolves both to canonical A; BBB and CCC resolve to B and C. This map is explicit fixture data, not an automatic ticker resolver or a claim that similar display names imply the same security.
The FINRA concentration discussion notes that overlapping exposures can create concentration. Our algorithm concerns strategy targets rather than fund look-through. It creates one direct-stock target ledger and does not infer any unobserved underlying holdings.
Unknown identities block merging rather than being dropped and their remaining weights renormalized. Keep share class, market and currency distinctions appropriate to the real security master. An incorrect merge can hide actual concentration or create a false overlap before the cap is even checked.
Validate vectors before arithmetic
Check every sleeve weight and budget is finite and nonnegative, then apply the sum-to-one tolerance. The Python isfinite documentation supports the explicit NaN and infinity guard. A budget check alone can let NaN bypass a greater-than comparison.
The sample rejects nonfinite vectors and budgets 0.6 plus 0.6. It also constructs the naive unbudgeted sum of the two fully invested strategies and confirms its total is two, which is rejected as a one-portfolio allocation.
Do not treat a target’s valid normalization as proof that its trades can be funded. Weight validation precedes security aggregation, portfolio constraint adjustment and account execution. Each stage has its own output and failure reason rather than one broad success flag.
Reconstruct the first merged target
S1 holds A 0.7 and B 0.3 inside its sleeve; S2 holds A 0.5 and C 0.5. Apply capital budgets before summing repeated securities:
| Contribution row | A | B | C | Cash |
|---|---|---|---|---|
| S1 budget 0.6 | 0.42 | 0.18 | 0 | 0 |
| S2 budget 0.4 | 0.20 | 0 | 0.20 | 0 |
| Raw combined | 0.62 | 0.18 | 0.20 | 0 |
| Cap adjustment | −0.12 | 0 | 0 | +0.12 |
| Admitted target | 0.50 | 0.18 | 0.20 | 0.12 |
Each raw security weight can be reconstructed from sleeve contributions. A exceeds the common single-stock cap of 0.5. Our declared policy clips the excess into cash without redistributing it to B or C. That is one explicit policy, not a general constrained optimizer.
Keep the adjustment as a separate row. The raw sleeve instructions cannot all remain exactly satisfied after the common cap. Do not silently attribute the final capped A weight back to S1 or S2 without an additional allocation rule. Raw contributions plus the adjustment reproduce the admitted aggregate.
Execute the first funded account
Starting cash is 1000 and all three prices are 100. The admitted target buys A five shares, B 1.8 and C two, leaving cash 120. Fractional shares and zero fees are intentional simplifications. A real implementation needs its lot, cost and rejection policy before calling these orders executable.
The next marks are A 110, B 100 and C 90, producing NAV 1030 from actual quantities and cash. The cash reserve is still present; do not normalize securities-only weights to pretend the first target was fully invested.
One account ledger is used throughout. Running each strategy on a separate 1000 and adding their equity would answer a different two-account, 2000-capital question. It would not verify the common budget or the single-stock cap of this experiment.
Merge and execute the second period
S1’s next internal weights are A 0.4 and B 0.6; S2’s are A 0.25 and C 0.75. The same budgets produce aggregate A 0.34, B 0.36 and C 0.30. All pass the 0.5 cap, so no new cash reserve is required by the clipping policy.
At current NAV 1030 and prices 110/100/90, target quantities are approximately A 3.183636, B 3.708 and C 3.433333. Actual changes sell about 1.816364 A shares, buy 1.908 B and buy 1.433333 C. The runner sells first and checks nonnegative cash after each operation.
The following marks are 100, 105 and 95. Ending value is 1033.870303, checked within an absolute tolerance of 1e-8 against the unrounded reference. This is the two-period synthetic account result, not the sum of independent strategy returns or a promise about an investment sleeve’s performance.
Preserve policy and execution conflicts
Record each sleeve’s original target, timestamp, budget contribution, canonical identity, raw merge, cap adjustment and admitted target. Then attach requested and actual fills, cash and resulting holdings. A conflict is not resolved merely because a final vector sums to one.
If a sale is blocked in a real implementation, do not credit its planned proceeds to another sleeve’s buy. If a sleeve’s target is unavailable, follow the declared hold, cash or stop policy rather than silently scaling up the others. The fixture blocks missing sleeve identities but does not implement a full asynchronous strategy scheduler.
The cap affects this merged output only. It does not demonstrate that arbitrary strategy code has been prevented from submitting other orders or that a broker enforces the same limit. Shared-account governance and execution authorization require separate integration evidence.
Review the merge contract before execution
Attach currency, target horizon and information time to each sleeve record, not just a strategy name. A normalized vector from another currency cannot be admitted by this same-currency routine merely because its weights are dimensionless. A stale target may be technically readable while failing the declared synchronization policy; retain that limitation instead of silently treating it as current.
Both fixture sleeves declare USD; a USD/HKD merge is actually rejected rather than converted.
If an alternative policy redistributes capped excess, recheck every resulting stock and sector constraint. Redistribution can create a new violation elsewhere. Our cash policy deliberately avoids that secondary allocation problem, but it does not solve every possible mandate. After real lot conversion or execution rejection, compare achieved portfolio weights with the admitted target again. A valid aggregate target does not certify the later funded account, and later price drift can create another exception.
Execute and accept the merged ledger
Download the complete example. Use Python 3.12 or later and run python R637.py. Standard-library assertions verify sleeve contribution recovery, raw A 0.62, capped A 0.5 and cash 0.12, funded trades, ending value and rejection of nonfinite, unknown-identity and overbudget inputs.
Accept when capital is counted once, duplicates use the approved identity map, portfolio adjustments remain visible and every trade traces to the admitted combined target. Preserve all sleeve instructions even when a cap prevents following them exactly.
Rebuild after budgets, targets, identity mapping, constraints, prices or execution rules change. The example demonstrates synthetic multi-strategy allocation and account reconstruction only, without verifying product integration or real market profitability.
FAQ
Can two full-investment strategy weights simply be added?
No. Apply their shared capital budgets before aggregating securities.
Must excess above a cap be redistributed?
Not under this policy. It becomes explicit cash; another redistribution rule would be another experiment.