QuantConnect / QuantConnect/Lean

ImmediateExecutionModel.py feature enhancement request

Open
#9,231 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Expected Behavior

In live cash account, when rebalance the holdings (portfolio with 100% holding + 0% cash) including sell order and buy order. The order should be first execute the sell order and then buy order.

if execute not in that order, the broker will report not enough cash error

Actual Behavior

The order execution does not do sell order first, then buy order.

Potential Solution

Execute sell order first, upon completion, execute buy order

Checklist
  • [Y] I have completely filled out this template
  • [Y] I have confirmed that this issue exists on the current master branch
  • [Y] I have confirmed that this is not a duplicate issue by searching issues

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 ImmediateExecutionModel.py and trace how rebalance orders are submitted and completed. Reproduce a live cash-account rebalance containing both sells and buys, then verify that all sell orders complete before buy orders are submitted and that the insufficient-cash broker error no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
fintech-quant
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.