Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Resolve order into multiple position groups

Open jhonabreul opened this issue 2 years ago • 0 comments

Expected Behavior

Lean can resolve orders into the possible several position groups that would be formed if position groups being held get impacted by the trades.

Actual Behavior

When you are holding options, either as strategies or single, and trading any of those options (again, either in strategies or single), the resulting position groups might be multiple, not just one as returned by SecurityPortfilioManager.TryCreatePositionGroup and OptionStrategyPositionGroupResolver.TryGroup.

For instance, if holding 10 bear call spreads with short option X and long option Y, then buying 5 of the option X, I end up having -5 X and 10 Y, wich would be group into a bear call position group with quantity 5 and a position group for option Y with quantity 5. This would be resolved into a single group, ignoring the others that get formed after the trade.

Potential Solution

Reproducing the Problem

See the Actual Behavior section

System Information

Windows 11

Checklist

  • [x] I have completely filled out this template
  • [x] I have confirmed that this issue exists on the current master branch
  • [x] I have confirmed that this is not a duplicate issue by searching issues
  • [x] I have provided detailed steps to reproduce the issue

jhonabreul avatar Jun 09 '23 20:06 jhonabreul