Mean-variance portfolio optimization via Conjugate Gradient — 40-60× faster than the legacy Neumann path, with full provenance metadata and automatic fallback.
npx clawhub@latest install trader-portfolio-cgTrader 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.
npx clawhub@latest install trader-portfolio-cgClick the Install button at the top of this page for one-click setup
neural-trader available and cannot install it, as the skill depends on it for covariance and return data.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.
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.
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.
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.
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.
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 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.
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.
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.
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.
neural-trader npm package — auto-installed via npm install --ignore-scripts neural-trader if not presentmcp__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 toolscovariance: number[][] (n × n SPD) and expectedReturns: number[] (length n)trading-risk AgentDB namespace must be accessible (ADR-126 Phase 1 five-namespace alignment)npx clawhub@latest install trader-portfolio-cgLog in to write a review
No reviews yet. Be the first to share your experience!