What problem does it solve?
Mean-variance portfolio optimization requires solving the linear system Σ·x = μ, and the legacy Neumann series approach takes roughly 50 µs at n=256. This Skill replaces that path with Conjugate Gradient, which exploits the symmetric positive-definite structure of covariance matrices to converge in far fewer iterations, achieving a measured 40-60× speedup while maintaining parity within 1e-4 of the legacy result.
Core Features & Use Cases
- Conjugate Gradient Solver: Solves Σ·x = μ through a SublinearAdapter that dispatches to a native MCP solver when available and falls back to an embedded local JS CG implementation otherwise.
- Graceful Degradation: Automatically falls back to the legacy Neumann CLI path when input fails SPD checks, the matrix is non-square, or the disable flag RUFLO_NEURAL_TRADER_DISABLE_CG=1 is set.
- Auditable Provenance: Stores optimal weights in the trading-risk memory namespace with method, solver, iterations, residual, and latency metadata so operators can verify which backend produced each artifact.
- Use Case: A quantitative trading operator needs to rebalance a 256-asset portfolio under a latency budget. The skill reads the current covariance matrix and expected returns from neural-trader, solves for optimal weights in under 1 ms, cross-checks against historical patterns, and flags deviations over 30% for human review.
Quick Start
Ask the agent to optimize the current portfolio using Conjugate Gradient with a tolerance of 1e-6 and store the resulting weights with full provenance metadata.