Trader backtest

From ruvnet/ruflo · View interactive version

Trader backtest is an AI agent skill from the GitHub repository ruvnet/ruflo. Run a historical backtest using npx neural-trader with Rust/NAPI engine (8-19x faster) and walk-forward validation; Ed25519-sign the result for paper→live tamper evidence (ADR-126 Phase 4)

How to use this skill

Skill file

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

  1. 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 })

  1. Run backtest via neural-trader CLI:

```bash

npx neural-trader --backtest --strategy <name> --symbol <TICKER> --period <range> --walk-forward --live

```

For multi-indicator strategies:

```bash

npx neural-trader --backtest --strategy multi-indicator --position-sizing kelly --symbol SPY --period 2020-2024

```

3b. Check the data source. Without --live the backtest runs on synthetic bars, and when the live fetch fails it silently falls back to them. Read dataSource for every symbol in the result. Only yahoo-finance is real data. If any symbol is synthetic or mixed, store the result with synthetic: true in the body, do NOT sign it for paper→live promotion, and tell the user why.

  1. Capture performance metrics from output: total return, annualized return, Sharpe ratio, Sortino ratio, max drawdown, win rate, profit factor, number of trades.
  2. Dedup prior backtests for the same (strategyId, paramsHash) before storing the fresh one (ADR-125 lifecycle / ADR-126 Phase 2 — keep-newest semantics):
  1. Sign the artifact (ADR-126 Phase 4):

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).

  1. 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.

  1. If Sharpe > 1.5, store as successful pattern:

mcp__plugin_ruflo-core_ruflo__agentdb_pattern-store({ pattern: "profitable-STRATEGY_TYPE: PARAMS_AND_RESULTS", type: "trading-strategy", confidence: 0.8 }) (the tool takes pattern, type, confidence; a data field is ignored)

  1. Train SONA on the outcome (skip for synthetic runs):

mcp__plugin_ruflo-core_ruflo__neural_train({ modelType: "moe", epochs: 10 }) (modelType is required; there is no patternType)

Key sourcing & key rotation (ADR-103)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.