Skip to content

Manually Warming Up the Forex Session #9353

@DerekMelchin

Description

@DerekMelchin

Expected Behavior

The following algorithm populates the Forex Session with all of the daily bars in the history request.

class DancingApricotBarracuda(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2024, 9, 25)
        self.set_cash(100_000)
        forex = self.add_forex("EURUSD")
        lookback = 152
        forex.session.size = lookback
        bars = self.history[QuoteBar](forex, lookback, Resolution.DAILY)
        for bar in bars:
            forex.session.update(bar)
        self.quit(f'bars: {len(list(bars))}; session.samples: {forex.session.samples}')

Actual Behavior

Quit(): bars: 152; session.samples: 77

However, if we use set_warm_up instead, it populates correctly.

class DancingApricotBarracuda(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2024, 9, 25)
        self.set_cash(100_000)
        self._forex = self.add_forex("EURUSD")
        lookback = 152
        self._forex.session.size = lookback
        self.set_warm_up(lookback, Resolution.DAILY)
    
    def on_warmup_finished(self):
        self.quit(f'session.samples: {self._forex.session.samples}')

Quit(): session.samples: 154

Potential Solution

N/A

Reproducing the Problem

Run the algorithm above.

System Information

QC Cloud

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions