Skip to content

Conversation

@joaquinbejar
Copy link
Owner

Pull Request: Release v0.2.3

Summary

This pull request introduces version 0.2.3, which includes new features, strategy implementations, performance improvements, and codebase refinements. The update ensures better functionality, robustness, and maintainability of the library.


Key Changes

1. New Strategies

2. Enhancements and Fixes

  • Error Handling:

    • Refactored max_profit and max_loss methods across multiple strategies to return Result types.
    • Improved robustness by handling potential None values with defaults.
  • Performance Improvements:

    • Updated the statrs crate to v0.18.0 for better compatibility and performance.
  • Code Cleanups:

    • Removed trailing whitespace and redundant inline comments across the codebase.
    • Refactored validation logic for clarity and reduced duplication.

3. Tooling and Utility Scripts

  • Added a script to detect and process Spanish comments in the codebase, aiding in translation management.

4. General Improvements

  • Reorganized imports and modules for better clarity and maintainability.
  • Updated project structure by introducing workspaces for improved modularity.

Documentation and Versioning

  • Version Bump:
    • Updated Cargo.toml and README.md to reflect the new version 0.2.3.

Testing

  • Comprehensive test coverage for all new strategies and features.
  • Validated edge cases for large, small, or invalid input values.
  • Verified profit/loss calculations and visualizations under various conditions.

Labels

release, enhancement, new strategies, testing, code cleanup

Additional Notes

This release prepares the library for broader use cases and ensures alignment with project standards for maintainable and reusable code.

