본문으로 건너뛰기
cccskills
무료GitHub에 공개한국어 소개

trader-portfolio-cg

자산 수익의 연동 관계를 나타내는 공분산 행렬과 기대 수익률로 포트폴리오 비중을 계산합니다. 켤레기울기법을 사용하고 계산 방식과 오차 등의 검증 기록을 저장합니다.

원문원문 설명 보기

Mean-variance portfolio optimization via Conjugate Gradient — 40-60× faster than the legacy Neumann path (ADR-126 Phase 3, ADR-123 Wedge 8)

AI 평가80점/ 100설치 방법 보기

이럴 때 유용합니다

  • 수익 데이터로 자산 비중 계산
  • 기존 방식과 계산 결과 비교
  • 비중과 계산 검증 기록 저장
  • 과거 비중 대비 큰 변화 확인

한국어 소개

할 수 있는 일

자산 수익 사이의 연동 관계를 나타내는 공분산 행렬과 기대 수익률로 포트폴리오 비중을 계산합니다. 연립방정식을 반복해서 푸는 켤레기울기법을 사용하며, 네이티브 MCP 구현을 사용할 수 없으면 로컬 JavaScript 구현으로 전환합니다. 비중과 함께 계산 방식, 반복 횟수, 오차, 소요 시간을 저장합니다.

이럴 때 유용합니다

입력 데이터를 준비해 자산 비중을 계산하거나 기존 Neumann 방식과 결과를 비교할 때 유용합니다. 과거 비중과 대조해 개별 자산의 변화가 클 경우 사람이 확인하도록 표시하는 용도로도 사용할 수 있습니다.

사용 예시

  • “이 공분산 행렬과 기대 수익률로 비중을 계산해 주세요.”
  • “계산 방식과 오차를 포함해 결과를 저장해 주세요.”
  • “과거 비중과 비교하고 큰 차이를 보고해 주세요.”

주의 사항

neural-trader, 전용 어댑터, MCP 저장 도구를 사용합니다. neural-trader 2.8.11은 필요한 행렬과 기대 수익률을 반환하지 않으므로 사용자나 과거 저장 데이터에서 입력을 준비해야 합니다. 켤레기울기법은 대칭 양의 정부호 행렬을 전제로 하며, 입력 조건을 충족하지 못하는 경우 등에는 기존 방식으로 전환합니다. 원문의 속도 비교는 특정 조건에서 측정한 값입니다.

이 소개문은 공개된 SKILL.md를 바탕으로 AI(OpenAI Codex)가 작성했습니다. 정확한 사양은 아래 원문을 확인하세요.

객관 평가

AI가 SKILL.md의 내용만을 근거로 4가지 관점에서 판정했습니다. 스타 수나 인기도는 판정에 넣지 않았습니다.

지시의 명확성언제 쓰고 무엇을 하는지 알 수 있는가
A양호공분산과 기대 수익률로 비중을 계산하고 검증 정보를 저장하는 목적이 명시되어 있습니다.
절차의 구체성절차·입출력·예시가 구체적으로 적혀 있는가
A양호입력 배열 형식, solveCG 인수, 대체 경로와 저장 항목이 구체적으로 제시됩니다.
안전성전송·삭제·명령 실행 등을 명시하고 있는가
B일부 부족npm install과 MCP 데이터 저장을 수행하지만 실행 전 확인 절차는 명시되지 않았습니다.
도입의 용이성필요한 도구나 API 키가 적고 적혀 있는가
B일부 부족neural-trader 설치 명령은 있지만 전용 어댑터와 MCP 도구의 준비 절차는 불완전합니다.

총점은 각 항목을 A=25점, B=15점, C=5점으로 더한 값입니다. 2026년 10월 21일 기준으로 AI(OpenAI Codex)가 판정했습니다. 참고용이므로 설치 전에 원문도 확인해 주세요.

평가가 다르다고 생각되면 재검토를 요청하기

어느 항목이 왜 다르다고 생각하는지 적어 주세요. 로그인은 필요 없습니다. SKILL.md와 대조해 평가를 다시 만들고 이곳에 반영합니다.

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

