def compute_ma_cross(
        df, column_source, column_target_golden_cross, column_target_death_cross,
        time_period_fast, time_period_slow):
    """
    Compute Moving Average (Golden/Death) Crosses.

    :param df: dataframe (sorted in ascending time order)
    :param column_source: prefix of source column in dataframe with moving average values
    :param column_target_golden_cross: name of target column in dataframe for golden cross results
    :param column_target_death_cross: name of target column in dataframe for death cross results
    :param time_period_fast: number of days over which to average for fast MA
    :param time_period_slow: number of days over which to average for slow MA
    :return: modified dataframe
    """
    # get moving average values
    key_ma_fast = column_source + "-{:d}".format(time_period_fast)
    key_ma_slow = column_source + "-{:d}".format(time_period_slow)
    fast_series = df[key_ma_fast]
    slow_series = df[key_ma_slow]

    # compute golden cross / death cross and add results back to dataframe
    previous_fast_series = df[key_ma_fast].shift(1)
    previous_slow_series = df[key_ma_slow].shift(1)
    key_golden_cross = column_target_golden_cross + "-{:d}-{:d}".format(time_period_fast, time_period_slow)
    key_death_cross = column_target_death_cross + "-{:d}-{:d}".format(time_period_fast, time_period_slow)
    df[key_golden_cross] = (fast_series >= slow_series) & (previous_fast_series <= previous_slow_series)
    df[key_death_cross] = (fast_series <= slow_series) & (previous_fast_series >= previous_slow_series)

    return df