trader-portfolio-cg

Originally fromruvnet/ruflo
Installation
SKILL.md

Solve the mean-variance optimization Σ · x = μ via Conjugate Gradient instead of the legacy Neumann series.

Why CG instead of Neumann (ADR-123 Wedge 8):

  • Neumann series: ~50 µs at n=256 (legacy npx neural-trader --portfolio optimize)
  • Conjugate Gradient: ~816 ns at n=256 (this skill)
  • Measured speedup: 40-60×; parity within 1e-4 on a fixed seed.

The covariance matrix Σ is symmetric positive-definite by construction (it's a Gram matrix on real returns), so CG is provably optimal — it converges in at most n iterations with no preconditioning, and typically far fewer when eigenvalues cluster.

Disable flag: set RUFLO_NEURAL_TRADER_DISABLE_CG=1 to skip the CG path entirely and fall through to step 4's legacy Neumann route. Useful for A/B validation or when an upstream covariance regression breaks SPD.

Native dispatch flag: set RUFLO_SUBLINEAR_NATIVE=1 to force the adapter to attempt the native mcp__ruflo-sublinear__solve path even when globalThis doesn't expose the tool (e.g. when the harness mounts it via a different transport). On any native-dispatch failure the adapter cleanly falls back to the local JS CG and records method: 'cg-local' in the artifact metadata — so the regression is auditable.

Steps:

  1. Ensure neural-trader is available:
    npm ls neural-trader 2>/dev/null || npm install --ignore-scripts neural-trader
    
Installs
29
GitHub Stars
61.6K
First Seen
May 20, 2026
trader-portfolio-cg — ruvnet/claude-flow