Skip to content

Releases: joaquinbejar/OptionStratLib

v0.5.3

11 Jun 14:55
43e2cea

Choose a tag to compare

Release Notes: Version 0.5.3 - Delta Neutrality Fixes for Short Strangle

Summary

This emergency patch addresses critical issues in delta neutrality calculations for the short_strangle strategy. It also brings improvements in validation logic, code structure, and test coverage to ensure more reliable and accurate execution.


What's New

  • generate_delta_adjustments Function: Newly implemented method for calculating delta adjustments with improved precision and robust error handling.

Enhancements

  • Fully refactored delta adjustment logic: simplified contract calculations, removed redundant code, and improved error handling.
  • Separated call and put implied volatility handling in the short_strangle strategy for more accurate modeling.
  • Enhanced delta neutrality validation by checking total size and improving error messages.
  • Updated visualizations with enriched Plotly features.
  • General code cleanup: removed unused imports, redundant spacing, and standardized numeric formatting.

Bug Fixes

  • Fixed incorrect delta adjustment logic that produced inaccurate results in certain configurations.
  • Improved error handling for failed delta adjustment generation to prevent silent failures.
  • Refined delta neutrality validation logic for greater accuracy and robustness.

Documentation Updates

  • Updated in-code comments to clarify delta adjustment logic.
  • Enhanced test suite structure and readability.

Migration Notes

  • No breaking changes introduced. Users are strongly encouraged to update to benefit from the critical fixes and enhancements.

v0.5.2

10 Jun 08:28
e2e286c

Choose a tag to compare

Release v0.5.2: Plotly Visualization, Code Cleanup, and Macro Improvements

Description

This pull request delivers the beta version v0.5.2-beta.1, introducing substantial improvements across plotting, macro utilities, testing, and internal structure. A major enhancement includes integrating plotly.rs for visualizing strategy payoffs, particularly for the short strangle strategy. Furthermore, the codebase has undergone systematic cleanup, documentation enrichment, macro expansion, and dependency management refinement—enhancing maintainability, clarity, and usability.


Changes Made

  • Visualization Enhancements:

    • Integrated plotly.rs to visualize profit/loss charts.
    • Added new short strangle P/L visualization with segment coloring and zero lines.
    • Enabled Plotly features (kaleido) in the library.
    • Improved HTML output and formatting of embedded plots.
  • Macro and Trait Refactoring:

    • Added impl_json_display_pretty, impl_json_debug_pretty for structured JSON output.
    • Refactored usage of pos! and standardized with spos! for signed positive numbers.
    • Improved macro coverage with unit tests.
  • Library and Code Cleanup:

    • Removed deprecated CustomStrategy implementation.
    • Eliminated unused functions and variables in pricing utilities.
    • Migrated to workspace-based dependency configuration.
    • Cleaned up stray whitespaces, improved module declarations, and test formatting.
    • Removed old plotly.rs files and re-vendored with updates.
  • Testing Improvements:

    • Enhanced test coverage for OptionData, OptionChain, and macro utilities.
    • Improved error handling and assertions for numerical stability in implied volatility calculations.
    • Updated option semantics in tests for consistency (SP500AAPL).
  • Documentation and Usability:

    • Added inline documentation for key traits, macros, and methods.
    • Introduced structured example outputs and adjusted builder parameter defaults.

Testing

  • Unit Tests:

    • Verified new macros and visual components.
    • Tested calculate_iv utility across edge cases like zero DTE.
    • Validated OptionData and OptionChain behavior with updated parameters.
  • Manual Testing:

    • Manually confirmed correctness of generated plots.
    • Verified P/L visualization against known strategies.
  • Refactoring Validation:

    • Ensured compilation and execution across updated binaries and examples.
    • Confirmed logging consistency via setup_logger across example bins.

Screenshots/Examples

  • Embedded plotly charts for short strangle and short straddle.
  • Updated HTML files showing visual enhancements.