포함된 파일(1)

  • SKILL.md6.6 KB

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
    
  2. Read the current covariance matrix Σ and expected-return vector μ from neural-trader's portfolio API:

    # neural-trader 2.8.11 does NOT return Σ or μ: `--portfolio current` runs the equal-weight demo
    # (symbols, weights, a risk figure and a note that the returns matrix is not wired).
    # Take Σ and μ from the user (a returns matrix they provide), or from AgentDB if a prior run stored them:
    
    mcp__plugin_ruflo-core_ruflo__memory_search({ query: "covariance matrix current", namespace: "trading-risk", limit: 1 })
    

    The skill expects the response to include covariance: number[][] (n × n) and expectedReturns: number[] (length n).

  3. Solve Σ · x = μ via the SublinearAdapter (preferred path) when RUFLO_NEURAL_TRADER_DISABLE_CG is unset:

    import { sublinearAdapter } from '../../src/sublinear-adapter.mjs';
    const result = await sublinearAdapter.solveCG(COVARIANCE, EXPECTED_RETURNS, {
      tolerance: 1e-6,
      maxIterations: 200,
    });
    // result.solution    — optimal weights (number[])
    // result.iterations  — CG iterations executed
    // result.residual    — final ||A·x − b||₂
    // result.latencyMs   — wall-clock latency
    // result.method      — 'cg-sublinear-native' | 'cg-local'   <-- READ THIS
    // result.solver      — 'sublinear-time-solver@1.7.0' | 'local-js-cg'
    // result.degraded    — true if input failed SPD checks (fall back to step 4)
    

    The adapter does the dispatch itself: it probes for mcp__ruflo-sublinear__solve on globalThis (and honours RUFLO_SUBLINEAR_NATIVE=1 as a manual override), routes through the native kernel when reachable, and falls back transparently to the embedded ~50-LOC JS CG when not. The math is identical either way — CG, dense form, n × n SPD covariance. The operator reads result.method to know which backend produced the artifact.

    The native MCP tool's wire shape (for direct callers who want to bypass the adapter):

    mcp__ruflo-sublinear__solve({
      matrix: COVARIANCE,
      rhs: EXPECTED_RETURNS,
      algorithm: "cg",
      tolerance: 1e-6,
      maxIterations: 200
    })
    

    Output:

    { solution: number[], iterations: number, residual: number }
    
  4. Fallback (legacy Neumann) — if step 3 reports degraded: true (non-SPD input, non-square matrix, MCP error) OR if RUFLO_NEURAL_TRADER_DISABLE_CG=1:

    npx neural-trader --portfolio optimize
    

    Capture the weights output and tag the artifact metadata with method: 'neumann-fallback' and a reason field.

  5. Store the optimal weights to trading-risk namespace with full provenance metadata. Take method and solver straight from the adapter's result so the operator can verify which backend ran:

    mcp__plugin_ruflo-core_ruflo__memory_store({
      key: "portfolio-weights-PORTFOLIO_ID-TIMESTAMP",
      namespace: "trading-risk",
      value: JSON.stringify({
        weights: result.solution,           // number[] from step 3 (or weights from step 4 fallback)
        method: result.method,              // 'cg-sublinear-native' | 'cg-local' | 'neumann-fallback'
        solver: result.solver,              // 'sublinear-time-solver@1.7.0' | 'local-js-cg' | 'neural-trader-cli'
        iterations: result.iterations,
        residual: result.residual,
        latencyMs: result.latencyMs,
        capturedAt: NEW_DATE_ISO,
        reason: FALLBACK_REASON || null
      })
    })
    

    The trading-risk namespace is canonical (ADR-126 Phase 1; the five-namespace alignment). Long-lived — no TTL — because portfolio weights are the audit trail Phase 4 will Ed25519-sign.

  6. Cross-check against historical patterns (optional but recommended):

    mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search({
      query: "portfolio weights Sharpe regime:CURRENT_REGIME",
      namespace: "trading-risk"
    })
    

    If the new weights differ by more than 30% in any single asset from the historical median, flag for human review before applying. This is a guard-rail, not a hard block.

