QuantConnect / QuantConnect/Lean

Liquidate options strategies in batch

Open
#7,223 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

depth feature
Dominant language
C#
Stars
21.7k
Forks
5.3k
Avg merge
2d 22h
Merged PRs (30d)
34

Description

Originally posted by @jhonabreul in https://github.com/QuantConnect/Lean/issues/7221#issuecomment-1526022776

Expected Behavior

The Liquidate API takes care of multi-asset position groups (like option strategies) by liquidating them in batch (with a group order) to avoid the insufficient margin issue.

Actual Behavior

The Liquidate API liquidates multi-asset position groups using individual market orders, causing potential insiffucient buying power issues that won't allow the assets liquidation (see #7221)

Potential Solution

The Liquidate API could use combo orders to liquidate option strategies position groups in batch.

Reproducing the Problem

Run the ComboLimitOrderAlgorithm but reduce the initial cash to something like 10000. It places a butterfly call order which margin requirement is zero (0), but after Liquidate() is called, the portfolio will still have invested securities because some of the market orders fail with insufficient buying power.

System Information

Windows 11

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Liquidate API and run ComboLimitOrderAlgorithm with initial cash around 10000, using the behavior described in #7221 as context. Trace how multi-asset option position groups are handled; the issue is done when liquidation completes without leaving invested securities or triggering insufficient-buying-power failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
fintech-quant
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.