Skip to content

Conversation

@joaquinbejar
Copy link
Owner

Add strangle strategy and related assets

This commit includes a new Rust example for the short strangle options strategy, along with two image files. The example script demonstrates setting up the strategy and generating a profit/loss chart, saved as "short_strangle_profit_loss_chart.png". The gold_princes.png file appears to be included but its purpose is unclear.

This commit includes a new Rust example for the short strangle options strategy, along with two image files. The example script demonstrates setting up the strategy and generating a profit/loss chart, saved as "short_strangle_profit_loss_chart.png". The gold_princes.png file appears to be included but its purpose is unclear.
Introduce a `fees` method to the `Strategies` trait to allow implementations to specify any fees associated with the strategy. This addition aims to improve the accuracy of cost and profit calculations by factoring in fees.
Change the visibility of the strangle module from private to public. This allows other parts of the application to access and use the strangle module directly.
Corrected indentation in break_even calculation to improve readability. Added a new method fees to calculate the total transaction fees incurred for the strategy.
This commit introduces the `LongStrangle` and `ShortStrangle` strategies in `strangle.rs`. These strategies define their respective characteristics, initialization, and functions for profit calculation, break-even points, max profit, and max loss. Additionally, graph plotting features have been implemented for both strategies.
Refactor the fee calculation for improved readability and consistency with the break-even calculation format. Adjust indentation in the break-even computation for better alignment and visual clarity. These changes do not alter any logic but enhance code maintainability.
These attributes suppress dead code warnings for the `abs` and `is_infinite` methods. This change ensures the compiler does not generate unnecessary warnings for these methods, which might be used in future implementations or are conditionally compiled.
Adjusted the format for multi-line strings and method chaining to improve readability and code style consistency. This change affects both the short and long strangle strategy descriptions and several method implementations.
Aligned inline comments and adjusted multi-line formatting in `strategy_short_strangle.rs` to improve code readability and maintainability. Ensured consistent spacing and indentation for better visual clarity.
Refreshed the profit-loss chart visualization for the short strangle strategy. This ensures the latest data and formatting standards are represented.
Introduced a default `area` method in the base strategy returning infinity. Also added the `num_traits::Float` import to support this new method.
Adjusted the calculation of break-even points and the lower break-even to reflect half of the net premium received. Introduced a new method `area` to calculate the profitability area under the break-even points normalized by the underlying price.
Adjusted key parameters such as call_strike, put_strike, quantity, and premiums for a more realistic short strangle strategy. Enhanced logging format for better precision and added a new profit area log entry.
Reordered `get_values` and `get_vertical_lines` methods in `Graph` trait implementations for `ShortStrangle` and `LongStrangle` to follow consistent structure. Added comprehensive unit tests for `ShortStrangle` to ensure accuracy of break-even points, profit calculations, and other properties.
Implemented comprehensive unit tests for the Long Strangle strategy, including tests for initialization, break-even calculation, total cost, and profit calculation. This ensures the robustness and accuracy of strategy-related computations.
Introduce a visual representation of the long strangle strategy. This chart helps in better understanding the profit and loss zones for traders.
Introduce a new example demonstrating the implementation of a long strangle options strategy. This includes detailed setup, visualizations, and logging for comprehensive strategy analysis.
Updated break-even points calculation by dividing total cost by 2.0. Adjusted code formatting for better readability and removed unused imports in tests.
Updated log statements to include dollar symbols for net premium, max profit, max loss, and total fees. This change improves clarity by clearly indicating that these values are monetary amounts.
Moved the `num_traits::Float` import to improve code organization and consistency. This change helps maintain readability and follows standard import placement conventions.
Adjusted spacing around division operations and reformatted long assert statements for clarity. Removed redundant newline and ensured consistent formatting in the test module.
Adjusted the log format for "Net Premium Received" to enhance readability. This change ensures better alignment and consistency in the output logs.
@joaquinbejar joaquinbejar merged commit 29a2433 into main Sep 22, 2024
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 81.10236% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strategies/strangle.rs 83.73% 20 Missing ⚠️
src/strategies/base.rs 0.00% 2 Missing ⚠️
src/strategies/bull_call_spread.rs 0.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files with missing lines Coverage Δ
src/utils/decimal.rs 90.69% <ø> (ø)
src/strategies/base.rs 0.00% <0.00%> (ø)
src/strategies/bull_call_spread.rs 77.41% <0.00%> (-2.59%) ⬇️
src/strategies/strangle.rs 83.73% <83.73%> (ø)

... and 1 file with indirect coverage changes

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.

3 participants