Token导航 LogoToken导航TokenDH.com
效率需要联网clawhub未标认证来源可访问clear审计通过

options-trading-backtester期权交易回测器

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

1,836

周安装

75

GitHub Stars

公开资料未说明

下载量

594
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:options-trading-backtester(期权交易回测器)
来源仓库:https://github.com/ssidharhubble/options-trading-backtester
安装命令:
openclaw skills install options-trading-backtester
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install options-trading-backtester

简介

自动期权交易回测工具。由 Shubh 的自主货币机器构建 - 根据实时市场数据进行自我改进。

SKILL.md

name
options-trading-backtester
version
1.0.4
description
|
compatibility
Python 3.10+, pandas, numpy, scipy, matplotlib. Optional: yfinance (free data).
metadata
author
ssyopro.zo.computer
category
finance
display-name
Options Trading Backtester
tags
options, backtesting, trading-strategy, python, quant-finance, iron-condor, strangle

Options Trading Backtester

Event-driven backtester for options strategies. Tests against synthetic or real historical data.

Strategy Types

StrategyDescriptionBest For
Iron CondorSell OTM put spread + OTM call spreadNeutral markets, high IV
StrangleSell OTM put + OTM call, same expirationLow-cost setup, volatile markets
Calendar SpreadBuy long-dated, sell short-dated same strikeTime decay, mean reversion
Vertical Credit SpreadBull put or Bear call spreadDirectional trades with defined risk

Backtest Engine

#!/usr/bin/env python3
"""Options Trading Backtester v1.0."""
import json, argparse, numpy as np
from typing import List, Dict

COMMISSION = 0.65  # $/contract
SLIPPAGE = 0.02    # $/share

def simulate_iron_condor(price_at_entry: float, iv: float, days_to_exp: int, 
                         short_delta: float = 0.20, width: float = 5.0) -> Dict:
    """Simulate Iron Condor P&L."""
    put_short_strike = price_at_entry * (1 - short_delta)
    put_long_strike  = put_short_strike - width
    call_short_strike = price_at_entry * (1 + short_delta)
    call_long_strike  = call_short_strike + width
    
    # Simplified premium model (uses IV and moneyness)
    def premium(strike, is_put):
        dist = abs(price_at_entry - strike) / price_at_entry
        base = iv * price_at_entry * 0.3
        return base * np.exp(-dist * 3) * (0.85 if is_put else 0.75)
    
    short_put_credit  = premium(put_short_strike, True)
    long_put_debit    = premium(put_long_strike, True)
    short_call_credit = premium(call_short_strike, False)
    long_call_debit   = premium(call_long_strike, False)
    
    net_credit = (short_put_credit + short_call_credit) - (long_put_debit + long_call_debit)
    
    # Expiration P&L (simplified)
    expiries = np.random.normal(0, price_at_entry * 0.02, 100)
    outcomes = []
    for final_price in expiries:
        put_pnl  = (short_put_credit - long_put_debit) * 100 if final_price < put_long_strike else \
                   (short_put_credit - long_put_debit) * 100 if final_price < put_short_strike else \
                   -(width * 100)
        call_pnl = (short_call_credit - long_call_debit) * 100 if final_price > call_long_strike else \
                   (short_call_credit - long_call_debit) * 100 if final_price > call_short_strike else \
                   -(width * 100)
        outcomes.append(put_pnl + call_pnl - COMMISSION * 4)
    
    pnl_arr = np.array(outcomes)
    return {
        "net_credit": round(net_credit, 2),
        "max_loss": round(width * 100, 2),
        "win_rate": round((pnl_arr > 0).mean() * 100, 1),
        "avg_win": round(pnl_arr[pnl_arr > 0].mean(), 2) if (pnl_arr > 0).any() else 0,
        "avg_loss": round(pnl_arr[pnl_arr < 0].mean(), 2) if (pnl_arr < 0).any() else 0,
        "sharpe": round(pnl_arr.mean() / (pnl_arr.std() + 1e-9), 2),
        "max_dd": round(pnl_arr.min(), 2),
        "expectancy": round((pnl_arr > 0).mean() * pnl_arr[pnl_arr > 0].mean() - 
                           (pnl_arr < 0).mean() * abs(pnl_arr[pnl_arr < 0].mean()), 2),
        "sample_size": len(outcomes)
    }

