Skip to content
cccskills
FreePublished on GitHub

backtesting-trading-strategies

Test crypto and traditional trading strategies on historical market data. Review returns, risk measures such as Sharpe ratio and maximum drawdown, trade logs, and equity curves, then use grid search to compare parameter combinations before considering a strategy further.

OriginalShow the original description

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

jeremylongshore/tons-of-skills-marketplace2,884 stars(GitHub 2,884 + cccskills 0)
Works withYahoo Finance

Run score Not tested

See how to install

Good for

  • Testing a crypto strategy on historical prices
  • Comparing signals or strategy approaches
  • Reviewing drawdown, Sharpe ratio, and trade history
  • Searching parameter combinations for a strategy

Files included (16)

  • SKILL.md6.9 KB
  • commands/backtest-strategy.md3.2 KB
  • commands/compare-strategies.md2.6 KB
  • commands/optimize-parameters.md2.4 KB
  • commands/walk-forward.md4.0 KB
  • config/settings.yaml1.4 KB
  • references/errors.md3.9 KB
  • references/examples.md3.9 KB
  • references/implementation.md4.6 KB
  • scripts/backtest.py14.3 KB
  • scripts/fetch_data.py4.8 KB
  • scripts/metrics.py13.1 KB
  • scripts/optimize.py7.5 KB
  • scripts/strategies.py11.1 KB
  • tests/test_metrics.py6.2 KB
  • tests/test_strategies.py13.7 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Backtesting Trading Strategies

Overview

Simulate trading strategies against historical data. Results describe a historical simulation, not expected future performance. The framework includes 8 built-in strategies, the metrics listed below, and parameter optimization.

Key Features:

  • 8 pre-built trading strategies (SMA, EMA, RSI, MACD, Bollinger, Breakout, Mean Reversion, Momentum)
  • Performance metrics (Sharpe, Sortino, Calmar, VaR, max drawdown)
  • Parameter grid search optimization
  • Equity curve visualization
  • Trade-by-trade analysis

Prerequisites

Before invoking this skill, the user installs the required dependencies in the Python environment used for the simulation:

set -euo pipefail
pip install pandas numpy yfinance matplotlib

Optional for advanced features:

set -euo pipefail
pip install ta-lib scipy scikit-learn

Instructions

  1. Fetch historical data (cached to ${CLAUDE_SKILL_DIR}/data/ for reuse):

    python ${CLAUDE_SKILL_DIR}/scripts/fetch_data.py --symbol BTC-USD --period 2y --interval 1d
    
  2. Run a backtest with default or custom parameters:

    python ${CLAUDE_SKILL_DIR}/scripts/backtest.py --strategy sma_crossover --symbol BTC-USD --period 1y
    python ${CLAUDE_SKILL_DIR}/scripts/backtest.py \
      --strategy rsi_reversal \
      --symbol ETH-USD \
      --period 1y \
      --capital 10000 \
      --params '{"period": 14, "overbought": 70, "oversold": 30}'
    
  3. Analyze results saved to ${CLAUDE_SKILL_DIR}/reports/ -- includes *_summary.txt (performance metrics), *_trades.csv (trade log), *_equity.csv (equity curve data), and *_chart.png (visual equity curve).

  4. Optimize parameters via grid search to find the best combination:

    python ${CLAUDE_SKILL_DIR}/scripts/optimize.py \
      --strategy sma_crossover \
      --symbol BTC-USD \
      --period 1y \
      --param-grid '{"fast_period": [10, 20, 30], "slow_period": [50, 100, 200]}'
    

Output

Performance Metrics

MetricDescription
Total ReturnOverall percentage gain/loss
CAGRCompound annual growth rate
Sharpe RatioHistorical risk-adjusted return
Sortino RatioDownside risk-adjusted return
Calmar RatioReturn divided by max drawdown

Risk Metrics

MetricDescription
Max DrawdownLargest peak-to-trough decline
VaR (95%)Value at Risk at 95% confidence
CVaR (95%)Expected loss beyond VaR
VolatilityAnnualized standard deviation

Trade Statistics

MetricDescription
Total TradesNumber of round-trip trades
Win RatePercentage of profitable trades
Profit FactorGross profit divided by gross loss; N/A with no observed losses
ExpectancyExpected value per trade

Example Output

Figure-free layout; actual values depend on the input series, fees, slippage, strategy and parameters. Do not present these placeholders as measured returns.

HISTORICAL SIMULATION: [strategy]
[symbol] | [start_date] to [end_date]
Total Return: [computed] | Max Drawdown: [computed]
Sharpe Ratio: [computed] | Win Rate: [computed]
Total Trades: [observed] | Profit Factor: [computed or N/A]

