MyClaw
HomeProductsUse CasesPricingSkillsResourcesCompany
HomeUse CasesPricingSkills
Sign In
Home
ProductsOpenClaw HostingHermes Agent Hosting
Use CasesPricingSkills
ResourcesCompareTutorialLearnBlogUpdatesResourcesCommunity
CompanyAboutSupport
Sign In
MyClaw.ai

Your AI agent, already running.

Product

OpenClaw HostingHermes Agent HostingUse CasesPricingCompareAlibaba Cloud

Resources

BlogUpdatesSkillsModelsSupportCommunityCapybara

Legal

TermsPrivacyCookieGDPRContact

© 2023 Cubo World Inc. All rights reserved.

← Back to Skills
Data & Analytics
💼

Trader Portfolio CG

Mean-variance portfolio optimization via Conjugate Gradient — 40-60× faster than the legacy Neumann path, with full provenance metadata and automatic fallback.

by ruvnetv1.0.0
Connecting to VM...
Connecting to VM...
npx clawhub@latest install trader-portfolio-cg
4.0kStars
1.4kDownloads
0Current Installs
📦
v1.0.0Version
View Source

Trader Portfolio CG Skill Overview

Trader Portfolio CG solves the mean-variance optimization problem Σ · x = μ using the Conjugate Gradient algorithm, delivering 40-60× lower latency than the legacy Neumann series path. It dispatches through the SublinearAdapter — using the native mcp__ruflo-sublinear__solve kernel when available, or a local JS CG fallback otherwise — and stores every result with full provenance metadata in the trading-risk AgentDB namespace.

How to Use It

Step 1: Run in your terminal or install this skill on MyClaw

npx clawhub@latest install trader-portfolio-cg
or

Click the Install button at the top of this page for one-click setup

When to Use Trader Portfolio CG

Best Fit

  • You need sub-millisecond portfolio weight computation at n=256 or similar scale and the legacy Neumann path is a bottleneck.
  • Your workflow requires auditable, reproducible weight artifacts with solver provenance (method, backend, residual, latency) for compliance or Phase 4 signing.
  • You want a single skill that handles both the fast native CG path and a safe fallback to legacy Neumann without manual intervention.
  • You are running A/B validation between CG and Neumann outputs and need clean metadata to distinguish which backend produced each artifact.

When Not to Use

  • Your covariance matrix is not symmetric positive-definite and you cannot supply a valid SPD input — the CG path will degrade to the Neumann fallback automatically, but the speedup benefit is lost.
  • You do not have neural-trader available and cannot install it, as the skill depends on it for covariance and return data.
  • You need a fully self-contained solver with no external npm dependencies in a locked-down environment.

Key Features

40-60× Speedup over Legacy Neumann

CG solves Σ · x = μ at ~816 ns vs ~50 µs for the Neumann series at n=256, as measured in portfolio-cg.bench.ts. The covariance matrix is symmetric positive-definite by construction, making CG provably optimal with convergence in at most n iterations.

Transparent Native / Local Fallback

The SublinearAdapter probes for mcp__ruflo-sublinear__solve on globalThis and routes to the native kernel when reachable. On any failure it falls back silently to the embedded local JS CG — the math is identical either way, and result.method records which backend ran.

Full Provenance Metadata

Every stored artifact includes method, solver, iterations, residual, latencyMs, capturedAt, and an optional reason field. This makes every weight vector fully auditable and ready for Ed25519 signing in ADR-126 Phase 4.

Disable and Override Flags

Set RUFLO_NEURAL_TRADER_DISABLE_CG=1 to skip CG and use the legacy Neumann route — useful for A/B validation. Set RUFLO_SUBLINEAR_NATIVE=1 to force native kernel dispatch even when globalThis doesn't expose the tool.

Historical Pattern Cross-Check

After computing weights, the skill optionally queries mcp__claude-flow__agentdb_pattern-search against historical Sharpe/regime patterns. Any single-asset deviation above 30% from the historical median is flagged for human review before the weights are applied.

Graceful Non-SPD Fallback

If the covariance matrix fails SPD checks (non-square, non-positive-definite, or MCP error), result.degraded is set to true and the skill falls through to the legacy npx neural-trader --portfolio optimize Neumann path, tagging the artifact with method: 'neumann-fallback' and a reason field.

Use Cases

High-Frequency Portfolio Rebalancing

Use this skill when rebalancing needs to happen at low latency — the CG path targets under 1 ms on n=256 covariance, making it suitable for workflows that recompute weights frequently throughout a trading session.

Auditable Weight Artifacts

When your compliance or risk workflow requires a signed, reproducible record of how each set of portfolio weights was computed, the provenance metadata stored in trading-risk provides the full solver trail needed for ADR-126 Phase 4 Ed25519 signing.

CG vs Neumann A/B Validation

Set RUFLO_NEURAL_TRADER_DISABLE_CG=1 on one run and leave it unset on another to produce two artifacts from the same covariance input. The method field in each artifact makes it straightforward to compare outputs and verify parity within 1e-4.

Regime-Aware Allocation Guard

The historical pattern cross-check queries prior weights by Sharpe and market regime, flagging anomalous shifts before they are applied — useful in volatile regimes where a covariance regression could produce spurious weight vectors.

Requirements

  • neural-trader npm package — auto-installed via npm install --ignore-scripts neural-trader if not present
  • mcp__ruflo-sublinear__solve MCP tool (optional — skill falls back to local JS CG if unavailable)
  • mcp__claude-flow__memory_store, mcp__claude-flow__memory_retrieve, mcp__claude-flow__memory_search, mcp__claude-flow__agentdb_pattern-search claude-flow MCP tools
  • Portfolio API response must include covariance: number[][] (n × n SPD) and expectedReturns: number[] (length n)
  • trading-risk AgentDB namespace must be accessible (ADR-126 Phase 1 five-namespace alignment)
Connecting to VM...
npx clawhub@latest install trader-portfolio-cg
4.0kStars
1.4kDownloads
0Current Installs
📦
v1.0.0Version
View Source

Reviews

0 reviews

Log in to write a review

No reviews yet. Be the first to share your experience!