QuantConnect / QuantConnect/Lean
Reorganize Schedule Event Calls in AlgorithmManager
Open
Nobody has claimed this yet.
consistency
feature
- Dominant language
- C#
- Stars
- 21.7k
- Forks
- 5.3k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 34
Description
Expected Behavior
Scheduled Events are triggered after consolidators/indicators are updated.
Actual Behavior
Scheduled Events are triggered before consolidators/indicators are updated.
Potential Solution
Reorganize the calls.
Reproducing the Problem
namespace QuantConnect.Algorithm.CSharp {
public class SwimmingBlackArmadillo : QCAlgorithm {
private int _day = 0;
public override void Initialize() {
SetStartDate(2021, 5, 1);
AddEquity("SPY");
SMA("SPY", 5).Updated += OnSmaUpdated;
Schedule.On(DateRules.EveryDay("SPY"), TimeRules.AfterMarketOpen("SPY", 1),
() => Log($"AfterMarketOpen on {Time}")
);
}
private void OnSmaUpdated(object sender, IndicatorDataPoint updated) {
if (_day == updated.EndTime.Day) return;
_day = updated.EndTime.Day;
Log($"OnSmaUpdated on {Time}");
}
}
}
Checklist
- I have completely filled out this template
- I have confirmed that this issue exists on the current
masterbranch - I have confirmed that this is not a duplicate issue by searching issues
- I have provided detailed steps to reproduce the issue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in AlgorithmManager at the scheduling and consolidator/indicator update flow, using the C# reproducer in the issue to trace the call order. Verify the change by confirming that the scheduled event logs after OnSmaUpdated for the same market time.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100