joaquinbejar and others added 30 commits November 30, 2024 06:58
Update version number in README.md and Cargo.toml to reflect the latest release of the library. This prepares the project for any newly included features, bug fixes, or improvements that are part of version 0.2.3.
This commit introduces a probability analysis module for evaluating option strategies, including risk metrics. It includes implementations for calculating probabilities of profit, value expectations, and extreme profit scenarios. Several new test cases are also added to ensure accuracy for various input scenarios and configurations. (ref. #36)
Moved the `profit_range` and `probabilities` module declarations to improve logical organization within the codebase. Adjusted the formatting of the author comment block in `probabilities/mod.rs` for consistency. These changes enhance the code structure without altering functionality.  (ref. #36)
Condensed the parameter formatting for ProfitRange::new function calls to improve code readability and reduce unnecessary line breaks. This change doesn't affect the functionality but makes the codebase cleaner and easier to maintain.  (ref. #36)
Renamed the macro to `assert_positivef64_relative_eq` to reflect its new functionality, using `PositiveF64` instead of `Decimal` types. Added comprehensive tests to validate the macro's behavior with different value scenarios, including edge cases with zero and large values.  (ref. #36)
This commit removes several unnecessary line breaks in the test functions within `src/model/types.rs`. Cleaning up these line breaks improves readability and maintains a more consistent code style across the file.  (ref. #36)
Implemented default probability calculations when both volatility adjustment and trend are absent, providing default values for max profit and loss probabilities. Enhanced existing functionality with comprehensive tests for the analyze_probabilities and calculate_extreme_probabilities methods, ensuring robust performance across various scenarios. Cleaned up formatting and enhanced code readability.  (ref. #36)
Reorganized the project by introducing workspaces and moving examples into respective subdirectories. Updated `.gitignore` to handle new file paths and added necessary dependencies in each `Cargo.toml`. This enhances modularity and maintains code management efficiency.
Update module visibility to allow broader access to utilities and probabilities, facilitating external usage and integration. Adjust type name in model module for consistency and clarity.
Integrated a comprehensive probability analysis feature to both ShortStrangle and LongStrangle, enhancing their capability to perform complex financial assessments. This update includes calculating profit and loss ranges, expected value with volatility and trend adjustments, and extreme probability calculations. New test cases have been added to ensure reliability and correctness of these probability functions. (ref. #36)
…s-Probability-Trait-for-Options-Strategies

Feature/#36 implement success probability trait for options strategies
Introduce profit/loss charts for long and short straddle strategies to enhance visual analytics. Refactor strangle.rs by removing redundant whitespace and streamlining `ProfitLossRange` initializations for improved readability. (ref. #26)
…le-Strategy

Add long and short straddle P&L charts; optimize strangle.rs
Introduce scripts for long and short straddle strategies, focusing on best profit areas and ratios. Include associated profit/loss chart images for each strategy to visualize potential outcomes and enhancements. These additions aim to improve strategy evaluation and decision-making processes in options trading. (ref. #26)
Introduce `bull_put_spread` and `bear_call_spread` strategy modules to the strategies directory. These strategies provide options for trading with expectations of moderate price movements, expanding the available trading strategies in the codebase. Additionally, update the `mod.rs` file to include these new modules.
Reorder the import statements for strategy modules in mod.rs to maintain logical grouping and improve organization. This change does not affect the functionality but enhances readability and standardizes module arrangement.
Updated max_profit and max_loss functions to return Result<PositiveF64, &str> instead of PositiveF64. This change improves error handling by making it explicit when max profit or max loss is not applicable for a strategy. Additionally, re-implemented best_ratio and best_area functions to utilize find_optimal, removing panic situations.
Change the visibility of `OptionData` from `pub(crate)` to `pub` to allow access from outside the module. This modification facilitates usage in other parts of the codebase or by external crates.
The enum OptimizationCriteria is now public to allow its use outside of the module. This change facilitates better extensibility and reuse of this utility in other parts of the code.
Refactored code by incorporating the `Optimizable` trait in strategy modules for a cleaner and more modular design. Removed unused methods `best_ratio` and `best_area` from the custom strategies implementation to enhance code maintainability and reduce redundancy. This update streamlines the strategy optimization process and aligns with best practices.
Updated the `max_profit` and `max_loss` methods to return `Result<PositiveF64, &str>` instead of directly returning `PositiveF64`. This change enhances error handling capabilities. Additionally, refactored the use of these methods to utilize `unwrap_or(PZERO)` where necessary to handle potential errors gracefully.
Updated multiple functions in the strangle strategies to employ result-based error handling, improving robustness. Introduced error checks and updated test cases to ensure functions return expected results. Enhanced code readability and maintainability by removing and refactoring redundant code.
This commit updates the `max_profit` and `max_loss` methods to return `Result` types, adding error handling for cases when the calculations yield negative or invalid results. The changes include modifications to how the values are used throughout the codebase, ensuring proper handling with `unwrap_or` where default values are necessary. Additionally, the code has been cleaned up by removing unused functions and adding missing imports.
Updated the `max_profit` and `max_loss` functions in the `PoorMansCoveredCall` strategy to return `Result<PositiveF64, &str>`, providing better error handling. Adjusted related code to handle the new return type accordingly by using unwrap_or to default to `PZERO`. Removed redundant logging of price range to streamline the application's output.
This update modifies the `max_profit` and `max_loss` functions to return a `Result` type, enhancing the robustness of error handling. The changes also include adjustments to dependent calculations to accommodate the new return type. Additionally, removed obsolete methods and updated examples to reflect these improvements.
Refactored max_profit and max_loss methods in BullCallSpread to return Results, incorporating error handling. Updated related calculations and tests to use the Results and handle potential zero or error values gracefully.
This commit introduces the Bear Call Spread strategy to the codebase, adding its implementation along with accompanying visualization features. This includes profit/loss calculations, optimal strategy selection, and a complete suite of tests to ensure accuracy and reliability. (ref. #41)
…-Strategy-Implementation

Feature/#41 Implementation of Bear Call Spread Strategy with Enhanced Error Handling
The validation for matching expiration dates between short and long calls in bear call spreads has been removed. This change assumes that managing expiration dates is handled elsewhere or is unnecessary, simplifying the validation logic within this strategy module.
This commit introduces the complete implementation of the Bull Put Spread strategy, including its setup, validation, and test coverage. Key features include calculation of max profit, max loss, and break-even points, ensuring that the strategy only accepts valid configurations where the long put strike is less than the short put strike. Comprehensive test cases have been added to verify the correct behavior under various scenarios. (ref. #42)
joaquinbejar and others added 13 commits December 6, 2024 12:17
…Strategy-Implementation

Feature/#42 bull put spread strategy implementation
Simplified the logic for validating options by moving the detailed checking into the `base.rs` and removing redundant code in `bear_call_spread.rs`. Now, the `is_valid_short_option` and `is_valid_long_option` methods in `base.rs` use a more comprehensive approach based on the `FindOptimalSide` enum, enhancing code maintainability and reducing duplication.
Refactor bull_put_spread strategy by removing redundant option validation methods and the invalid price test. This change streamlines the price validation process, ensuring only essential conditions are checked while cleaning up the existing test suite for better maintainability.
Refactor the Bull Call Spread Strategy to include new features for optimization and validation. Add calculations for maximum profit, loss, and break-even points, as well as the ability to analyze profit and loss ranges, fees, and profit ratios. Tests have been added to ensure the correctness of strategy creation and its inherent calculations, improving the robustness of the implementation. (ref. #17)
…all-Spread-Strategy

Feature/#17 implement bull call spread strategy
This script locates Rust comments in a given directory, detects their language using `langdetect`, and highlights those written in Spanish. It provides a summary of files with Spanish comments, aiding in translation management.
This commit removes inline comments from various strategy and test files to enhance code readability and maintain consistency across the codebase. The comments that provided instructions or explanations within the function bodies were removed to make the code cleaner, assuming that the code itself is self-explanatory or that documentation and external resources will provide the necessary context. This change should streamline the development process by reducing clutter and potential maintenance burdens.
This commit removes unnecessary trailing whitespace from several files, enhancing code readability and consistency. No functional changes were made to the codebase, ensuring existing functionality remains unchanged.
This commit removes trailing whitespace across several lines in the bull_put_spread.rs file. These cleanups improve code readability and maintain consistency with style guidelines. No functional changes have been made to the code.
Implemented the bear put spread strategy and integrated it with the option chain for optimal profit ratio calculation. This enhancement includes new visualizations for profit/loss scenarios and comprehensive testing to ensure strategy accuracy and efficiency. (ref. #16)
…ut-Spread-Strategy

Feature/#16 implement bear put spread strategy
Modified several strategy-related files to use `unwrap_or(PZERO)` when calculating max profit and max loss to prevent potential runtime errors from None values. Synced library usage across the board by including the `PZERO` type from `optionstratlib`. Additionally, updated the `statrs` crate version to 0.18.0 in `Cargo.toml` for improved compatibility or performance.
This commit reorders the import statements in multiple strategy example files for better clarity and consistency. By grouping related imports together, it enhances readability and maintains a uniform style across the codebase.
@codecov
Copy link

codecov bot commented Dec 7, 2024

@joaquinbejar joaquinbejar merged commit f261d19 into main Dec 7, 2024
4 checks passed
@joaquinbejar joaquinbejar deleted the release/v0.2.3 branch December 7, 2024 16:48
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