← Back to Skills Marketplace
clawdiri-ai

Backtest Engine - Run Backtests

by RunByDaVinci · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ⚠ suspicious
191
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install einstein-research-backtest-engine-dv
Description
Programmatic backtesting framework for trading strategies. Runs backtests with historical price data (yfinance or CSV), supports momentum/mean-reversion/fact...
README (SKILL.md)

Backtest Engine

This skill is the programmatic engine for running quantitative trading strategy backtests. It takes a machine-readable strategy definition (e.g., from the einstein-research-edge skill) and executes it against historical data, producing detailed performance metrics.

When to Use This Skill

  • User wants to run a backtest on a specific strategy.
  • User has a strategy.yaml file from the edge-generator skill.
  • User wants to generate performance metrics for a trading idea.
  • Triggers: "run a backtest," "test this strategy," "generate performance metrics."

This skill is for execution. For guidance on how to design a robust backtest, see the einstein-research-backtest methodology skill.

Workflow

Step 1: Provide Strategy Definition

The backtest engine requires a strategy.yaml file that defines the rules of the strategy.

strategy.yaml Format:

version: backtest-engine/v1
name: 52-Week High Momentum
universe: "sp500"
data:
  source: yfinance
  start_date: "2018-01-01"
  end_date: "2023-12-31"
entry_signal:
  - "price > high_52w"
  - "volume > 2 * avg_volume_50d"
exit_signal:
  - "hold_days == 5"
  - "pct_change >= 0.10"
  - "pct_change \x3C= -0.05"
parameters:
  hold_days: 5
  profit_target: 0.10
  stop_loss: -0.05

Step 2: Execute the Backtest

The backtest-engine CLI runs the simulation.

backtest-engine run --strategy-file path/to/strategy.yaml

Optional Flags:

  • --costs 0.0005: Apply a 0.05% transaction cost per trade.
  • --out-of-sample-split 2022-01-01: Split data for out-of-sample testing.
  • --walk-forward: Enable walk-forward optimization mode.

The script performs the following actions:

  1. Loads Data: Fetches historical price data via yfinance or from a local CSV.
  2. Generates Signals: Iterates through the historical data day-by-day, applying the entry_signal and exit_signal logic.
  3. Simulates Trades: Creates a trade log based on the generated signals.
  4. Calculates Equity Curve: Builds the portfolio's equity curve over time.
  5. Computes Metrics: Calculates a full suite of performance metrics.

Step 3: Analyze the Performance Report

The engine generates a detailed report in JSON and Markdown.

Key Performance Metrics (KPIs):

  • CAGR: Compound Annual Growth Rate.
  • Max Drawdown: The largest peak-to-trough drop.
  • Sharpe Ratio: Risk-adjusted return (vs. risk-free rate).
  • Sortino Ratio: Risk-adjusted return (vs. downside deviation only).
  • Calmar Ratio: Return relative to max drawdown.
  • Win Rate %: Percentage of trades that were profitable.
  • Profit Factor: Gross profits / gross losses.
  • Trades per Year: Frequency of the strategy.

Report Structure (backtest_report_YYYY-MM-DD.md):

  1. Strategy Summary: The input strategy.yaml definition.
  2. Overall Performance: A table with the key performance metrics.
  3. Equity Curve: An ASCII or image chart of the portfolio's growth.
  4. Drawdown Periods: Highlights the worst drawdown periods.
  5. Trade Log: A sample of the individual trades made.
  6. Annual Returns: A bar chart of returns by year.

Step 4: Present Findings

Synthesize the report for the user, focusing on the most important metrics that answer their original question. Always contextualize the results by referencing the methodology from the einstein-research-backtest skill (e.g., "This is an initial backtest. The next step is to test for parameter robustness.").

