AI Slop Code RIsk Monitor

kernc/backtesting.py

🔎 📈 🐍 💰 Backtest trading strategies in Python.

20.4 Elevated pattern signal View on GitHub

Maintenance and Governance Review

This report summarizes scanner evidence for kernc/backtesting.py, a Python project with 9,034 GitHub stars. SynthScan examined 8,340 lines of code across 37 source files, recording 101 pattern matches distributed across 14 syntactic categories. The legacy adjusted pattern signal is 20.4 (Elevated pattern signal); it is not an authorship estimate.

Use the findings to ask whether maintainers can explain intent, verify dependencies, simplify unnecessary scaffolding, and focus review effort. Risk Payload v1 adds ownership, supply-chain, over-engineering, and review-effort vectors when available. These are prompts for human verification, not probabilities, security findings, or measured maintenance costs.

20.4
Adjusted Signal
20.4
Raw Pattern Score
100%
Time Factor
2026-08-05
Last Push
9.0K
Stars
Python
Language
8.3K
Lines of Code
37
Files
101
Pattern Hits
2026-10-12
Scan Date
0.30
HC Hit Rate

Risk Review · v3

Use each vector to guide manual verification of the underlying findings.

Cognitive Ownership Risk 38.1/100 · MEDIUM

Can maintainers explain intent, assumptions, and trade-offs? 71 finding(s).

Hallucinated Dependency & Supply Chain Risk 31.2/100 · MEDIUM

Are imports declared and package/API names verified? 19 finding(s).

Agent Over-Engineering Ratio 27.9/100 · MEDIUM

Are wrappers, guards, and repeated structures necessary? 40 finding(s).

PR Review Velocity Impact 64.8/100 · HIGH

Which changes need focused human review? 101 finding(s).

What These Metrics Mean

Adjusted Signal
Legacy pattern score normalized per 1,000 scanned lines and multiplied by the repository-level time factor. It is not an estimate of AI authorship.
Raw Pattern Score
Sum of severity- and context-weighted pattern findings before applying the time factor.
Time Factor
A coarse multiplier based on repository last-push metadata. It does not identify when individual code was written.
Pattern Hits
Count of configured pattern findings. Review each location and surrounding code before acting.
HC Hit Rate
High- and critical-severity findings per scanned file. Severity is a configured detector weight, not proof of a vulnerability or authorship.
Lines / Files
Scan coverage denominators used by the legacy normalized score.

Pattern-Signal History

This chart tracks the legacy adjusted pattern score across scan runs. Changes can reflect source changes, scan coverage, or detector/scoring versions; they do not measure AI adoption or prove that a team refactored code. Compare runs only when their scoring versions are compatible. The dashed line tracks the raw pattern-hit count.

Severity Breakdown

Groups findings by configured severity weight. Severity is not a confidence estimate, security rating, or proof that a package is missing. Verify imports against the project's manifests and inspect each finding in its local design context.

CRITICAL 0HIGH 11MEDIUM 9LOW 81

Directory Score Breakdown

This horizontal bar chart shows where configured pattern scores accumulate across directories. Treat the bars as locations to inspect, not as evidence of authorship or code quality. Use the file-level findings to decide whether a directory needs a focused ownership, dependency, complexity, or review check.

Pattern Findings

The scanner identified 101 distinct pattern matches across 14 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a detector match to inspect in context. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.

