Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By Yvictorv0.1.6PolyForm Noncommercial 1.0.0In 2 marketplaces
Backtests trading strategies on Polars DataFrames with stop loss, take profit and T+1 execution, and builds interactive HTML reports. Claims its reports need no extra dependencies and work offline.
Trending plugins
7-day copy clicks
Claude loads one when your task matches it, or you run it by name.
2 marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Blazingly fast portfolio backtesting for Polars
df.bt.backtest() namespacepip install polars-backtest
# or
uv add polars-backtest
import polars as pl
import polars_backtest as pl_bt
# Long format data: one row per (date, symbol)
df = pl.DataFrame({
"date": ["2024-01-01", "2024-01-01", "2024-01-02", "2024-01-02"],
"symbol": ["AAPL", "GOOGL", "AAPL", "GOOGL"],
"close": [100.0, 50.0, 102.0, 51.0],
"weight": [0.6, 0.4, 0.6, 0.4],
})
# Run backtest
result = df.bt.backtest(trade_at_price="close", position="weight")
Interactive, self-contained HTML report — no extra dependencies, works offline:
report = df.bt.backtest_with_report(position="weight", resample="M")
pl_bt.viz.show(report) # browser tab, or inline in notebooks
pl_bt.viz.save_html(report, "report.html") # standalone shareable file
pl_bt.viz.report_data(report) # JSON-safe payload for custom dashboards
Includes equity curve (benchmark overlay, log scale, range presets), drawdown, monthly return heatmap, trade return distribution, MAE scatter, and full stats. Light/dark mode follows the system.
300-day breakout strategy (~2000 stocks, 17 years daily data, 12M rows):
# Finlab
position = close >= close.rolling(300).max()
report = backtest.sim(position, resample="M")
# polars_backtest
df = df.with_columns(
(pl.col("close") >= pl.col("close").rolling_max(300).over("symbol"))
.alias("weight")
)
report = df.bt.backtest_with_report(position="weight", resample="M")
| Finlab | polars_backtest | |
|---|---|---|
| Time | 3.7s | 244ms |
| Speedup | 1x | 15x faster |
just bench # Run benchmarks
Get AI-powered assistance for writing and analyzing backtests.
# 1. Add the marketplace
/plugin marketplace add Yvictor/polars_backtest_extension
# 2. Install the plugin
/plugin install polars-backtest@polars-backtest-marketplace
After installation, Claude Code can help you:
get_metrics(), get_stats(), etc.import polars_backtest as pl_bt
# Function API
result = pl_bt.backtest(df, trade_at_price="close", position="weight")
# DataFrame namespace
result = df.bt.backtest(trade_at_price="close", position="weight")
result = df.bt.backtest(
trade_at_price="close",
position=pl.col("signal").cast(pl.Float64),
resample="M",
)
report = pl_bt.backtest_with_report(df, trade_at_price="adj_close", resample="M")
report
BacktestReport(
creturn_len=4219,
trades_count=6381,
total_return=8761.03%,
cagr=29.85%,
max_drawdown=-35.21%,
sharpe=1.13,
win_ratio=46.33%
)
report.get_stats() # or report.stats
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub yvictor/polars_backtest_extension --plugin polars-backtestPlugins from other owners that cover similar ground