Additional Notes

  • This release significantly improves maintainability by standardizing formatting, macros, and plot generation logic.
  • Follow-up work includes further extending visualization support for other strategies and refining macro ergonomics.

References

  • Supersedes earlier plotly.rs visual patches and macro improvements.

Checklist

  • Code changes reviewed and linted.
  • Documentation updated with inline and example-based explanations.
  • All unit and integration tests pass.
  • Plotly visualization manually verified.
  • Redundant code and dependencies removed.

v0.5.1

29 May 14:11
d740e2c

Choose a tag to compare

Release v0.5.1: Improved Implied Volatility Calculation, Refactors, and Documentation Enhancements

Description

This pull request finalizes the v0.5.1 beta release, which introduces major improvements to implied volatility (IV) calculations, enhanced macro and type handling, refactors for consistency, and expanded documentation. The release also includes updated test cases, parameter handling improvements, and utility enhancements aimed at improving code clarity, maintainability, and performance, particularly for edge cases in options pricing.


Changes Made

  • Implied Volatility Enhancements:

    • Introduced calculate_iv utility.
    • Replaced Newton-Raphson with parallelized brute-force search for better performance and accuracy.
    • Improved clamping, error handling, and test coverage, especially for zero DTE scenarios.
  • Macro and Type Refactors:

    • Standardized pos! to spos! usage for consistency in signed positive values.
    • Updated Positive type with sub_or_zero, sub_or_none methods.
    • Improved Display/Debug trait macros with pretty JSON formatting.
  • Documentation and Usability:

    • Added inline documentation to key methods, macros, and types like OptionData.
    • Refined parameter naming and removed unused variables in simulation and test files.
  • Parameter and Utility Updates:

    • Updated OptionDataPriceParams, OptionChainBuildParams to use Some(...) consistently.
    • Enhanced OptionData to support optional extra_fields.
  • Test Refactors and Additions:

    • Adjusted expectations, reduced error margins, and improved test clarity.
    • Removed deprecated test data, unused variables, and renamed parameters for clarity.

Testing

  • Unit Tests: Extensive coverage for all new utilities, especially calculate_iv.
  • Edge Cases: Special focus on zero volatility, zero DTE options, and non-convergent scenarios.
  • Manual Testing: Verified changes in simulation output and test harness consistency.

Screenshots/Examples

Not applicable for this update.


Additional Notes

  • This release significantly improves robustness for volatility calculation in high-frequency trading or short-dated options.
  • Prepares the codebase for future integrations with visualization libraries like Plotly via the plotly and kaleido features now enabled.

References

  • Resolves multiple internal improvements aligned with issue themes on documentation clarity, IV computation, and macro usage consistency.

Checklist

  • Code refactored for consistency and clarity.
  • New utility methods and macros documented.
  • All tests updated and passing.
  • Version bumped to v0.5.1.
  • README and Cargo.toml updated accordingly.

v0.5.0

18 May 15:50
fd9aa1b

Choose a tag to compare

Release Notes: Version 0.5.0 – Advanced Strategy Engine & Visualization Overhaul

Summary

Version 0.5.0-beta.1 marks a major milestone with the introduction of enhanced strategy frameworks, dynamic trade modeling, and robust visualization powered by Plotly. This beta release refines strategy APIs, introduces conditional rendering capabilities, expands test coverage, and improves documentation for ease of adoption.


What's New

  • Strategy Enhancements: Implemented new strategy modules, including Short/Long Calls and Puts, Strangles, Straddles, Spreads, and Butterflies. All strategies now follow the BasicAble trait with consistent get_ prefixed APIs.
  • Trade Modeling: Added a comprehensive Trade module, supporting trade status management, PnL calculations, and custom trade states via TradeStatusAble.
  • Graphing Overhaul: Replaced Plotters with Plotly for interactive charting. Added support for HTML/PNG exports, 3D surface plotting, and enhanced GraphConfig customization.
  • Monte Carlo Simulations: Introduced tests and visualizations for simulations using Plotly, including MathJax support for mathematical rendering.
  • Rolling Strategies: Added roll_in and roll_out operations for managing evolving positions.

