def swap_to_dcf(swap_rates):
    """
    Helper function transforms sorted swap rates to discount factors.

    :param swap_rates: par swap rates
    :return: discount factors
    """
    num_rates = len(swap_rates)
    dcf = num_rates * [0]
    for index, rate in enumerate(swap_rates):
        if index == 0:
            dcf[index] = 1. / (1. + rate)
        else:
            dcf[index] = (1 - (rate * sum(dcf[0:index + 1]))) / (1. + rate)
    return dcf