Reading the findings table: The Severity column indicates the configured finding weight (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — legacy comment-context matches receive a ×1.5 score weight. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier under the legacy scoring model.

Cross-Language Confusion9 hits · 52 pts
SeverityFileLineSnippetContext
HIGH⚡backtesting/_plotting.py160 assert not indicators or indicators[0].df.index.equals(df.index)CODE
HIGH⚡backtesting/_plotting.py163 assert equity_data.index.equals(df.index)CODE
HIGHbacktesting/_plotting.py221 assert df.index.equals(results['_equity_curve'].index)CODE
HIGHbacktesting/_plotting.py289this.labels = this.labels || formatter.doFormat(ticksCODE
HIGHbacktesting/_plotting.py291 .filter(t => t !== undefined));CODE
HIGHbacktesting/_plotting.py361 assert equity.index.equals(equity_data.index)STRING
HIGH⚡backtesting/test/_test.py1124 assert close.s.equals(pd.Series(close, index=index))CODE
HIGH⚡backtesting/test/_test.py1130 assert close.s.equals(pd.Series(close, index=index))CODE
HIGHbacktesting/test/_test.py309 self.assertTrue(df.equals(EURUSD))CODE
Over-Commented Block24 hits · 24 pts
SeverityFileLineSnippetContext
LOWbacktesting/lib.py261 # Let's convert closing prices back to pandas Series.COMMENT
LOWdoc/examples/Strategies Library.py1# ---COMMENT
LOWdoc/examples/Strategies Library.py21# [basic package usage](https://kernc.github.io/backtesting.py/doc/examples/Quick%20Start%20User%20Guide.html).COMMENT
LOWdoc/examples/Strategies Library.py101# For other strategies of the sort, and other reusable utilities in general, seeCOMMENT
LOWdoc/examples/Quick Start User Guide.py1# ---COMMENT
LOWdoc/examples/Quick Start User Guide.py21# _Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python struCOMMENT
LOWdoc/examples/Quick Start User Guide.py41# DataFrame should ideally be indexed with a _datetime index_ (convert it with [`pd.to_datetime()`](https://pandas.pydatCOMMENT
LOWdoc/examples/Quick Start User Guide.py121# [`self.data`](https://kernc.github.io/backtesting.py/doc/backtesting/backtesting.html#backtesting.backtesting.StrategyCOMMENT
LOWdoc/examples/Quick Start User Guide.py141# self.position.close()COMMENT
LOWdoc/examples/Quick Start User Guide.py161from backtesting import BacktestCOMMENT
LOWdoc/examples/Quick Start User Guide.py201# %%COMMENT
LOWdoc/examples/Quick Start User Guide.py221# The columns should be self-explanatory.COMMENT
LOWdoc/examples/Parameter Heatmap & Optimization.py1# -*- coding: utf-8 -*-COMMENT
LOWdoc/examples/Parameter Heatmap & Optimization.py21# It is assumed you're already familiar withCOMMENT
LOWdoc/examples/Parameter Heatmap & Optimization.py121# It makes the function return a heatmap series along with the usual stats of the best run.COMMENT
LOWdoc/examples/Parameter Heatmap & Optimization.py161)COMMENT
LOWdoc/examples/Parameter Heatmap & Optimization.py181# ## Model-based optimizationCOMMENT
LOWdoc/examples/Trading with Machine Learning.py1# ---COMMENT
LOWdoc/examples/Trading with Machine Learning.py21# [basic framework usage](https://kernc.github.io/backtesting.py/doc/examples/Quick%20Start%20User%20Guide.html)COMMENT
LOWdoc/examples/Trading with Machine Learning.py261bt.plot()COMMENT
LOWdoc/examples/Trading with Machine Learning.py281# by increasing the conviction needed and imposing extra domain expertise and discretionary limitations before enterinCOMMENT
LOWdoc/examples/Multiple Time Frames.py1# ---COMMENT
LOWdoc/examples/Multiple Time Frames.py21# [pandas resampling](https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#resampling).COMMENT
LOWdoc/examples/Multiple Time Frames.py141# In conclusion, to test strategies on multiple time frames, you need to pass in OHLC data in the lowest time frame, theCOMMENT
Hyper-Verbose Identifiers25 hits · 23 pts
SeverityFileLineSnippetContext
LOWbacktesting/_stats.py14def compute_drawdown_duration_peaks(dd: pd.Series):CODE
LOW⚡backtesting/test/_test.py1136 def test_indicators_picklable(self):CODE
LOW⚡backtesting/test/_test.py1270 def test_optimize_datetime_index_with_timezone(self):CODE
LOW⚡backtesting/test/_test.py1276 def test_optimize_range_index(self):CODE
LOW⚡backtesting/test/_test.py1286 def test_sl_tp_values_in_trades_df(self):CODE
LOWbacktesting/test/_test.py100 def test_data_missing_columns(self):CODE
LOWbacktesting/test/_test.py238 def test_absolute_size_order_warns_on_insufficient_margin(self):CODE
LOWbacktesting/test/_test.py393 def test_compute_stats_bordercase(self):CODE
LOWbacktesting/test/_test.py426 def test_trade_enter_hit_sl_on_same_day(self):CODE
LOWbacktesting/test/_test.py444 def test_stop_price_between_sl_tp(self):CODE
LOWbacktesting/test/_test.py453 def test_position_close_portion(self):CODE
LOWbacktesting/test/_test.py468 def test_close_orders_from_last_strategy_iteration(self):CODE
LOWbacktesting/test/_test.py480 def test_check_adjusted_price_when_placing_order(self):CODE
LOWbacktesting/test/_test.py533 def test_broker_exclusive_orders(self):CODE
LOWbacktesting/test/_test.py545 def test_trade_multiple_close(self):CODE
LOWbacktesting/test/_test.py566 def test_stop_limit_order_price_is_stop_price(self):CODE
LOWbacktesting/test/_test.py575 def test_autoclose_trades_on_finish(self):CODE
LOWbacktesting/test/_test.py659 def test_optimize_invalid_param(self):CODE
LOWbacktesting/test/_test.py807 def test_resample_trades_vectorized(self):CODE
LOWbacktesting/test/_test.py1160 def test_backtest_run_docstring_contains_stats_keys(self):CODE
LOWbacktesting/test/_test.py1165 def test_readme_contains_stats_keys(self):CODE
LOWbacktesting/test/_test.py1204 def test_trade_on_close_closes_trades_on_close(self):CODE
LOWbacktesting/test/_test.py1239 def test_trades_dates_match_prices(self):CODE
LOWbacktesting/test/_test.py1259 def test_stop_entry_and_tp_in_same_bar(self):CODE
LOWbacktesting/test/_test.py1297 def test_sl_value_in_trades_df_when_gapped_through(self):CODE
Decorative Section Separators4 hits · 12 pts
SeverityFileLineSnippetContext
MEDIUMdoc/examples/Strategies Library.py17# ======================COMMENT
MEDIUMdoc/examples/Quick Start User Guide.py17# =======================COMMENT
MEDIUMdoc/examples/Parameter Heatmap & Optimization.py18# ==========COMMENT
MEDIUMdoc/examples/Multiple Time Frames.py17# ============COMMENT
AI Slop Vocabulary4 hits · 12 pts
SeverityFileLineSnippetContext
MEDIUMdoc/examples/Strategies Library.py20# It is, henceforth, assumed you're already familiar withCOMMENT
MEDIUMdoc/examples/Quick Start User Guide.py21# _Backtesting.py_ is a small and lightweight, blazing fast backtesting framework that uses state-of-the-art Python struCOMMENT
MEDIUMdoc/examples/Parameter Heatmap & Optimization.py91# It's not a robust strategy, but we can optimize it.COMMENT
MEDIUMdoc/examples/Trading with Machine Learning.py151# Let's backtest a simple strategy that buys the asset for 20% of available equity with 20:1 leverage whenever the forecCOMMENT
Unused Imports10 hits · 10 pts
SeverityFileLineSnippetContext
LOWbacktesting/backtesting.py9CODE
LOWbacktesting/lib.py14CODE
LOWbacktesting/__init__.py68CODE
LOWbacktesting/__init__.py69CODE
LOWbacktesting/__init__.py71CODE
LOWbacktesting/__init__.py71CODE
LOWbacktesting/_plotting.py1CODE
LOWbacktesting/_util.py1CODE
LOWbacktesting/_stats.py1CODE
LOWbacktesting/test/__init__.py3CODE
Empty Error Handlers2 hits · 10 pts
SeverityFileLineSnippetContext
HIGHbacktesting/backtesting.py1231except ValueError:CODE
HIGHbacktesting/test/_test.py734except RuntimeError:CODE
Deep Nesting9 hits · 9 pts
SeverityFileLineSnippetContext
LOWbacktesting/backtesting.py765CODE
LOWbacktesting/backtesting.py875CODE
LOWbacktesting/backtesting.py1271CODE
LOWbacktesting/backtesting.py1386CODE
LOWbacktesting/backtesting.py1513CODE
LOWbacktesting/lib.py427CODE
LOWbacktesting/_plotting.py198CODE
LOWbacktesting/_plotting.py535CODE
LOWbacktesting/_stats.py37CODE
AI Structural Patterns4 hits · 4 pts
SeverityFileLineSnippetContext
LOWbacktesting/backtesting.py1195CODE
LOWbacktesting/backtesting.py1658CODE
LOWbacktesting/lib.py330CODE
LOWbacktesting/_plotting.py198CODE
Excessive Try-Catch Wrapping3 hits · 4 pts
SeverityFileLineSnippetContext
LOWbacktesting/backtesting.py145 except Exception as e:CODE
LOW⚡backtesting/_plotting.py152 except Exception:CODE
LOWbacktesting/_util.py304 except Exception:CODE
Redundant / Tautological Comments3 hits · 4 pts
SeverityFileLineSnippetContext
LOWbacktesting/backtesting.py887 # Check if stop condition was hitCOMMENT
LOWbacktesting/backtesting.py899 # Check if limit order can be filled.COMMENT
LOWbacktesting/_plotting.py495 # Check if resampling was downsampling; error on upsamplingSTRING
Self-Referential Comments1 hit · 3 pts
SeverityFileLineSnippetContext
MEDIUMdoc/examples/Quick Start User Guide.py95 # Define the two MA lags as *class variables*COMMENT
Modern Structural Boilerplate2 hits · 2 pts
SeverityFileLineSnippetContext
LOWbacktesting/backtesting.py1772__all__ = [getattr(v, '__name__', k)CODE
LOWbacktesting/lib.py640__all__ = [getattr(v, '__name__', k)CODE
Slop Phrases1 hit · 2 pts
SeverityFileLineSnippetContext
LOWdoc/examples/Trading with Machine Learning.py283# Also make sure to familiarize yourself with the fullCOMMENT