Enhancements

  • Refactored strategy and trait method names for clarity and consistency (get_ prefix).
  • Modularized feature flags: plotly, kaleido for conditional compilation of visualization features.
  • Updated the Black-Scholes model to include dividend yield support.
  • Improved logging, error handling, and import structure across modules.
  • Enhanced test coverage for option pricing, graphing, and strategy behavior.
  • Upgraded rand crate to version 0.9.1 for improved compatibility.
  • Streamlined GitHub workflows for code coverage and semantic versioning.

Bug Fixes

  • Fixed delta handling in get_position_with_delta for accurate filtering and precision.
  • Corrected round_to_nice_number output in documentation.
  • Removed unused or deprecated test attributes and features for cleaner test execution.
  • Addressed redundant code in strategy implementations and improved test assertions.

Breaking Changes

  • Deprecated and removed legacy Display and Default implementations for strategies.
  • Replaced title() with get_title() across strategy modules.
  • Reorganized strategies under a consistent trait structure, requiring migration to new method signatures and module paths.

Documentation Updates

  • Refactored and expanded library documentation with new sections for geometry tools, visualization, simulation, and strategy classification.
  • Updated README with enhanced Plotly examples, coverage details, and a link to the new wiki.
  • Added inline examples and trait usage guidelines across core modules.

Migration Notes

  • Visualization: Enable plotly and kaleido features in Cargo.toml to use charting and export capabilities.
  • Strategy Refactoring: Update any usage of old strategy methods to use get_ prefixed versions and adapt to new module paths.
  • Feature Flags: Explicitly toggle features as needed (plotly, kaleido) for modular builds.
  • Deprecated Modules: Remove dependencies on spanish.py, Plotters, and ShortStrangle.

Release Links

v0.4.6

01 May 18:51
1d6bebb

Choose a tag to compare

Release Notes: Version 0.4.6 - Advanced Simulation and Option Series Enhancements

Summary

This release introduces foundational improvements to the simulation engine, a more flexible system for modelling volatility, and expanded support for option series workflows. The update also refines backtesting tools, enhances documentation, and includes key quality-of-life upgrades in code structure and test coverage.


What's New

  • OptionSeries and Series Module: Added the OptionSeries struct and a new series module to manage collections of option chains by expiration, supporting analysis across different timeframes.
  • Backtesting Framework: Introduced detailed data structures and metrics for trade statistics, drawdown, capital utilisation, and overall strategy performance.
  • Random Walk Simulation: A new example using geometric Brownian motion for generating option series, complete with bitmap visualisation support.

Enhancements

  • Replaced skew_factor with more intuitive smile_curve and added skew_slope for better volatility modeling.
  • Refactored the build_series function to construct from OptionSeriesBuildParams, improving consistency and validation.
  • Improved strike interval handling using a new strike_step function.
  • Added Rayon and Indicatif for parallel simulations with progress feedback.
  • Enhanced conversion capabilities with From<OptionSeries> for Positive.
  • Simplified fmt function signature in OptionDataPriceParams for improved readability.

Bug Fixes

  • Fixed formatting issues in the short strangle test file to comply with project standards.
  • Streamlined call/put validations and removed redundant test cases for cleaner logic and faster test execution.

Breaking Changes

  • The renaming of skew_factor to smile_curve and updated constructor signatures require adjustments in existing simulation scripts and configurations.
  • Method and parameter names related to volatility modelling and option chain building have been updated for clarity.

Documentation Updates

  • Detailed documentation added for OptionSeriesBuildParams, including field and method descriptions.
  • Introduced a Mermaid class diagram explaining the structure of the backtesting module.
  • Updated README and Cargo files to reflect version bump and newly supported features.

