Skip to content

Add Zipline Backtesting Environment with ClassicModel Integration#54

Open
laurentvv wants to merge 2 commits into
mainfrom
feature/zipline-backtesting-1715705710406165164
Open

Add Zipline Backtesting Environment with ClassicModel Integration#54
laurentvv wants to merge 2 commits into
mainfrom
feature/zipline-backtesting-1715705710406165164

Conversation

@laurentvv

Copy link
Copy Markdown
Owner

This branch introduces a complete algorithmic backtesting pipeline using zipline-reloaded.

Features included:

  1. Data Ingestion (backtests/fetch_data.py): Fetches historical data from Yahoo Finance and formats it as a custom Zipline bundle (csvdir_equities).
  2. Data Filtering (backtests/filter_csv.py): Resolves specific data anomalies required by Zipline (like missing dates causing misalignment or capping the WTI negative prices of April 2020 which break Zipline's uint32 casting).
  3. Backtest Runner (backtests/run_zipline_backtest.py):
    • Dynamically pre-trains the system's ClassicModel on pre-backtest windows.
    • Executes day-by-day simulations, recreating technical indicators on rolling windows.
    • Applies the explicit user rule: "Never sell at a loss, always HOLD".
    • Outputs a summary table comparing the Model's performance against a passive "Buy and Hold" strategy and generates a plot (*_backtest.png).
  4. Pre-commit: Pre-commit hooks run and fixed linting / trailing whitespaces across all the files.

PR created automatically by Jules for task 1715705710406165164 started by @laurentvv

Co-authored-by: laurentvv <8775515+laurentvv@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@laurentvv laurentvv marked this pull request as ready for review June 13, 2026 13:33
Comment thread backtests/run_zipline_backtest.py Outdated
true_range = ranges.max(axis=1)
df["ATR_14"] = true_range.rolling(14).mean()

df.fillna(method="bfill", inplace=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Deprecated pandas fillna(method=...) syntax

The fillna(method="bfill", inplace=True) syntax was deprecated in pandas 2.0 and removed in pandas 3.0. Since the project uses pandas 2.2.3, this should use df.bfill(inplace=True) instead.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The previous CRITICAL issue about deprecated pandas fillna(method="bfill"...) syntax has been resolved. The code now correctly uses .bfill() on line 74.

No new issues found in the incremental changes (whitespace fixes and new file additions only).

Files Reviewed (11 files)
  • backtests/run_zipline_backtest.py - 0 issues (previous issue resolved)
  • backtests/fetch_data.py - new file, no issues
  • backtests/filter_csv.py - new file, no issues
  • backtests/test_zipline.py - new file, no issues
  • Other modified files - whitespace/trailing newline fixes only

Reviewed by laguna-m.1-20260312:free · 139,456 tokens

Co-authored-by: laurentvv <8775515+laurentvv@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant