Releases: joaquinbejar/OptionStratLib
v0.5.3
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_adjustmentsFunction: 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_stranglestrategy 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
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.rsto 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.
- Integrated
-
Macro and Trait Refactoring:
- Added
impl_json_display_pretty,impl_json_debug_prettyfor structured JSON output. - Refactored usage of
pos!and standardized withspos!for signed positive numbers. - Improved macro coverage with unit tests.
- Added
-
Library and Code Cleanup:
- Removed deprecated
CustomStrategyimplementation. - 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.rsfiles and re-vendored with updates.
- Removed deprecated
-
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 (
SP500→AAPL).
- Enhanced test coverage for
-
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_ivutility across edge cases like zero DTE. - Validated
OptionDataandOptionChainbehavior 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_loggeracross 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.rsvisual 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
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_ivutility. - 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.
- Introduced
-
Macro and Type Refactors:
- Standardized
pos!tospos!usage for consistency in signed positive values. - Updated
Positivetype withsub_or_zero,sub_or_nonemethods. - Improved
Display/Debugtrait macros with pretty JSON formatting.
- Standardized
-
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.
- Added inline documentation to key methods, macros, and types like
-
Parameter and Utility Updates:
- Updated
OptionDataPriceParams,OptionChainBuildParamsto useSome(...)consistently. - Enhanced
OptionDatato support optionalextra_fields.
- Updated
-
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
plotlyandkaleidofeatures 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
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
BasicAbletrait with consistentget_prefixed APIs. - Trade Modeling: Added a comprehensive
Trademodule, supporting trade status management, PnL calculations, and custom trade states viaTradeStatusAble. - Graphing Overhaul: Replaced
PlotterswithPlotlyfor interactive charting. Added support for HTML/PNG exports, 3D surface plotting, and enhancedGraphConfigcustomization. - Monte Carlo Simulations: Introduced tests and visualizations for simulations using Plotly, including MathJax support for mathematical rendering.
- Rolling Strategies: Added
roll_inandroll_outoperations for managing evolving positions.
Enhancements
- Refactored strategy and trait method names for clarity and consistency (
get_prefix). - Modularized feature flags:
plotly,kaleidofor 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
randcrate 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_deltafor accurate filtering and precision. - Corrected
round_to_nice_numberoutput 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
DisplayandDefaultimplementations for strategies. - Replaced
title()withget_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
plotlyandkaleidofeatures inCargo.tomlto 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, andShortStrangle.
Release Links
v0.4.6
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
OptionSeriesstruct and a newseriesmodule 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_factorwith more intuitivesmile_curveand addedskew_slopefor better volatility modeling. - Refactored the
build_seriesfunction to construct fromOptionSeriesBuildParams, improving consistency and validation. - Improved strike interval handling using a new
strike_stepfunction. - Added
RayonandIndicatiffor parallel simulations with progress feedback. - Enhanced conversion capabilities with
From<OptionSeries> for Positive. - Simplified
fmtfunction signature inOptionDataPriceParamsfor 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_factortosmile_curveand 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_factor→smile_curve,strike_intervaladjustments). - Refactor any custom implementations using
OptionChainorOptionSeriesBuildParamsto align with the new constructors and methods. - Ensure dependencies are updated for
uuid,rayon, andindicatifto match project versions.
Release Links
v0.4.5
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
Simulatormodule for random walk generation, visualization, and management. - Enhanced with extensive documentation, iterator support, and test coverage.
- Introduced a new
-
Visualization Enhancements:
- Added
graphfunction inrandomwalk.rsto support plotting with an inverted X-axis. - Introduced
build_chart_invertedmacro invisualizationfor simplified graph setup.
- Added
-
Historical Data Improvements:
WalkType::Historicalnow includes an optionalsymbolfield to represent asset identifiers.
-
Mermaid Syntax Updates:
- Replaced deprecated Mermaid configuration with updated syntax in
src/lib.rsandREADME.md.
- Replaced deprecated Mermaid configuration with updated syntax in
-
Documentation & Scripts:
- Added shell script to convert HTML docs to Markdown via
pandoc. - Generated initial Markdown documentation for the
optionstratlibcrate.
- Added shell script to convert HTML docs to Markdown via
-
Additional Updates:
- Added
itermethod toOptionDatafor easier traversal. - Added
strikegetter method and serialization tests forWalkType. - Cleaned up README by removing redundant anchor tags.
- Version bump to
0.4.5across README, Cargo.toml, and source files.
- Added
Testing
-
Unit Tests:
- Serialization tests added for all
WalkTypevariants. - Unit tests created for the new
Simulatormethods and macros.
- Serialization tests added for all
-
Manual Validation:
- Verified visual outputs for inverted graphs and Mermaid diagrams.
- Checked historical simulation behavior with the
symbolfield 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
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.rsto 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
Historicalvariant supporting serialized/deserialized historical walk data. - Sample Dataset: Included
cl-1m-sample.zipfor 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 ofprintln!. - Streamlined
OptionChainwith new public methods:get_position_with_deltaand 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
Point2Dand pricing modules. - Removed outdated
delta_hedgingbinaries 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
tracingcrate. - Review the new
WalkType::Historicalvariant usage if working with historical data input.
Release Links
v0.4.3
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
PnLMetricsandPnLMetricsStepstructs with serialization and display traits. - Enhanced delta adjustment tracking with
initial_volumes,final_volumes, anddelta_adjustments. - Introduced
PnLMetricsDocumentfor persistent, thread-safe PnL storage.
- Added
-
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.
- Added unit tests for:
-
Utilities and Dependencies
- Added new dependencies:
Rayon,num_cpus,itertools,lazy_static. - Added example dataset (
cl-1m-sample.zip) for testing.
- Added new dependencies:
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
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
TransactionandTransactionStatusstructs, alongside robust methods for tracking and calculating PnL.
Enhancements
- Implemented
TransactionAblefor thePositionstruct to integrate transaction handling. - Expanded
TransactionErrorwith detailed documentation for improved clarity and debugging. - Renamed
calculate_pnltopnlfor 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
PnLCalculatortrait and associated tests. This simplifies the codebase but may impact users relying on this abstraction.
Documentation Updates
- Updated the version number to
v0.4.2acrossREADME,Cargo.toml, and in-code comments for consistency.
Migration Notes
- Users relying on
PnLCalculatorshould transition to using the new PnL methods within theTransactionmodule. - 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
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
RandomWalkstruct with traits and utilities to enable flexible two-dimensional stochastic simulations. - Custom Generator Modules: Added
generator_optionchainandgenerator_positivefor 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, andYstepinto dedicated modules for improved structure. - Improved Step Serialization & Display: Added JSON serialization and detailed
Displayimplementations for better debug and output readability. - Graphing Optimizations: Simplified graph APIs, improved precision, and replaced
printlnwithtracing::infofor logging. - Time Handling: Integrated
days-leftcomputation 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
RiskCategoryevaluations. - Removed legacy test files and unused imports/variables for cleaner builds.
Breaking Changes
- Module Renaming:
stepmodule renamed tosteps– 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, orStepmay need to adapt to the new modular layout.
Documentation Updates
- Updated version references in
Cargo.toml,README.md, andlib.rsto0.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, orWalkParamsto match the new module structure. - Any custom visualizations or simulations should verify compatibility with updated
days_leftlogic and serialization changes. - Ensure that logging configurations support
tracingfor 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