I looked lots of posts and the documentation and it seems that what I am trying to do should work, but I am stuck for the past few days :(

All I'm trying to do is to get a list of high volatility stocks based on their earnings date.

I keep running in circles about this error:

Runtime Error: Trying to perform a summation, subtraction, multiplication or division between 'EarningReportsFileDate' and 'datetime.timedelta' objects throws a TypeError exception. To prevent the exception, ensure that both values share the same type.
  at fine_selection_function
    earnings_release_date = f.EarningReports.file_date + timedelta(days=7)

import numpy as np
from AlgorithmImports import *

class EarningsVolatilityAlgorithm(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2020, 1, 1)  # Define start date
        self.SetCash(100000)  # Set initial cash
        self.universe_settings.Resolution = Resolution.Daily
        self.AddUniverseSelection(QC500UniverseSelectionModel())
        self.AddUniverse(self.fine_selection_function)

    def fine_selection_function(self, fine):
        today = self.Time.date()
        filtered_by_earnings = []

        for f in fine:
            if f.EarningReports and f.EarningReports.file_date:
                earnings_release_date = f.EarningReports.file_date + timedelta(days=7)
                if today > earnings_release_date:
                    filtered_by_earnings.append(f)

        high_vol_candidates = []
        days_before_earnings = 5
        days_after_earnings = 5
        volatility_threshold = 0.03

        for stock in filtered_by_earnings:
            symbol = stock.Symbol
            earnings_date = stock.EarningReports.file_date
            window_start = earnings_date - timedelta(days=days_before_earnings)
            window_end = earnings_date + timedelta(days=days_after_earnings)
            historical_data = self.History(symbol, days_before_earnings + days_after_earnings + 1, Resolution.Daily)
            if not historical_data.empty:
                historical_volatility = np.std(historical_data['close'].pct_change().dropna())
                if historical_volatility > volatility_threshold:
                    avg_volume = historical_data['volume'].mean()
                    if avg_volume >= 200000:
                        high_vol_candidates.append(symbol)

        return high_vol_candidates