Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add naked single-option strategies #7231

Conversation

jhonabreul
Copy link
Collaborator

Description

Add naked call and put single-option strategies in order to allow matching naked positions in the OptionStrategyPositionGroupResolver. This allows doing things like placing orders for an option strategy that would liquidate existing positions with only one leg ramianing. Previous to this change, a single leg option strategy was never matched and the orders could not be placed.

For instance, take the situation where you want to roll out a front month contract for a back month one using a strategy (see the new RollOutFrontMonthToBackMonthOptionUsingCalendarSpreadRegressionAlgorithm algorithm):

  • You sell a front month contract and hold the position
  • Then you roll it out to the next month, by placing a calendar spread order that would liquidate the existing position and sell the back month contract.

In this situation, after resolving the positions, the OptionStrategyPositionGroupResolver tries to match the resolved strategy (a single leg) with the existing definitions, which is why we needed the single-leg strategies.

Note: this should be merged after rebasing #7230. That bug fix would revert the stats change in OptionShortCallMarginCallEventsAlgorithm.

Related Issue

Closes #7184

Motivation and Context

Requires Documentation Change

How Has This Been Tested?

Unit tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

Copy link
Member

@Martin-Molinero Martin-Molinero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🙌

@jhonabreul jhonabreul force-pushed the bug-7184-rolling-out-short-put-calendar branch from f705244 to 20e4b25 Compare May 30, 2023 17:07
Copy link
Member

@Martin-Molinero Martin-Molinero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@Martin-Molinero Martin-Molinero merged commit 82b3468 into QuantConnect:master May 30, 2023
5 checks passed
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.

Error rolling out short put calendar spread to next month
2 participants