Schedualing Events On First Trading Day Of The Week


I have been porting my algos across from Quantopian. The schedule functions used at quantopian allow you to action a function on the first or subsequent trading day of the week. Quantconnect only seems to allow for a function to be scheduled on a specific day (e.g. Tuesday).

Q1. If a function is schedualed on a monday but monday is a holiday, will the function be actioned on the next trading day?

Q2. What is the easiest way to scheduale a function to be actioned on a specific trading day in the week (e.g. the first trading day or the second)?

I am coding in python. I believe the TradingCalander may be useful; however I am not familiar with how it works. I appreciate any help!

Update Backtest

I am only a c# developer but i would take a look at the info provided by tradingcalender.

like GetTradingDays(DateTime start, DateTime end)

TradingDayType: BusinessDay | PublicHoliday


Thank you - I will try to think of a way to utilise the feature


1 )when you go in the "Algorithm Lab" on the left there is the "API" - tab

2) expand QCAlgorithm then expand TradingCalendar

3) click on the return value to see the propierties





Jared Broad

DONT CLICK ON "Quantconnect.Tradingday" link because you will not see the properites!!

BECAUSE ITS THE "SYMBOL"  !!! CLASS hehe :) thats the wrong class



GetDaysBuyType also shows symbol class information :)

if you click on the first two decriptions links


Recently DateRules for WeekStart WeekEnd and MonthStart MonthEnd were added to Lean, Not in the docs yet but they exist around the codebase:

Perfect - thank you both for your help. Do you know if the new DateRules allow to offset days?


Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed