Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize Schedule Event Calls in AlgorithmManager #5595

Open
4 tasks done
AlexCatarino opened this issue May 24, 2021 · 0 comments
Open
4 tasks done

Reorganize Schedule Event Calls in AlgorithmManager #5595

AlexCatarino opened this issue May 24, 2021 · 0 comments

Comments

@AlexCatarino
Copy link
Member

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 master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants