本文へ移動
cccskills
無料GitHub で公開日本語紹介

backtesting-trading-strategies

暗号資産や株式などの売買戦略を過去データでバックテストし、リターンやリスク指標、資産曲線、取引履歴を比較してパラメーターを調整します。

原文原文の説明を見る

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-marketplaceスター 2,884(GitHub 2,884 + cccskills 0)
連携ツールYahoo Finance

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • 暗号資産の戦略を過去データで試したいとき
  • 売買シグナルや戦略を比較したいとき
  • ドローダウンや取引履歴を確認したいとき
  • パラメーターの組み合わせを探索したいとき

日本語での紹介

できること

暗号資産や従来型市場の売買戦略を過去データで検証し、実資金を投じる前に成績を確認します。SMAやEMA、RSI、MACD、ボリンジャーバンドなど8種類の戦略を使い、総リターン、Sharpe比、Sortino比、最大ドローダウンなどの指標を計算します。取引ごとの記録や資産曲線も出力でき、グリッドサーチで複数のパラメーターを比較できます。結果はサマリー、CSVの取引・資産データ、チャート画像として保存されます。

こんなときに便利

売買シグナルが過去にどう機能したかを調べたいとき、複数の戦略を比べたいとき、リスク指標や取引単位の結果まで確認したいときに向いています。設定値を変えながら成績の違いを見たい場合にも使えます。

使い方の例

  • 「BTC-USDでSMAクロス戦略を過去1年分バックテストして」
  • 「RSI戦略の取引履歴と最大ドローダウンを確認して」
  • 「移動平均の期間を変えて成績を比較して」

注意点

基本機能にはpandas、numpy、yfinance、matplotlibが必要です。高度な機能にはta-lib、scipy、scikit-learnが必要となる場合があります。結果は過去データ上の検証であり、将来の成績を示すものではありません。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(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(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

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

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

abridge-ci-integration

無料概要あり

Abridge連携コードのCIに合成データを使った回帰チェックを加え、同意状態、ノート確認、ログの秘匿、ロールバックなど顧客側の処理を検証します。

  • Abridge連携の回帰テストを追加したいとき
  • 同意やノート確認の処理を検証したいとき
  • ログに機微情報が出ないか確かめたいとき
jeremylongshore/tons-of-skills-marketplace2,8842026年10月29日 更新

abridge-common-errors

無料概要あり

Abridgeの録音、記録の確認、Epicへの引き渡し、アクセスの不具合を観測情報から切り分け、患者情報を抑えた証拠と担当窓口への引き継ぎ資料を整理するスキル。

  • 録音とアップロード障害の切り分け
  • 記録生成の遅延や編集画面の不具合調査
  • Epic連携障害の担当窓口の特定
jeremylongshore/tons-of-skills-marketplace2,8842026年10月29日 更新

abridge-core-workflow-a

無料概要あり

同意確認から録音、生成メモの根拠確認、編集、最終確定まで、臨床文書作成の手順と確認ポイントを整理するスキルです。

  • 診療メモ作成の手順を導入・監査したいとき
  • 同意から医師の確認までの流れを整理したいとき
  • 下書きの根拠確認と停止条件を定めたいとき
jeremylongshore/tons-of-skills-marketplace2,8842026年10月29日 更新

abridge-core-workflow-b

無料概要あり

Abridgeで臨床家が確認した記録内容が、承認済みの手順でEpicの適切なテンプレート欄へ渡るか、テスト記録を使って対応関係や例外を検証するスキルです。

  • AbridgeとEpicの記録欄の対応を確認したいとき
  • 部門ごとの連携設定を監査したいとき
  • 承認済みテスト記録で連携を検証したいとき
jeremylongshore/tons-of-skills-marketplace2,8842026年10月29日 更新

abridge-cost-tuning

無料概要あり

Abridgeの導入・更新判断に向け、利用定着率や業務の完了状況、診療記録の品質、支援負担を契約に基づく費用情報と照らし、継続や改善の選択肢を整理するスキル。

  • Abridge導入後の定着率確認
  • 契約更新の判断材料をまとめたいとき
  • 診療環境ごとの業務成果の比較
jeremylongshore/tons-of-skills-marketplace2,8842026年10月29日 更新

abridge-debug-bundle

無料概要あり

Abridgeの障害調査で、録音や診療記録を含めず、許可した項目だけを集めたサポート用資料と確認用マニフェストを作成します。

  • 障害サポート用の証拠をまとめたいとき
  • 共有資料の除外項目を記録したいとき
  • 調査情報を安全な経路で引き継ぎたいとき
jeremylongshore/tons-of-skills-marketplace2,8842026年10月29日 更新

jeremylongshore のスキルをすべて見る

このスキルの問題を報告する