Profit factor is unavailable when no losing trades were observed, including a zero-trade run or a single winning/breakeven trade. A single losing trade yields zero gross profit divided by its loss; this is not evidence of strategy quality. Zero/one-trade samples cannot establish performance, and optimization is an in-sample historical comparison rather than a forecast.

Supported Strategies

StrategyDescriptionKey Parameters
sma_crossoverSimple moving average crossoverfast_period, slow_period
ema_crossoverExponential MA crossoverfast_period, slow_period
rsi_reversalRSI overbought/oversoldperiod, overbought, oversold
macdMACD signal line crossoverfast, slow, signal
bollinger_bandsMean reversion on bandsperiod, std_dev
breakoutPrice breakout from rangelookback, threshold
mean_reversionReturn to moving averageperiod, z_threshold
momentumRate of change momentumperiod, threshold

Configuration

Create ${CLAUDE_SKILL_DIR}/config/settings.yaml:

data:
  provider: yfinance
  cache_dir: ./data

backtest:
  default_capital: 10000 # Starting simulated capital in quote-currency units
  commission: 0.001 # 0.1% per trade
  slippage: 0.0005 # 0.05% slippage

risk:
  max_position_size: 0.95
  stop_loss: null # Optional fixed stop loss
  take_profit: null # Optional fixed take profit

Error Handling

Use Read to inspect references/errors.md for common issues and solutions.

Examples

See references/examples.md for detailed usage examples including:

  • Multi-asset comparison
  • Walk-forward analysis
  • Parameter optimization workflows

Files

FilePurpose
scripts/backtest.pyMain backtesting engine
scripts/fetch_data.pyHistorical data fetcher
scripts/strategies.pyStrategy definitions
scripts/metrics.pyPerformance calculations
scripts/optimize.pyParameter optimization

Resources

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Add a synthetic-data CI gate for customer-owned Abridge integration code. Test consent handling, note-review handoffs, redaction, and rollback behavior with mocked vendor boundaries, without connecting CI to a live Abridge or EHR tenant.

  • Adding regression checks to an Abridge integration repository
  • Testing consent and note-release handling
  • Checking logs for sensitive data exposure
jeremylongshore/tons-of-skills-marketplace2.9KUpdated Oct 29, 2026

Triage Abridge recording, note review, Epic handoff, and access problems using observed symptoms and approved guidance. Identify the affected workflow stage, organize a minimal timeline, and prepare a redacted escalation record for the responsible team.

  • Separate recording problems from upload failures
  • Investigate note creation delays and editor issues
  • Identify the responsible team for Epic handoff failures
jeremylongshore/tons-of-skills-marketplace2.9KUpdated Oct 29, 2026

Map and review an Abridge clinical documentation workflow from consent and recording through draft review, evidence checks, edits, and final disposition. Keep clinician approval explicit, identify failure exits, and separate verified facts from tenant-specific details and pending approvals.

  • Map a clinical note workflow for a care setting
  • Check where consent and patient identity are verified
  • Review draft notes against linked evidence before sign-off
jeremylongshore/tons-of-skills-marketplace2.9KUpdated Oct 29, 2026

Audit how clinician-reviewed Abridge note sections map into Epic templates and downstream workflows. Use approved test records to document destinations, exceptions, evidence, rollback steps, and a go or no-go decision for a specific environment.

  • Checking Abridge note section mappings to Epic templates
  • Auditing a department’s approved documentation handoff
  • Preparing test evidence and a go or no-go decision
jeremylongshore/tons-of-skills-marketplace2.9KUpdated Oct 29, 2026

Review Abridge adoption and workflow value using local usage records, clinician feedback, and verified contract costs. Build an evidence based decision table covering adoption, quality, support burden, and options to expand, hold, or improve the rollout.

  • Reviewing adoption after an Abridge rollout
  • Preparing evidence for a renewal decision
  • Comparing workflow outcomes across care settings
jeremylongshore/tons-of-skills-marketplace2.9KUpdated Oct 29, 2026

Prepare a bounded support bundle for an Abridge issue using allowlisted operational details such as versions, coarse timestamps, and correlation references. Exclude recordings, transcripts, patient identifiers, credentials, and unrestricted logs, then document redactions and review details.

  • Preparing reviewed evidence for an Abridge support case
  • Documenting redactions and excluded data
  • Collecting approved operational details for an incident
jeremylongshore/tons-of-skills-marketplace2.9KUpdated Oct 29, 2026

See all skills by jeremylongshore

Report a problem with this skill