Migration Notes

  • Review all simulation scripts for updated parameter names (skew_factorsmile_curve, strike_interval adjustments).
  • Refactor any custom implementations using OptionChain or OptionSeriesBuildParams to align with the new constructors and methods.
  • Ensure dependencies are updated for uuid, rayon, and indicatif to match project versions.

Release Links

v0.4.5

24 Apr 10:13
6761b1e

Choose a tag to compare

Release v0.4.5: Simulator Enhancements, Visualization Tools, and Historical Symbol Support

Description

This pull request delivers a major update to the project, centered around simulation functionality, visualization improvements, and metadata support for historical simulations. It introduces a fully-featured Simulator module, updates to plotting capabilities, and adds a symbol field to WalkType::Historical for clearer asset tracking. This release also includes key refactorings, documentation improvements, and compatibility updates with external tools like Mermaid.


Changes Made

  • Simulator Implementation:

    • Introduced a new Simulator module for random walk generation, visualization, and management.
    • Enhanced with extensive documentation, iterator support, and test coverage.
  • Visualization Enhancements:

    • Added graph function in randomwalk.rs to support plotting with an inverted X-axis.
    • Introduced build_chart_inverted macro in visualization for simplified graph setup.
  • Historical Data Improvements:

    • WalkType::Historical now includes an optional symbol field to represent asset identifiers.
  • Mermaid Syntax Updates:

    • Replaced deprecated Mermaid configuration with updated syntax in src/lib.rs and README.md.
  • Documentation & Scripts:

    • Added shell script to convert HTML docs to Markdown via pandoc.
    • Generated initial Markdown documentation for the optionstratlib crate.
  • Additional Updates:

    • Added iter method to OptionData for easier traversal.
    • Added strike getter method and serialization tests for WalkType.
    • Cleaned up README by removing redundant anchor tags.
    • Version bump to 0.4.5 across README, Cargo.toml, and source files.

Testing

  • Unit Tests:

    • Serialization tests added for all WalkType variants.
    • Unit tests created for the new Simulator methods and macros.
  • Manual Validation:

    • Verified visual outputs for inverted graphs and Mermaid diagrams.
    • Checked historical simulation behavior with the symbol field populated and omitted.

Additional Notes

  • These enhancements pave the way for more complex simulation scenarios and improved documentation workflows.
  • Future improvements could include real-time graph interactivity and strategy-based analysis integrations.

Checklist

  • Code changes reviewed and documented.
  • All new features tested.
  • README and version metadata updated.
  • Mermaid diagrams confirmed to render properly.

v0.4.4

17 Apr 09:25
99dbe2a

Choose a tag to compare

Release Notes: Version 0.4.4 - Enhanced Simulations and Logging

Summary

Version 0.4.4 introduces comprehensive improvements across simulation capabilities, data handling, and logging consistency. This release enhances historical data support, refines volatility management, boosts test coverage, and unifies the logging system using tracing, delivering a more robust and developer-friendly experience.


What’s New

  • Historical Chain Builder: Added historical_build_chain.rs to simulate option chains using historical price data and volatility.
  • Delta Hedging Simulation: Introduced a multithreaded delta hedging example using OHLCV data and JSON output.
  • WalkType Enum Expansion: Added a Historical variant supporting serialized/deserialized historical walk data.
  • Sample Dataset: Included cl-1m-sample.zip for demonstration and testing.

Enhancements

  • Refactored statistical curve generation and volatility handling to support edge cases like zero deviation or skewness.
  • Improved PnL metrics with documentation, better logging (tracing), and structural flexibility.
  • Unified logging across modules using tracing::info, replacing all instances of println!.
  • Streamlined OptionChain with new public methods: get_position_with_delta and improved delta-based positioning.
  • Enhanced test suite covering edge cases in curve detection, volatility scenarios, and financial simulations.
  • Standardized file and code formatting for clarity and consistency.

