Can't Maximize Position Size of OptionStrategies
See original GitHub issueExpected Behavior
We can place an order with OptionStrategies to maximize the position size (minimize the amount of margin remaining).
Actual Behavior
When we try to maximize the position size of OptionStrategies, we receive the error
Order Error: id: 1, Insufficient buying power to complete order
Related issue: #2709 Related thread: Examples of how to use OptionStrategyPositionGroupBuyingPowerModel?
Potential Solution
Fix the bug in the OptionStrategyPositionGroupBuyingPowerModel. None of the examples in the repo using OptionStrategies maximize the position size. They all use a small order size of <= 10. We need more unit tests to cover the case of attaining the maximum position size.
Reproducing the Problem
Run this backtest.
When placing a single order for the BullPutSpread, with
self.Order(strategy, 54) # Works in interval [1, 54]
the orders go through without error but we have $7,111 of $10K margin remaining. Increasing the order size to 55 throws the error.
Additionally, when placing the orders incrementally with
for i in range(64): # Works in interval [1, 64]
self.Order(strategy, 1)
we can achieve a larger position size but we have $6,480 of $10K margin remaining. Increasing the range
to range(65)
throws the error.
System Information
Checklist
- I have completely filled out this template
- I have confirmed that this issue exists on the current
master
branch - I have confirmed that this is not a duplicate issue by searching issues
- I have provided detailed steps to reproduce the issue
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top GitHub Comments
It would be nice to have something like
so we can maximize the position size.
The underlying bug here was solved, opening new feature request to add missing sugar syntax for option strategies https://github.com/QuantConnect/Lean/issues/7261.