/algo-trading-skills:multi-account-same-strategy-fan-outfrom algo-trading-skills
Apportions a master trading signal across sub-accounts using the largest-remainder (Hamilton) method so per-account quantities sum exactly to the parent, with deterministic client order IDs and an auditable record.
Ships in algo-trading-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Invoke this skill when a single master signal — "Buy 1,000 shares of AAPL" — has to be turned into per-account order quantities across $N$ sub-accounts, and each account must genuinely require its own order: separate broker connections, separate venues, separate legal entities, or a broker with no bunched-order facility.
The core problem is not latency, it is apportionment. Sizing each account independently and rounding — round(Q_master × w_i) per account — does not sum back to the master quantity. Three equal-NAV accounts splitting 10 shares round to 3 each and never trade the tenth share; four equal accounts splitting 6 shares each round 1.5 up to 2 and dispatch 8 shares for a 6-share signal. This skill apportions by the largest-remainder (Hamilton) method so the per-account quantities sum to $Q_{\text{master}}$ exactly, assigns deterministic client order IDs that a retry can reproduce, and records the basis behind every quantity so the split is independently verifiable.
faGroup and faMethod (NetLiq, AvailableEquity, EqualQuantity, PctChange) and IBKR performs the allocation server-side. Re-implementing the split client-side and sending N orders instead gives up the broker's average pricing and doubles the reconciliation surface.ALLOCATION_METHOD_WEIGHT, not against NAV.multi-strategy-capital-allocation-limits and cross-account-aggregate-risk-view.PRO_RATA_NAV) or explicit weight (EXPLICIT_WEIGHT).min_order_qty policy — the quantity below which an account is excluded from the batch rather than given a token order.Register Sub-Accounts and Snapshot the Basis:
Choose the Allocation Basis:
EXPLICIT_WEIGHT.EXPLICIT_WEIGHT with a missing weight must raise, never fall back to NAV. A silent fallback unwinds the wrong quantity from every account at once.Apportion by Largest Remainder:
account_id ascending.round() is round-half-to-even: round(2.5) == 2 but round(3.5) == 4, so two accounts with near-identical entitlements receive different quantities and the total drifts off the master signal in either direction.Apply the Minimum-Quantity Floor by Exclusion, Not by Inflation:
min_order_qty is dropped, and its shares are re-apportioned across the survivors. Repeat until every remaining allocation clears the floor.max(min_order_qty, share). Raising every account to the floor mints quantity the master signal never authorised: 50 accounts with a 1-share floor turn a 10-share signal into 50 shares, and on a SELL it opens a short in an account whose fair share was zero.is_fully_allocated is false and the shortfall was not traded; the caller must decide whether to re-batch, not discover the gap at reconciliation.Assign Deterministic Client Order IDs:
{prefix}_{batch_id}_{account_id}, a pure function of the batch.batch_id. Minting a fresh ID on retry is how a fan-out double-executes: the broker may already have accepted the first order and has no way to recognise the second as the same instruction. See order-placement-idempotency.Dispatch, Then Reconcile Against the Recorded Basis:
allocation_basis, allocation_weight, exact_quantity and received_remainder_share per order. 17 CFR 1.35(b)(5)(iv)(C) requires a methodology objective enough to permit independent verification of the split, and (b)(5)(v) requires records reconstructing the order from placement through to allocation.Full procedure: see
references/workflows.md. Standards reference: seereferences/standards.md. Printable pre-flight checklist: seeassets/checklist.md.
round(Q × w_i) per account under-executes (3 equal accounts × 10 shares → 9 dispatched) or over-executes (4 equal accounts × 6 shares → 8 dispatched) with no error raised. The shortfall is an un-traded position and the excess is unauthorised exposure; both surface days later in reconciliation, not at dispatch.max(min_order_qty, share) guarantees every account a share regardless of entitlement. An account holding 0.01% of NAV receiving 1 share out of a 10-share signal has received 1,000× its pro-rata entitlement, taken from the other clients — the "consistently favorable treatment" 17 CFR 1.35(b)(5)(iv)(B) prohibits.self._seq += 1 is a read-modify-write. Under the concurrent dispatch this skill is used for, two threads can read the same value and emit the same "collision-free" ID, and a process restart resets the counter to zero.received_remainder_share and rotate if the distribution skews.-100 quantity fanned out pro-rata produces negative per-account quantities that a broker adapter may reinterpret arbitrarily. Direction belongs in action; the quantity must be a positive integer.{4, 3, 3} summing to exactly 10 — not {3, 3, 3} summing to 9. Repeat with 4 equal accounts and 6 shares: expect {2, 2, 1, 1} summing to 6, not {2, 2, 2, 2} summing to 8.min_order_qty=5 and 100 shares must drop the third account and re-apportion to {51, 49}, still summing to 100.batch_id must emit byte-identical client order IDs; two calls without one must not collide.python -m unittest discover -s skills/multi-account-same-strategy-fan-out/scripts and confirm 100% pass rate.order-placement-idempotencyminimum-fill-size-and-lot-rounding-logiccross-account-aggregate-risk-viewmulti-broker-consolidated-position-viewmulti-strategy-capital-allocation-limitsbroker-failover-secondary-account-routingbest-execution-record-keeping-globalWhat SKILL.md sets; muted values are Claude Code's defaults
36 skills in this plugin
/alpaca-paper-live-key-separationUse when a bot connects to the Alpaca Trading API and must never cross paper keys with the live endpoint; pins the base URL per environment, checks the key prefix, probes /v2/account and requires an explicit ALLOW_LIVE_TRADING flag./api-key-least-privilege-audit-toolUse before deploying a live bot, to audit existing broker API keys for scopes they do not need. Flags withdrawal, transfer and admin rights that turn a leaked execution key into theft./broker-account-margin-call-handlingUse when a bot trades a Reg T, portfolio or futures margin account and must act before the broker liquidates: tiered maintenance-margin warnings cross-checked against broker excess liquidity, initial-margin order gating and liquidity-aware de-leveraging./broker-agnostic-adapter-interfaceUse when strategy code must run across several brokers and should not import kiteconnect, alpaca-py or ibapi directly; defines an adapter contract with Decimal prices, typed exceptions and normalised order status across venues./broker-api-changelog-diffing-toolUse before upgrading a broker SDK or OpenAPI spec, to diff two schema snapshots for removed endpoints, newly required parameters, enum mutations and type changes so CI fails before the change reaches an order path./broker-api-deprecation-notice-monitoringUse when a long-running bot calls REST endpoints a broker may retire; parses RFC 8594 Sunset and RFC 9745 Deprecation headers plus changelog feeds into one dated migration deadline with an escalation tier.npx claudepluginhub himanshuj16/algo-trading-skills --plugin algo-trading-broker-integrationOther plugins' skills for the same job