Bug Fixes

  • Corrected test assertions to ensure proper validation in Point2D and pricing modules.
  • Removed outdated delta_hedging binaries and replaced debug prints with structured logs.
  • Fixed parameter validations and resolved typos in key strategy implementations.

Breaking Changes

  • Deprecated legacy binaries (delta_hedging, delta_hedging_adjust) have been removed. Users depending on these must migrate to the new simulation scripts.

Documentation Updates

  • Expanded inline documentation for PnL-related structs and enums, improving clarity.
  • Updated test descriptions and added code examples for both random and historical chain simulations.

Migration Notes

  • Replace any use of removed binaries with the new delta hedging simulation script.
  • Ensure the logging system is compatible with the tracing crate.
  • Review the new WalkType::Historical variant usage if working with historical data input.

Release Links

v0.4.3

10 Apr 08:16
04f41ce

Choose a tag to compare

This pull request delivers significant upgrades to the delta hedging simulation, introduces a comprehensive profit and loss (PnL) metrics tracking system, and improves robustness across statistical and geometric utilities. It focuses on enhancing simulation performance with parallel processing, refining error handling, and increasing test coverage. The changes ensure better maintainability, improved performance, and more precise financial metrics for analysis and debugging.


Changes Made

  • Delta Hedging Simulation

    • Introduced parallel processing using Rayon for delta hedging.
    • Added configurable delta ranges, volatility metrics extraction, and structured output handling.
    • Refactored volatility and log returns calculations for clarity and reusability.
  • PnL Metrics System

    • Added PnLMetrics and PnLMetricsStep structs with serialization and display traits.
    • Enhanced delta adjustment tracking with initial_volumes, final_volumes, and delta_adjustments.
    • Introduced PnLMetricsDocument for persistent, thread-safe PnL storage.
  • Error Handling and Validation

    • Improved error messages in pricing and position modification.
    • Added validation logic and assertions for strategy configuration and parameter correctness.
  • Code Refactors

    • Standardized code formatting and file organization.
    • Refactored statistical and geometric utilities (curve generation, contains_point, Point2D) for efficiency and clarity.
  • Test Coverage

    • Added unit tests for:
      • Delta adjustments and PnL steps.
      • Statistical curves, prominence detection, and invalid inputs.
      • File I/O and edge case behavior.
    • Improved test stability by adjusting tolerances and removing flaky validations.
  • Utilities and Dependencies

    • Added new dependencies: Rayon, num_cpus, itertools, lazy_static.
    • Added example dataset (cl-1m-sample.zip) for testing.

Testing

  • Unit Tests: Comprehensive tests added for all new and modified modules, including strategy validation, curve logic, and file handling.
  • Edge Case Handling: Explicit checks for NaN, Infinity, zero volatility, and missing dates.
  • Manual Testing: Validated delta hedging outputs with sample OHLCV data and different parameter combinations.

Screenshots/Examples

  • JSON output from delta hedging simulations includes detailed PnL metrics, volatility stats, and adjustment steps.
  • Example test cases for detecting peaks/valleys and validating error conditions in geometric utilities.

Additional Notes

  • This release deprecates legacy binaries (delta_hedging, delta_hedging_adjust) in favor of streamlined, parallelized simulations.
  • Modular refactors lay groundwork for future enhancements in volatility modeling and strategy optimizations.

References

  • Related commits include implementation details for volatility extraction, delta filters, and error handling improvements across modules.

Checklist

  • Code changes reviewed and tested.
  • Documentation and examples updated.
  • New dependencies added and locked in Cargo.toml.
  • All unit tests passing.
  • Redundant code and binaries removed.

v0.4.2

04 Apr 06:52
a9c4d3e

Choose a tag to compare

Version 0.4.2 introduces a new standardized transaction management system with the TransactionAble trait and enhancements to error handling and profit/loss tracking. The release also focuses on improving implied volatility validation and streamlining the codebase for maintainability.