Acceptance criteria (ADR-126 Phase 3):

  • Latency < 1 ms on n = 256 covariance (local JS CG); native path target 40-60× faster (816 ns native vs 50 µs Neumann per sublinear-time-solver@1.7.0).
  • Parity with legacy Neumann within ||cg − neumann||_∞ < 1e-4 on a fixed seed.
  • Fallback path engages cleanly when native MCP unavailable / covariance non-SPD.
  • Artifact metadata distinguishes cg-sublinear-native, cg-local, and neumann-fallback.

Refs:

  • ADR-126 Phase 3 (this skill's authoring ADR)
  • ADR-123 §162 Row 8 (Wedge 8 speedup claim)
  • ADR-123 §262-289 (the SublinearAdapter contract)
  • plugins/ruflo-neural-trader/src/sublinear-adapter.ts (the adapter)
  • plugins/ruflo-neural-trader/benchmarks/portfolio-cg.bench.ts (the measured numbers)

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

add-model-descriptions

무료요약 있음AI 평가 80점

HuggingFace router의 모델 목록과 chat-ui 설정을 비교해 미등록 모델을 조사합니다. 짧은 영어 설명을 작성하고 운영용·개발용 설정에 함께 추가합니다.

  • 라우터의 새 모델을 추가할 때
  • 모델 특징을 짧은 설명으로 정리할 때
  • 운영용·개발용 모델 정보를 함께 갱신할 때
ruvnet/ruflo7.8만2026년 10월 21일 업데이트

adr-create

무료요약 있음AI 평가 80점

기술 선택과 설계 판단을 기록하는 ADR을 기존 파일에 이어지는 번호로 만듭니다. 템플릿 생성, AgentDB 등록과 관련된 과거 결정의 연결을 처리합니다.

  • 기술 도입 이유 기록
  • API나 데이터 모델 변경 기록
  • 인프라 구성 결정 문서화
ruvnet/ruflo7.8만2026년 10월 21일 업데이트

adr-index

무료요약 있음AI 평가 90점

설계 결정과 이유를 기록한 ADR을 읽어 검색 색인과 의존 관계 그래프를 만들고 갱신합니다. 두 문서 형식을 지원하며 참조와 상태의 불일치도 집계합니다.

  • 다른 프로젝트의 ADR을 가져온 뒤 색인 생성
  • 파일과 관계 그래프 동기화
  • 기존 코드베이스에서 ADR 관리 시작
ruvnet/ruflo7.8만2026년 10월 21일 업데이트

adr-reindex

무료요약 있음AI 평가 70점

삭제한 ADR 설계 결정 기록이나 관계 정보가 색인에 남았을 때 전체 삭제 후 재구축합니다. 현재 파일 수와 등록 수를 대조하며, 변경 없이 작업 내용을 미리 확인할 수 있습니다.

  • ADR 파일을 삭제한 뒤 색인을 재구축할 때
  • ADR 관계 삭제 후 남은 정보를 정리할 때
  • ADR 색인을 정기적으로 맞출 때
ruvnet/ruflo7.8만2026년 10월 21일 업데이트

adr-review

무료요약 있음AI 평가 80점

코드 변경 사항을 채택된 설계 결정을 기록한 ADR과 대조합니다. 결정 위반, 오래된 기록 참조, 관련 기록이 없는 변경을 정리하고 코드 수정이나 결정 재검토를 제안합니다.

  • PR 병합 전 설계 결정 확인
  • 대규모 변경과 설계 결정 대조
  • 대체된 ADR을 참조하는 코드 검색
ruvnet/ruflo7.8만2026년 10월 21일 업데이트

adr-verify

무료요약 있음AI 평가 90점

저장된 아키텍처 결정 기록인 ADR의 관계를 검증해 끊어진 참조, 대체 관계의 순환, 상태 불일치를 보고합니다. 가져오기 후나 출시 전 점검에 활용합니다.

  • ADR 가져오기 후 일관성 확인
  • 지속적 통합에서 불일치 탐지
  • 출시 전 저장된 ADR 데이터 점검
ruvnet/ruflo7.8만2026년 10월 21일 업데이트

ruvnet의 스킬 모두 보기

이 스킬의 문제 신고