All skills
marketcalls avatar

/vectorbt-expert

@3a8c2a3

VectorBT backtesting expert. Use when user asks to backtest strategies, create entry/exit signals, analyze portfolio performance, optimize parameters, fetch historical data, use VectorBT/vectorbt, compare strategies, position sizing, equity curves, drawdown charts, or trade analysis. Also triggers for openalgo.ta helpers (exrem, crossover, crossunder, flip, donchian, supertrend).

Use this Skill: https://skilld.dev/gh/marketcalls/vectorbt-backtesting-skills/vectorbt-expert

This session only. Nothing lands on disk.

rulesposition-sizing.md

≈697 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Position Sizing

Size Types

SizeType size_type= size= meaning Best For
Amount "amount" Fixed number of shares Simple testing
Value "value" Fixed cash amount per trade Fixed exposure
Percent "percent" Fraction of current portfolio (0.5 = 50%) Risk-adjusted trading
TargetPercent "targetpercent" Target portfolio weight (rebalances) Portfolio allocation
TargetAmount "targetamount" Rebalance to target shares Specific share targets
TargetValue "targetvalue" Rebalance to target dollar value Specific value targets

Default: size=np.inf with Amount = invest all available cash.

Percent Sizing (Most Popular)

pf = vbt.Portfolio.from_signals(
    close, entries, exits,
    size=0.5,              # 50% of portfolio equity per trade
    size_type="percent",
    init_cash=1_000_000,
    fees=0.00111, fixed_fees=20,
    min_size=1,
    size_granularity=1,
    freq="1D"
)

Value Sizing (Fixed Capital Per Trade)

pf = vbt.Portfolio.from_signals(
    close, entries, exits,
    size=200_000,          # Deploy 2L per trade
    size_type="value",
    init_cash=1_000_000,
    fees=0.00111, fixed_fees=20,
    min_size=1,
    size_granularity=1,
    freq="1D"
)

Target Percent (Portfolio Rebalancing)

pf = vbt.Portfolio.from_orders(
    close=close_panel,          # DataFrame with multiple asset columns
    size=target_weights,        # DataFrame of target weights (0.0-1.0)
    size_type="targetpercent",
    group_by=True,
    cash_sharing=True,
    fees=0.00111, fixed_fees=20,
    init_cash=1_000_000,
    freq="1D",
)

Whole Shares Only (Realistic)

Always use min_size=1 and size_granularity=1 for equity backtesting to avoid fractional shares:

pf = vbt.Portfolio.from_signals(
    close, entries, exits,
    size=0.75,
    size_type="percent",
    min_size=1,             # Minimum 1 share
    size_granularity=1,     # Round to whole shares
    init_cash=1_000_000,
    freq="1D",
)

Best Practices

  • Equity intraday/swing: Use percent with 0.5-0.75 (50-75% deployment)
  • Futures: Use value with lot-aware min_size and size_granularity (see futures-backtesting)
  • Multi-asset portfolio: Use targetpercent with cash_sharing=True
  • Accumulation/pyramiding: Use accumulate=True with smaller percent per entry
  • Always set min_size=1 and size_granularity=1 for realistic equity simulation

Source: SKILL.md on GitHub

1 alert16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides comprehensive instructions and production-ready templates for financial strategy backtesting using the VectorBT library. It emphasizes security best practices such as environment-variable-based secret management, read-only database connections, and robustness testing. The analysis found no evidence of malicious patterns, data exfiltration, or obfuscation.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    19/33 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 3a8c2a3. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 3 months ago
user-invocable
false

README badge

README badge for marketcalls/vectorbt-backtesting-skills/vectorbt-expert