New to Claude Skills? Learn how to install them →

ruvnet on GitHub

Trader Backtest

Free

Run historical backtests with cryptographic integrity.

by ruvnet67.6k stars on ruvnet/ruflo
2 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What Trader Backtest does

The Trader Backtest skill enables users to perform historical backtesting of trading strategies using the neural-trader engine, which leverages Rust/NAPI for enhanced performance. This skill is particularly useful for traders and developers looking to validate their trading strategies over historical data with a focus on speed and reliability. By integrating walk-forward validation, users can ensure that their strategies are robust across different market conditions.

A key feature of this skill is its ability to sign backtest results using Ed25519 cryptography. This provides tamper evidence for the transition from paper trading to live trading, ensuring that the integrity of the backtest results is maintained. The signing process involves generating a signed artifact that includes crucial performance metrics and can be verified before any promotion to live trading.

The skill walks users through a series of steps that include checking for existing strategy configurations, running backtests via the command line, capturing performance metrics, and deduplicating prior backtests. This structured approach ensures that users can efficiently manage their backtesting process while maintaining a clear record of their trading strategies and results.

Overall, Trader Backtest is designed for developers and traders who require a reliable and efficient way to backtest and validate their trading strategies, while also ensuring that the results are secure and verifiable.

When to use it

Use this skill when you need to backtest trading strategies and require a secure method to validate the results before live trading.

When not to use it

This skill may not be suitable for users who do not require cryptographic signing of backtest results or those looking for a simple backtesting tool without advanced features.

What you can build with it

Validating a New Trading Strategy

Use the Trader Backtest skill to backtest a new trading strategy against historical data to assess its viability before going live.

Ensuring Compliance for Live Trading

Run backtests and sign the results to maintain a verifiable record, ensuring compliance with trading regulations.

Optimizing Strategy Performance

Utilize the skill's metrics to refine and optimize trading strategies based on past performance data.

How to install Trader Backtest

View source

1. Install with the skills CLI

npx skills add ruvnet/ruflo/trader-backtest --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by ruvnet

Run a historical backtest using the neural-trader Rust/NAPI engine, then Ed25519-sign the result so the paper→live promotion gate has cryptographic tamper evidence (ADR-126 Phase 4 + CWE-347 pattern).

Steps:

  1. Ensure neural-trader is available: npm ls neural-trader 2>/dev/null || npm install --ignore-scripts neural-trader
  2. Check for saved strategy config: mcp__plugin_ruflo-core_ruflo__memory_retrieve({ key: "strategy-STRATEGY_NAME", namespace: "trading-strategies" }) If not found, list available: mcp__plugin_ruflo-core_ruflo__memory_search({ query: "strategy", namespace: "trading-strategies", limit: 10 })
  3. Run backtest via neural-trader CLI:
    npx neural-trader --backtest --strategy <name> --symbol <TICKER> --period <range> --walk-forward
    
    For multi-indicator strategies:
    npx neural-trader --backtest --strategy multi-indicator --position-sizing kelly --symbol SPY --period 2020-2024
    
  4. Capture performance metrics from output: total return, annualized return, Sharpe ratio, Sortino ratio, max drawdown, win rate, profit factor, number of trades.
  5. Dedup prior backtests for the same (strategyId, paramsHash) before storing the fresh one (ADR-125 lifecycle / ADR-126 Phase 2 — keep-newest semantics):
    • Search: mcp__plugin_ruflo-core_ruflo__memory_search({ query: "backtest STRATEGY paramsHash:PARAMS_HASH", namespace: "trading-backtests", limit: 10 })
    • For each hit whose key matches backtest-STRATEGY-* AND whose stored paramsHash equals the current run's hash, delete it: mcp__plugin_ruflo-core_ruflo__memory_delete({ key: "OLD_KEY", namespace: "trading-backtests" })
    • (Note: even without this proactive step, the MemoryConsolidator.dedup('keep-newest') background pass introduced in @claude-flow/memory@3.0.0-alpha.18 runs every 6h and will eventually converge. Doing it inline keeps memory_search results deterministic immediately after a re-run.)
  6. Sign the artifact (ADR-126 Phase 4):
    • Build the SignedBacktestArtifact body — { strategyId, paramsHash, dataRange: {from,to}, metrics, runsHash, generatedAt } — where paramsHash = sha256(canonical params JSON), runsHash = sha256(canonical runs array JSON), and generatedAt = new Date().toISOString().
    • Resolve the witness signing key. The skill reads the key path in this order; the FIRST that resolves wins:
      1. RUFLO_WITNESS_KEY_PATH env var — points to a JSON file with { "privateKey": "<hex>" }.
      2. verification/witness-key.json (the ADR-103 default path, if present).
    • If the key resolves: call signBacktestArtifact(body, privateKeyHex) from plugins/ruflo-neural-trader/src/signed-artifact.mjs. The returned value is a SignedBacktestArtifact with schema, witnessPublicKey: "ed25519:<hex>", and witnessSignature: "<hex>" populated.
    • If NEITHER path resolves: log a loud warning — "[WARN] ruflo-neural-trader: no witness signing key found (RUFLO_WITNESS_KEY_PATH unset, verification/witness-key.json missing) — storing backtest artifact in UNSIGNED degraded mode. paper→live promotion will be refused by trader-cloud-backtest until a signed artifact replaces this one." — and store the body unsigned. NEVER silently fall back.
  7. Store the (possibly signed) artifact to the canonical trading-backtests namespace: mcp__plugin_ruflo-core_ruflo__memory_store({ key: "backtest-STRATEGY-TIMESTAMP", value: JSON.stringify(signedArtifact), namespace: "trading-backtests" }) The stored value contains witnessSignature + witnessPublicKey when signed; downstream consumers (trader-cloud-backtest) MUST call verifyBacktestArtifact(artifact, trustedPublicKey) before promoting any artifact to live.
  8. If Sharpe > 1.5, store as successful pattern: mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store({ pattern: "profitable-STRATEGY_TYPE", data: "PARAMS_AND_RESULTS" })
  9. Train SONA on the outcome: mcp__plugin_ruflo-core_ruflo__neural_train({ patternType: "trading-strategy", epochs: 10 })

Key sourcing & key rotation (ADR-103)

  • The witness key is a 32-byte Ed25519 private key, stored as { "privateKey": "<64-hex-chars>" } in a JSON file referenced by RUFLO_WITNESS_KEY_PATH. Keep it OUT of the repo. For local development, generate one once with node -e "import('@noble/ed25519').then(async ed=>{const sk=crypto.getRandomValues(new Uint8Array(32));console.log(Buffer.from(sk).toString('hex'))})" and write it to ~/.ruflo/witness-key.json.
  • Production deployments pin the corresponding PUBLIC key in project config and supply it as trustedPublicKey to verifyBacktestArtifact(...) — never trust the witnessPublicKey field on the artifact itself (CWE-347 / #1922).
  • Key rotation: re-sign existing backtest entries with the new key OR explicitly mark pre-rotation artifacts as non-promotable. Same pattern as ADR-103.

Frequently asked questions about Trader Backtest

Similar skills