14
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill terrylica/cc-skills --skill backtesting-py-oracle- SKILL.md8.3 KB
Overview
This skill provides a hardened backtesting.py configuration and checklist for validating ClickHouse SQL oracle results and range-bar pattern backtests. It codifies required constructor flags, common anti-patterns, and deterministic fixes so Python trade output matches SQL sweep results. Use it to run reproducible, bit-atomic comparisons between SQL-generated signals and backtesting.py trades.
How this skill works
The skill inspects backtesting.py runtime configuration, trade sorting, rolling-quantile signal generation, and strategy sizing to detect divergences from SQL oracle outputs. It enforces hedging and non-exclusive orders, prescribes EntryTime sorting of trades, and supplies NaN-safe rolling-quantile logic and data-range defaults. It also outlines a multi-position strategy template that mirrors SQL behavior for overlapping signals.
When to use it
- When validating ClickHouse SQL oracle vs backtesting.py trade outputs
- When running Backtest() with overlapping signals or multi-position modes
- When entry price, timestamp, or signal counts differ between SQL and Python
- When rolling quantile features produce NaNs that poison signals
- When configuring sizing to avoid margin exhaustion with concurrent positions
Best practices
- Always set hedging=True and exclusive_orders=False to allow overlapping trades
- Sort stats._trades by EntryTime before mapping trades to signals
- Skip NaN values when computing rolling quantiles to match SQL NULL handling
- Use an expanded data start (e.g., 2017-01-01) to match SQL data range
- Prefer fixed fractional sizing (e.g., size=0.01) for overlapping positions to avoid margin exhaustion
Example use cases
- Oracle validation run comparing SQL gen600_strategy outputs with backtesting.py trades
- Backtest configuration for multi-position range-bar pattern experiments
- Debugging entry-price mismatches by re-sorting trades on EntryTime
- Fixing cross-asset failures caused by rolling-quantile NaN propagation
- Reproducing SQL signal timestamps by recording signal bar timestamps in next()
FAQ
SQL evaluates signals independently and allows overlapping trades. Backtesting.py default behavior blocks new positions while a position is open. hedging=True and exclusive_orders=False reproduce SQL signal handling.
How do I fix entry price mismatches?
stats._trades is sorted by ExitTime by default. Re-sort trades by EntryTime (stats._trades.sort_values('EntryTime')) so trade[i] maps to the same signal[i].