Hi

I'm trying to use a RollingWindow to look back on previous day's volatilities, so I have the following:

  1. #...
  2. for tickers in self.tickers:
  3. self.volWindows[symbol] = RollingWindow[IndicatorDataPoint](5)
  4. self.volatilities[symbol].Updated += (lambda sender, updated: self.OnVolUpdated(sender, symbol, updated))
  5. #...
  6. def OnVolUpdated(self, sender, symbol, updated):
  7. if self.volatilities[symbol].IsReady:
  8. self.volWindows[symbol].Add(updated)

To trigger a signal, I have the following:

  1. if self.volWindows[symbol][1].Value > x:
  2. # ...

I've noticed that I'd frequently encountered the error: Runtime Error: Rolling window is empty (Parameter 'i') in RollingWindow.

I read that the readiness of self.volW∈dows[symbol] should be checked. But if I have

  1. if self.volWindows[symbol].IsReady and self.volWindows[symbol][1].Value > x:
  2. # ...

Quite a few signals are omitted/skipped. Does anyone know how this could be rectified?

Thanks

Author

John Munro

April 2023