Usage Guidance
This package appears to do what it says: run backtests against historical prices. Before using: (1) Be cautious when supplying or running custom strategy files — the engine dynamically imports and executes user-provided Python, so do not run strategies from untrusted sources. (2) Ensure you run it in a controlled environment with required Python deps installed (pandas, numpy, yfinance, etc.). (3) The engine will read CSVs from any path you provide and will fetch data from the Internet via yfinance — avoid passing sensitive file paths or secrets. (4) Note the small mismatch: SKILL.md mentions a 'backtest-engine' CLI while the repo provides scripts/backtest_engine.py; you may run the script directly (python3 scripts/backtest_engine.py). (5) Validate cost models, regime assumptions, and sample sizes before drawing conclusions from any backtest outputs.
Capability Analysis
Type: OpenClaw Skill Name: einstein-research-backtest-engine-dv Version: 0.1.0 The skill bundle contains a significant security vulnerability in `scripts/backtest_engine.py`, where the `load_custom_strategy` function uses `importlib.util` to dynamically load and execute arbitrary Python code from a file path provided via the `--strategy-file` CLI argument. This pattern allows for Remote Code Execution (RCE) if an attacker can influence the file system or the arguments passed to the script. Additionally, there is a discrepancy between `SKILL.md`, which describes a YAML-based configuration, and the Python implementation, which lacks YAML parsing logic and expects a Python file for custom strategies.
Capability Assessment
Purpose & Capability
The skill is described as a programmatic backtest engine and the included Python scripts implement data loading (yfinance/CSV), built-in strategies, signal generation, transaction-cost models, walk-forward capabilities, regime detection, and metric calculation. The declared requirements (no env vars, no binaries) match the contents: it needs Python and standard data science libs (pandas/numpy/yfinance) which are documented in README.
Instruction Scope
SKILL.md and README describe running a CLI and passing a strategy definition or CSV. The runtime instructions and code operate strictly within backtesting scope (price data, strategy logic, metrics). Two items to note: (1) SKILL.md references a 'backtest-engine' CLI while the bundle provides scripts/backtest_engine.py — the script provides a CLI but there is no explicit wrapper named 'backtest-engine' included. (2) The engine supports loading custom strategy code via dynamic import (load_custom_strategy) which will execute arbitrary Python from user-supplied files; this is expected for extensibility but means untrusted strategy files can run arbitrary code on the host. SKILL.md does not explicitly warn about executing custom strategy code.
Install Mechanism
There is no install spec — this is an instruction + script bundle. That minimizes install-time risk. Dependencies are standard Python packages (yfinance, pandas, numpy, scipy) declared in README; no external downloads or obscure install URLs are used.
Credentials
The skill requests no environment variables or credentials, and its runtime behavior (network access to Yahoo via yfinance and reading a user-specified CSV path) is proportionate to its purpose. There are no unexpected credential requests. Note: it does use internet access for yfinance and may attempt to fetch SPY separately for regime detection if not present.
Persistence & Privilege
The skill does not request permanent presence (always:false) and does not attempt to modify other skills or system-wide settings. It runs as a standalone script; no elevated privileges or persistent installation are requested.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install einstein-research-backtest-engine-dv
  3. After installation, invoke the skill by name or use /einstein-research-backtest-engine-dv
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v0.1.0
Initial release
Metadata
Slug einstein-research-backtest-engine-dv
Version 0.1.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Backtest Engine - Run Backtests?

Programmatic backtesting framework for trading strategies. Runs backtests with historical price data (yfinance or CSV), supports momentum/mean-reversion/fact... It is an AI Agent Skill for Claude Code / OpenClaw, with 191 downloads so far.

How do I install Backtest Engine - Run Backtests?

Run "/install einstein-research-backtest-engine-dv" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Backtest Engine - Run Backtests free?

Yes, Backtest Engine - Run Backtests is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Backtest Engine - Run Backtests support?

Backtest Engine - Run Backtests is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Backtest Engine - Run Backtests?

It is built and maintained by RunByDaVinci (@clawdiri-ai); the current version is v0.1.0.

💬 Comments