Skip to content

Conversation

@brandonschabell
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings December 24, 2025 03:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a configuration parameter on_missing_price to the AlphaFlow class to control behavior when price data is unavailable. This provides flexibility for users to decide whether to fail fast with an error, log warnings, or silently continue with zero prices when data is missing.

Key changes:

  • Added on_missing_price parameter to AlphaFlow.__init__() with three modes: "raise" (default), "warn", and "ignore"
  • Modified get_price() to respect the configured behavior instead of always raising an error
  • Added defensive check in SimpleBroker to reject buy orders when price data returns zero

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
alphaflow/init.py Added on_missing_price parameter with validation in __init__() and updated get_price() to implement the three behavior modes
alphaflow/brokers/simple_broker.py Added zero price validation in _can_execute_order() for buy orders to prevent execution with invalid pricing
alphaflow/tests/test_alphaflow.py Added comprehensive test coverage for all three on_missing_price modes plus validation of invalid values

if self.on_missing_price == "raise":
raise ValueError(f"No price data for symbol {symbol} after timestamp {timestamp}")
elif self.on_missing_price == "warn":
logger.warning(f"No price data for symbol {symbol} after timestamp {timestamp}")
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The handling of the "ignore" case is implicit in the final return statement. For better code maintainability and clarity, consider making it explicit with an else clause or elif self.on_missing_price == "ignore": before the return statement. This would make the three cases more obvious and prevent potential bugs if additional options are added in the future.

Suggested change
logger.warning(f"No price data for symbol {symbol} after timestamp {timestamp}")
logger.warning(f"No price data for symbol {symbol} after timestamp {timestamp}")
elif self.on_missing_price == "ignore":
return 0.0

Copilot uses AI. Check for mistakes.
@brandonschabell brandonschabell merged commit e098489 into main Dec 24, 2025
6 checks passed
@brandonschabell brandonschabell deleted the missing-price-handling branch December 24, 2025 03:13
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.

2 participants