QuantConnect / QuantConnect/Lean

Buying power validation for combo orders updates

Open
#8,567 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Expected Behavior

Buying power validation is done for combo orders, so that updates are rejected if margin is not enough for the requested new order settings.

Actual Behavior

Buying power validation is done only for individual orders and skipped for combo orders.
See https://github.com/QuantConnect/Lean/pull/8553.

Potential Solution

OrderTicket.Update might have an overload to take a collection of updates for each leg of a combo, and updates request can be queued in a batch together. That way the brokerage transaction handler can validate the buying power for the whole combo.

Reproducing the Problem

See https://github.com/QuantConnect/Lean/pull/8553 and comment out if (order.GroupOrderManager == null) in BrokerageTransactionHandler.HandleUpdateOrderRequest() to allow updates to combo orders legs. The regression algorithms that update combo orders start failing.

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 BrokerageTransactionHandler.HandleUpdateOrderRequest() and review the related changes in pull request 8553. Reproduce the issue using the regression algorithms that update combo orders, then trace OrderTicket.Update and combo-leg handling. Done means combo-order updates are rejected when the requested settings exceed available buying power, while valid updates continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
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.