What's New

  • TransactionAble Trait: Introduced to standardize transaction management with methods for adding and retrieving transactions.
  • Transaction Module: Added new Transaction and TransactionStatus structs, alongside robust methods for tracking and calculating PnL.

Enhancements

  • Implemented TransactionAble for the Position struct to integrate transaction handling.
  • Expanded TransactionError with detailed documentation for improved clarity and debugging.
  • Renamed calculate_pnl to pnl for conciseness and better readability.
  • Refactored and reorganized imports for clarity and consistency.
  • Normalized implied volatility across strategies, ensuring values are ≤ 1 and improving error messages.
  • Added a helper utility for parsing OHLVC CSV data and updated dependencies for ZIP file handling.

Bug Fixes

  • Fixed formatting inconsistencies in transaction and error modules, including whitespace cleanup and comment alignment.

Breaking Changes

  • Removed the PnLCalculator trait and associated tests. This simplifies the codebase but may impact users relying on this abstraction.

Documentation Updates

  • Updated the version number to v0.4.2 across README, Cargo.toml, and in-code comments for consistency.

Migration Notes

  • Users relying on PnLCalculator should transition to using the new PnL methods within the Transaction module.
  • Ensure all custom implied volatility inputs are normalized (≤ 1) to avoid assertion errors.

Acknowledgments

Thanks to Joaquin Bejar for leading the implementation and refactoring efforts in this release.


Release Links

v0.4.1

27 Mar 19:01
d16ec01

Choose a tag to compare

Summary

This beta release introduces major improvements to the modularity, testability, and clarity of the simulation engine and option chain generators. With a complete overhaul of step handling, serialization, and display traits, this version sets a solid foundation for robust simulation workflows, enhanced logging, and more maintainable code.


What’s New

  • Random Walk Simulation Support: Introduced the RandomWalk struct with traits and utilities to enable flexible two-dimensional stochastic simulations.
  • Custom Generator Modules: Added generator_optionchain and generator_positive for clearer and reusable option chain generation.
  • Example: Random Walk Visualization: New example showcasing visualized random walk simulations using custom walkers and generators.

Enhancements

  • Refactored Simulation Architecture: Modularized WalkType, WalkParams, Step, Xstep, and Ystep into dedicated modules for improved structure.
  • Improved Step Serialization & Display: Added JSON serialization and detailed Display implementations for better debug and output readability.
  • Graphing Optimizations: Simplified graph APIs, improved precision, and replaced println with tracing::info for logging.
  • Time Handling: Integrated days-left computation methods for better expiry-based analysis in graphs.
  • Test Coverage Expansion: Added extensive unit tests across risk models, axis types, and simulation components.

Bug Fixes

  • Corrected ownership and reference handling in create_chain_from_step.
  • Fixed logic and test expectations for RiskCategory evaluations.
  • Removed legacy test files and unused imports/variables for cleaner builds.

Breaking Changes

  • Module Renaming: step module renamed to steps – update all related imports.
  • API Cleanup: Methods involving x-values in graph functions have been simplified, which may affect existing visualization code.
  • Struct Reorganizations: Users depending on internal structure of WalkParams, WalkType, or Step may need to adapt to the new modular layout.

Documentation Updates

  • Updated version references in Cargo.toml, README.md, and lib.rs to 0.4.1.
  • Enhanced inline documentation and code comments, especially around OptionData, Step, and simulation modules.
  • Removed outdated examples and added illustrative random walk simulation examples.

Migration Notes

  • Users should review and update any imports referencing step, WalkType, or WalkParams to match the new module structure.
  • Any custom visualizations or simulations should verify compatibility with updated days_left logic and serialization changes.
  • Ensure that logging configurations support tracing for effective debug output.

Acknowledgments

Huge thanks to Joaquin Bejar for spearheading the refactor, enhancing modularity, and significantly improving the reliability and maintainability of the codebase.


Release Links