Repository navigation
Conversation
|
Someone is attempting to deploy a commit to the Collins' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@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! 🚀 |
collinsezedike
left a comment
There was a problem hiding this comment.
@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.
| export interface StrategyMember { | ||
| id: string; | ||
| strategy: Strategy; | ||
| weight: Decimal; |
There was a problem hiding this comment.
The member field is allocation, not weight, and its type is FixedPointDecimal, not Decimal. This is how ComposedStrategyMember is actually shaped.
| }); | ||
|
|
||
| // 2. Define composite strategy with 70/30 capital split | ||
| const composed = createComposedStrategy({ |
There was a problem hiding this comment.
There is no createComposedStrategy factory. The implementation exports the ComposedStrategy class, constructed with an array of { id, strategy, allocation, config }.
| // 2. Define composite strategy with 70/30 capital split | ||
| const composed = createComposedStrategy({ | ||
| members: [ | ||
| { id: "srl-core", strategy: srl, weight: FixedPointDecimal.from("0.70") }, |
There was a problem hiding this comment.
FixedPointDecimal has no static from. The parse helper is FixedPointDecimal.fromString.
| }); | ||
|
|
||
| // 3. Execute backtest | ||
| const result = await runComposedBacktest(composed, { |
There was a problem hiding this comment.
runComposedBacktest is not exported. A composed strategy is driven through the existing runBacktest.
|
|
||
| // 5. Compute return correlation | ||
| const matrix = correlationMatrix(result.memberReturns); | ||
| console.log("Pairwise correlation:", matrix.get("srl-core", "dn-hedge")); |
There was a problem hiding this comment.
correlationMatrix returns a readonly (readonly CorrelationEntry[])[], so index it as matrix[i][j]; it has no .get method.
| | **Borrow & Trading Fees** | -$120.00 | -$380.00 | -$500.00 | | ||
| | **Net PnL** | +$3,730.00 | +$760.00 | +$4,490.00 | | ||
|
|
||
| **Correlation analysis:** |
There was a problem hiding this comment.
The trailing whitespace here is what Prettier flags. Run pnpm format.
e9f998f to
dfe0456
Compare
|
Thanks @collinsezedike! Addressed all 6 review comments:
|
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
ebalance, close), and namespacing by (memberId, asset).
unComposedBacktest bottom-up reconciliation.
Verification