Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
gracefullight avatar

Backtesting Trading Strategies

  • 1.9k installs
  • 39 repo stars
  • Updated July 27, 2026
  • gracefullight/stock-checker

This is a copy of backtesting-trading-strategies by jeremylongshore - installs and ranking accrue to the original listing.

backtesting-trading-strategies is a stock-checker skill that simulates and evaluates trading strategies against historical market data for developers who need performance metrics before deploying real capital.

About

backtesting-trading-strategies is a gracefullight/stock-checker skill that configures and runs historical strategy simulations using a settings.yaml file with data provider, capital, commission, and slippage parameters. It supports yfinance and coingecko data sources with configurable cache directories, default 1d bar intervals, starting capital of $10,000 USD, 0.1% commission, and 0.05% slippage per trade. Optional risk management blocks cap position size at 95% of capital with configurable stop-loss and take-profit thresholds. Developers reach for it when validating algorithmic or discretionary trading rules against past market data before live execution.

  • Configurable backtesting engine with 8 built-in strategies including SMA Crossover, EMA Crossover, RSI Reversal, MACD, B
  • Customizable risk, commission, slippage and position sizing parameters via settings.yaml
  • Automated reporting that generates trade logs, equity curves and performance charts
  • Multiple data providers with local caching for fast repeated tests
  • Strategy parameter overrides via command line for rapid experimentation

Backtesting Trading Strategies by the numbers

  • 1,865 all-time installs (skills.sh)
  • +26 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/gracefullight/stock-checker --skill backtesting-trading-strategies

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.9k
repo stars39
Security audit2 / 3 scanners passed
Last updatedJuly 27, 2026
Repositorygracefullight/stock-checker

How do you backtest trading strategies on historical data?

Simulate and evaluate trading strategies against historical market data before committing real capital.

Who is it for?

Developers and quant engineers validating trading strategy rules with historical market data before live capital deployment.

Skip if: Teams needing live order execution, brokerage integration, or regulatory-compliant production trading systems.

When should I use this skill?

A developer asks to backtest a trading strategy, simulate historical performance, or configure commission and slippage for strategy evaluation.

What you get

Backtest performance report with trade simulation results and risk-adjusted metrics

  • Backtest simulation report
  • Trade performance metrics

By the numbers

  • Default starting capital of $10,000 USD with 0.1% commission and 0.05% slippage per trade
  • Supports 2 data providers: yfinance and coingecko

Files

SKILL.mdMarkdownGitHub ↗

Backtesting Trading Strategies

Overview

Validate trading strategies against historical data before risking real capital. This skill provides a complete backtesting framework with 8 built-in strategies, comprehensive performance metrics, and parameter optimization.

Key Features:

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

Prerequisites

Install required dependencies:

pip install pandas numpy yfinance matplotlib

Optional for advanced features:

pip install ta-lib scipy scikit-learn

Instructions

Step 1: Fetch Historical Data

python {baseDir}/scripts/fetch_data.py --symbol BTC-USD --period 2y --interval 1d

Data is cached to {baseDir}/data/{symbol}_{interval}.csv for reuse.

Step 2: Run Backtest

Basic backtest with default parameters:

python {baseDir}/scripts/backtest.py --strategy sma_crossover --symbol BTC-USD --period 1y

Advanced backtest with custom parameters:

# Example: backtest with specific date range
python {baseDir}/scripts/backtest.py \
  --strategy rsi_reversal \
  --symbol ETH-USD \
  --period 1y \
  --capital 10000 \
  --params '{"period": 14, "overbought": 70, "oversold": 30}'

Step 3: Analyze Results

Results are saved to {baseDir}/reports/ including:

  • *_summary.txt - Performance metrics
  • *_trades.csv - Trade log
  • *_equity.csv - Equity curve data
  • *_chart.png - Visual equity curve

Step 4: Optimize Parameters

Find optimal parameters via grid search:

python {baseDir}/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 RatioRisk-adjusted return (target: >1.5)
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
ExpectancyExpected value per trade

Example Output

================================================================================
                    BACKTEST RESULTS: SMA CROSSOVER
                    BTC-USD | [start_date] to [end_date]
================================================================================
 PERFORMANCE                          | RISK
 Total Return:        +47.32%         | Max Drawdown:      -18.45%
 CAGR:                +47.32%         | VaR (95%):         -2.34%
 Sharpe Ratio:        1.87            | Volatility:        42.1%
 Sortino Ratio:       2.41            | Ulcer Index:       8.2
--------------------------------------------------------------------------------
 TRADE STATISTICS
 Total Trades:        24              | Profit Factor:     2.34
 Win Rate:            58.3%           | Expectancy:        $197.17
 Avg Win:             $892.45         | Max Consec. Losses: 3
================================================================================

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 {baseDir}/config/settings.yaml:

data:
  provider: yfinance
  cache_dir: ./data

backtest:
  default_capital: 10000
  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

See {baseDir}/references/errors.md for common issues and solutions.

Examples

See {baseDir}/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

Related skills

How it compares

Choose backtesting-trading-strategies over live trading skills when the goal is historical simulation and risk scoping before real orders.

FAQ

Which data providers does backtesting-trading-strategies support?

backtesting-trading-strategies supports yfinance and coingecko as data providers configured in settings.yaml, with a local cache_dir for downloaded historical bars and a default 1d interval.

What are the default backtest cost assumptions?

backtesting-trading-strategies defaults to $10,000 starting capital, 0.1% commission per trade, and 0.05% slippage per trade, all configurable in the settings.yaml backtest block.

Is Backtesting Trading Strategies safe to install?

skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Finance & Tradingfinancepricing

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.