Hi all;

If the below is wrong, please correct. But I think this explains what is not clear, to me at least, in the documentation about all this.

When you want to start your algo, you almost always have indicators and/or other data, usually in RollingWindows that need to have the last N days of data in them. As an example, say you want the 50 day ExponentialMovingAverage (EMA). Then when your algo starts, you need the last 50 days of close price in the EMA.

So how is this initialized with the last 50 days of data? There could be separate initialization code but that would require additional programming, additional testing, and additional bugs (as you get a bug per X lines of code). So instead it goes back N days and runs using the data from those days to “warm up” (i.e. initialize) the data.

Hence the purpose of the IsWarmingUp property. When true, you should do everything in your methods except place orders. The primary purpose is to update indicators and add to rolling windows. But if you have other data that is changed as the day(s) progress, you need to do that too.

How many days is this done for? That is where SetWarmingUp() comes in. You set how many calendar days you need to warm up for. As indicators and pretty much everything else works off days the markets are open, you need to set the number of days to: calendar 

numCalendarDays = (numMarketDays * 7 / 5) * 1.1 + 2

The “* 1.1 + 2” is to cover holidays. It's fine if you need 50 days and the warmup runs for 52 days.

Three important notes about warmup:

  1. If you set a warm up period of 50 days and you have a 200 day indicator - you'll get no error from any of this and it will then start processing orders for real.
  2. IsWarmingUp will be true until warmup is complete, then will be false thereafter. It will never revert back to true.
  3. Time events do not fire during the warmup period. Only data based events fire.

 

Next there's IsReady which is a property for RollingWindows, indicators, and maybe some other stuff. This is letting you know if you have fully populated a collection. If you have a 200 day EMA and you set the warmup period to 50 days, then the indicator.IsReady will be false until you have had 150 days of live trading.

Fundamentally, if you set the warm up period correctly, then once the warm up is complete, every collection.IsReady should be true.

In addition, IsReady does not tell you if you've updated your collection at the end of the day. It merely tells you it's been fully initialized. So this is not a measure of today's numbers have been added.

And like IsWarmingUp, once IsReady is true, it will never revert to false.

All the examples show the code testing IsReady every time it uses a collection. I think this is a bad way to approach this issue. I recommend that in the event OnWarmupFinished(self), walk all collections and if any has IsReady == false, throw an exception and exit the app - because you have a run time error.

And if all are true, then they never need to be tested while running as they cannot revert to false.