Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added analyze_backtest which can be turned off. #717

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

brettelliot
Copy link
Collaborator

@brettelliot brettelliot commented Mar 5, 2025

Description by Korbit AI

What change is being made?

Introduce an analyze_backtest parameter across various strategy configurations to control if backtest analysis should be performed, and update related code and tests accordingly.

Why are these changes being made?

This change provides the ability to toggle backtest analysis on and off, offering more flexibility for users who might not need or want to perform analysis for every backtest execution. By default, analyze_backtest is enabled but can be disabled where it's unnecessary, improving efficiency and customization in backtesting workflows.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

@brettelliot brettelliot requested a review from grzesir as a code owner March 5, 2025 01:35
Copy link
Contributor

korbit-ai bot commented Mar 5, 2025

Important

Required App Permission Update

Noise Reduction Improvements

This update requests write permissions for Commit Statuses in order to send updates directly to your PRs without adding comments that spam notifications. Visit our changelog to learn more.

Click here to accept the updated permissions

To accept the updated permissions, sufficient privileges are required

@brettelliot brettelliot merged commit 7126a99 into be-dev Mar 5, 2025
1 check failed
Copy link
Contributor

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Fix Detected
Functionality Invalid Future Dates for Backtesting ▹ view
Functionality Example Doesn't Demonstrate New Feature ▹ view
Functionality Missing Initialization of analyze_backtest Flag ▹ view
Files scanned
File Path Reviewed
lumibot/tools/save_data.py
lumibot/example_strategies/classic_60_40.py
lumibot/example_strategies/crypto_50_50.py
lumibot/strategies/_strategy.py
lumibot/strategies/strategy.py

Explore our documentation to understand the languages and file types we support and the files we ignore.

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • Chat with Korbit on issues we post by tagging @korbit-ai in your reply.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Current Korbit Configuration

General Settings
Setting Value
Review Schedule Automatic excluding drafts
Max Issue Count 10
Automatic PR Descriptions
Issue Categories
Category Enabled
Documentation
Logging
Error Handling
Readability
Design
Performance
Security
Functionality

Feedback and Support

Note

Korbit Pro is free for open source projects 🎉

Looking to add Korbit to your team? Get started with a free 2 week trial here

Comment on lines +13 to +14
datetime_start = datetime(2025, 1, 13)
datetime_end = datetime(2025, 1, 18)
Copy link
Contributor

Choose a reason for hiding this comment

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

Invalid Future Dates for Backtesting category Functionality

Tell me more
What is the issue?

The backtesting dates are set in the future (2025), which will result in no historical data being available for analysis.

Why this matters

Alpaca will not be able to provide historical price data for future dates, causing the backtesting to fail or return empty results.

Suggested change ∙ Feature Preview

Change the dates to a past time period where historical data is available. For example:

datetime_start = datetime(2023, 1, 13)
datetime_end = datetime(2023, 1, 18)

Report a problem with this comment

💬 Chat with Korbit by mentioning @korbit-ai.

save_tearsheet=False,
show_indicators=False,
save_logfile=False,
analyze_backtest=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Example Doesn't Demonstrate New Feature category Functionality

Tell me more
What is the issue?

Setting analyze_backtest to False contradicts the developer's intent to add flexibility for backtest analysis.

Why this matters

Hard-coding this value to False in the example prevents users from seeing how to properly utilize the new analyze_backtest feature.

Suggested change ∙ Feature Preview

Either make the analyze_backtest parameter configurable or set it to True to demonstrate the feature:

analyze_backtest=True  # or make it a parameter

Report a problem with this comment

💬 Chat with Korbit by mentioning @korbit-ai.

Comment on lines +2908 to +2909
if not self._analyze_backtest:
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing Initialization of analyze_backtest Flag category Functionality

Tell me more
What is the issue?

The code adds a check for _analyze_backtest but there is no robust initialization or configuration of this flag. The flag could be undefined or uninitialized.

Why this matters

Without proper initialization, accessing _analyze_backtest could raise an AttributeError, causing the backtest functionality to fail unexpectedly.

Suggested change ∙ Feature Preview

Add proper initialization of the _analyze_backtest flag in the strategy's initialization code:

def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)
    self._analyze_backtest = kwargs.get('analyze_backtest', True)  # Default to True for backward compatibility

Report a problem with this comment

💬 Chat with Korbit by mentioning @korbit-ai.

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