-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Description
Description
The current implementation of generate_delta_increasing_adjustments in the DeltaNeutrality trait does not properly handle cases where delta is zero. The calculation:
let qty = Positive((net_delta.abs() / delta).abs());can lead to a division-by-zero error when delta == 0. This issue aims to implement a safeguard to prevent this error and ensure stability in delta-neutral adjustments.
Tasks
Implementation:
- Modify the calculation to handle the case where
delta == 0. - Introduce a conditional check to avoid division by zero.
- Determine an appropriate fallback mechanism, such as:
- Skipping adjustments.
- Using a small epsilon value to prevent zero division.
- Logging a warning or returning an error.
Testing:
- Add test cases for
generate_delta_increasing_adjustmentsthat include:delta == 0deltawith very small values approaching zero.- Normal
deltavalues for regression testing.
Documentation:
- Update the method documentation to explain how zero delta cases are handled.
- Add comments in the code to clarify the fix.
Additional Notes
- Ensure the fix does not introduce unintended side effects in delta adjustments.
- The implementation should follow the project's error handling and logging conventions.
- Consider discussing with the team whether a fallback strategy (e.g., a minimal default value) is preferable over skipping adjustments.
Labels
bug, delta-neutrality, error-handling, testing, documentation
Metadata
Metadata
Assignees
Labels
No labels