Despite added the filter criteria for specific security to exclude, I keep getting same error during the back testing. Where this is being called from. I filtered out the security from on_data and CoarseSelectionFunction

  1. Backtest Handled Error: No data loaded for ABFS R735QTJ8XC9X because there were no tradeable dates for this security.

 

  1. def OnData(self, data):
  2. if self.IsWarmingUp or not self.warmUpCompleted:
  3. return
  4. if not data:
  5. self.log("No data available for this slice")
  6. return
  7. try:
  8. if data.ContainsKey("ABFS"):
  9. return
  10. except Exception as e:
  11. self.logger.log(f"Error processing data for ABFS: {str(e)}")

 

  1. def CoarseSelectionFunction(self, coarse):
  2. trading_date = self.algorithm.Time.strftime('%Y-%m-%d') # Get the trading day in 'YYYY-MM-DD' format
  3. # Track memory usage before selection
  4. process = psutil.Process()
  5. memory_before = process.memory_info().rss / (1024 * 1024) # Convert to MB
  6. selected: List[str] = []
  7. for stock in coarse:
  8. if stock.Symbol.Value != 'ABFS' and stock.HasFundamentalData and stock.Price > params.PRICE_THRESHOLD and stock.DollarVolume > params.DOLLAR_VOLUME_THRESHOLD:
  9. selected.append(stock.Symbol)

Author

Dharmesh Khalasi

September 2024