def compute_sma(df, column_source, column_target_sma, time_periods):
    """
    Compute Simple Moving Average (SMA).

    :param df: dataframe (sorted in ascending time order)
    :param column_source: name of source column in dataframe with values to compute SMA (e.g. close price)
    :param column_target_sma: prefix of target column in dataframe for SMA results
    :param time_periods: list of time periods (number of days for SMA)
    :return: modified dataframe
    """
    # compute SMA for each time period and add results back to dataframe
    for time_period in time_periods:
        key_sma = column_target_sma + "-{:d}".format(time_period)
        df[key_sma] = df[column_source].rolling(window=time_period, min_periods=1).mean()

    return df