def compute_change(df, column_source, column_target_change, column_target_change_pc, time_periods):
    """
    Compute the change and percentage change of the values in the source column for the specified period in (trading)
    days.

    :param df: dataframe (sorted in ascending time order)
    :param column_source: name of source column in dataframe with values to compute change (e.g. close price)
    :param column_target_change: name of target column in dataframe for change to add to dataframe
    :param column_target_change_pc: name of target column in dataframe for change pc to add to dataframe
    :param time_periods: list of time periods in (trading) days
    :return: modified dataframe
    """

    # compute change over time period and add result back to dataframe
    for time_period in time_periods:
        key_change = column_target_change + "-{:d}".format(time_period)
        key_change_pc = column_target_change_pc + "-{:d}".format(time_period)
        #df2 = df[column_source].asfreq("D", method="ffill")
        #change_series = df2.diff(time_period)
        #change_pc_series = df2.pct_change(time_period)
        #df[key_change] = change_series
        #df[key_change_pc] = change_pc_series
        change_series = df[column_source].diff(time_period)
        change_pc_series = df[column_source].pct_change(time_period)
        df[key_change] = change_series
        df[key_change_pc] = change_pc_series

    return df