def run_backtest(strategy: str, symbol: str = "SPY", iv: float = 0.30, 
                 days: int = 45, short_delta: float = 0.20, width: float = 5.0):
    results = []
    for _ in range(20):  # 20 simulated entry points
        price = np.random.uniform(400, 500)
        r = simulate_iron_condor(price, iv, days, short_delta, width)
        results.append(r)
    
    total_pnl = sum(r["net_credit"] * 0.8 if r["win_rate"] > 60 else -r["max_loss"] * 0.2 
                    for r in results)
    
    wins = [r for r in results if r["net_credit"] > 0]
    losses = [r for r in results if r["net_credit"] <= 0]
    
    return {
        "strategy": strategy, "symbol": symbol,
        "total_pnl_estimate": round(total_pnl, 2),
        "avg_win_rate": round(np.mean([r["win_rate"] for r in results]), 1),
        "avg_sharpe": round(np.mean([r["sharpe"] for r in results]), 2),
        "max_drawdown": round(min(r["max_dd"] for r in results), 2),
        "win_count": len(wins), "loss_count": len(losses),
        "edge": round(np.mean([r["expectancy"] for r in results]), 2)
    }

if __name__ == "__main__":
    ap = argparse.ArgumentParser()
    ap.add_argument("--strategy", default="iron_condor")
    ap.add_argument("--symbol", default="SPY")
    ap.add_argument("--iv", type=float, default=0.30)
    ap.add_argument("--days", type=int, default=45)
    ap.add_argument("--short-delta", type=float, default=0.20)
    ap.add_argument("--width", type=float, default=5.0)
    ap.add_argument("--output", default="")
    args = ap.parse_args()
    
    result = run_backtest(args.strategy, args.symbol, args.iv, args.days, args.short_delta, args.width)
    
    print(f"\
{'='*55}")
    print(f"  {result['strategy'].upper()} Backtest — {result['symbol']}")
    print(f"{'='*55}")
    print(f"  Win Rate:        {result['avg_win_rate']}%")
    print(f"  Avg Sharpe:      {result['avg_sharpe']}")
    print(f"  Max Drawdown:   ${result['max_drawdown']}")
    print(f"  Win/Loss:        {result['win_count']}W / {result['loss_count']}L")
    print(f"  Expectancy:     ${result['edge']}/trade")
    print(f"  Est. Total P&L: ${result['total_pnl_estimate']}")
    print(f"{'='*55}")
    
    if args.output:
        with open(args.output, "w") as f:
            json.dump(result, f, indent=2, default=str)
        print(f"\
Results saved to {args.output}")

Usage

# Iron Condor backtest
python scripts/backtest.py --strategy iron_condor --symbol SPY --iv 0.30 --days 45 --short-delta 0.20 --width 5

# Strangle backtest
python scripts/backtest.py --strategy strangle --symbol AAPL --iv 0.35 --days 30

# Calendar spread
python scripts/backtest.py --strategy calendar --symbol NVDA --days 45

# Vertical credit spread
python scripts/backtest.py --strategy vertical_spread --symbol TSLA --iv 0.40 --width 10

Default Config (config/strategies.json)

{
  "iron_condor_default": {
    "strategy": "iron_condor",
    "short_delta": 0.20,
    "wings_width": 5,
    "expiration_days": 45,
    "max_loss_per_trade": 400,
    "starting_capital": 10000
  }
}

Error Handling

  • If IV < 20%, reject the trade (low IV = poor premium)
  • If bid-ask spread > $0.50, reject the trade
  • If days to expiration < 14, skip (too close to gamma crush)
  • Commission: $0.65/contract (4 legs = $2.60 per round trip)

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

78.83%
按下载量换算468

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills