QuantConnect / QuantConnect/Lean

Futures Orders Fill On Extended Market Hours

Open
#8,090 2 comments 0 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

Expected Behavior

Trailing stop orders for futures fill outside market hours.

Actual Behavior

Trailing stop orders do not fill outside market hours.

Potential Solution

Overwrite TrailingStopFill method in FutureFillModel as we did for StopMarketFill.

Reproducing the Problem
from AlgorithmImports import *
class MyAlgorithm(QCAlgorithm):
    def Initialize(self):
        self.set_start_date(2024, 6, 3)
        self.set_end_date(2024, 6, 4)
        self.es = self.add_future("ES", extended_market_hours=True)
        self.ticket = None
    def on_data(self, slice):
        if not self.ticket:
            self.market_order(self.es.mapped, 1)
            self.ticket = self.trailing_stop_order(self.es.mapped, -1, 5, False)
        if self.ticket and self.ticket.status != OrderStatus.FILLED:
            self.plot(self.es.mapped.value, 'Price', self.es.price)
            self.plot(self.es.mapped.value, 'Stop', self.ticket.get(OrderField.STOP_PRICE))

Captura de ecrã 2024-06-13 231653

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 FutureFillModel and compare its StopMarketFill implementation with the base TrailingStopFill behavior. Use the provided futures algorithm to reproduce the trailing-stop issue during extended market hours, then verify that the trailing stop fills as expected and add or update the relevant fill-model tests if present.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, python
Domain
backend, fintech-quant
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.