Skip to content

docs(strategies): add strategy composition guide and register in nav - #1208

Open
camesenin wants to merge 3 commits into
drydocs:mainfrom
camesenin:docs/strategy-composition-guide-1202
Open

camesenin wants to merge 3 commits into
drydocs:mainfrom
camesenin:docs/strategy-composition-guide-1202

Conversation

@camesenin

Copy link
Copy Markdown

Summary

Adds �pps/docs/strategies/composition.md documenting the strategy composition model, capital allocation mechanics (Hamilton largest-remainder rule), composition constraints, composed backtest runner, return attribution, and correlation matrix with a worked composed backtest example.

Resolves #1202

Changes

  • Created �pps/docs/strategies/composition.md covering:
    • ComposedStrategy model, deterministic lifecycle (init, step,
      ebalance, close), and namespacing by (memberId, asset).
    • Largest-remainder capital allocation (�llocateCapital) preventing fractional residual dust.
    • ConstraintEngine caps and drawdown limits.

unComposedBacktest bottom-up reconciliation.

  • correlationMatrix symmetric unit diagonal and zero-variance handling.
  • Complete reproducible simulation example composing Self-Repaying Loan and Delta-Neutral strategies.
  • Explicit simulation-only declaration consistent with delta-neutral.md.
  • Registered Strategy Composition Guide in �pps/docs/.vitepress/config.ts under Strategies navigation.

Verification

  • Verified Markdown formatting and structure.
  • Navigation links match VitePress router path.

@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Collins' projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@camesenin Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@camesenin the guide is a useful addition, but it needs a formatting pass and its examples do not match the composition APIs. Lint & Typecheck fails on apps/docs/strategies/composition.md (Prettier, trailing whitespace at line 193), and the sample code references symbols that the composition PRs do not export. Run pnpm format, then align the examples with the real surface: ComposedStrategy constructed with { id, strategy, allocation, config }, allocateCapital, and correlationMatrix, which returns a 2D array.

Comment thread apps/docs/strategies/composition.md Outdated
export interface StrategyMember {
id: string;
strategy: Strategy;
weight: Decimal;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The member field is allocation, not weight, and its type is FixedPointDecimal, not Decimal. This is how ComposedStrategyMember is actually shaped.

Comment thread apps/docs/strategies/composition.md Outdated
});

// 2. Define composite strategy with 70/30 capital split
const composed = createComposedStrategy({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no createComposedStrategy factory. The implementation exports the ComposedStrategy class, constructed with an array of { id, strategy, allocation, config }.

Comment thread apps/docs/strategies/composition.md Outdated
// 2. Define composite strategy with 70/30 capital split
const composed = createComposedStrategy({
members: [
{ id: "srl-core", strategy: srl, weight: FixedPointDecimal.from("0.70") },

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FixedPointDecimal has no static from. The parse helper is FixedPointDecimal.fromString.

Comment thread apps/docs/strategies/composition.md Outdated
});

// 3. Execute backtest
const result = await runComposedBacktest(composed, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runComposedBacktest is not exported. A composed strategy is driven through the existing runBacktest.

Comment thread apps/docs/strategies/composition.md Outdated

// 5. Compute return correlation
const matrix = correlationMatrix(result.memberReturns);
console.log("Pairwise correlation:", matrix.get("srl-core", "dn-hedge"));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correlationMatrix returns a readonly (readonly CorrelationEntry[])[], so index it as matrix[i][j]; it has no .get method.

Comment thread apps/docs/strategies/composition.md Outdated
| **Borrow & Trading Fees** | -$120.00 | -$380.00 | -$500.00 |
| **Net PnL** | +$3,730.00 | +$760.00 | +$4,490.00 |

**Correlation analysis:**

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trailing whitespace here is what Prettier flags. Run pnpm format.

@camesenin
camesenin force-pushed the docs/strategy-composition-guide-1202 branch from e9f998f to dfe0456 Compare October 20, 2026 17:42
@camesenin

Copy link
Copy Markdown
Author

Thanks @collinsezedike! Addressed all 6 review comments:

  • Updated the member interface to ComposedStrategyMember with �llocation: FixedPointDecimal.
  • Fixed the composite instantiation to
    ew ComposedStrategy([...]).
  • Corrected decimal parsing to FixedPointDecimal.fromString(...).
  • Routed execution through the standard
    unBacktest(...) runner.
  • Updated the correlation matrix lookup to direct indexing matrix[i][j].
  • Cleaned up trailing whitespace and formatted cleanly.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SDK] Write the strategy composition guide

2 participants