Example #1
0
def get_hash_v2(swap_proto: ir_swap.InterestRateSwap) -> Tuple[int, bool]:
    """Computes hash key for the batching strategy."""
    pay_leg = swap_proto.pay_leg
    receive_leg = swap_proto.receive_leg
    flip_legs, key = _get_legs_hash_key_v2(pay_leg, receive_leg)
    bank_holidays = swap_proto.bank_holidays
    h = utils.hasher(key + [bank_holidays])
    return h, flip_legs
Example #2
0
def _get_hash(
    american_option_proto: american_option_pb2.AmericanEquityOption
) -> Tuple[int, types.CurrencyProtoType]:
    """Computes hash key for the batching strategy."""
    currency = currencies.from_proto_value(american_option_proto.currency)
    bank_holidays = american_option_proto.bank_holidays
    business_day_convention = american_option_proto.business_day_convention
    h = utils.hasher([bank_holidays, business_day_convention])
    return h, currency
Example #3
0
def _get_hash_v2(
    fra_proto: fra.ForwardRateAgreement
) -> Tuple[int, types.CurrencyProtoType, period_pb2.Period,
           rate_indices.RateIndex]:
    """Computes hash key for the batching strategy."""
    currency = currencies.from_proto_value(fra_proto.currency)
    bank_holidays = fra_proto.bank_holidays
    daycount_convention = fra_proto.daycount_convention
    business_day_convention = fra_proto.business_day_convention
    # Get rate index
    rate_index = fra_proto.floating_rate_term.floating_rate_type
    rate_index = rate_indices.RateIndex.from_proto(rate_index)

    rate_term = fra_proto.floating_rate_term.term
    rate_type, multiplier = _frequency_and_multiplier(rate_term.type)
    h = utils.hasher([
        bank_holidays, daycount_convention, business_day_convention, rate_type
    ])
    return h, currency, (rate_type, [multiplier * rate_term.amount
                                     ]), rate_index
Example #4
0
def _get_hash(
    fra_proto: fra.ForwardRateAgreement
) -> Tuple[int, types.CurrencyProtoType, period_pb2.Period,
           rate_indices.RateIndex]:
    """Computes hash key for the batching strategy."""
    currency = currencies.from_proto_value(fra_proto.currency)
    bank_holidays = fra_proto.bank_holidays
    daycount_convention = fra_proto.daycount_convention
    business_day_convention = fra_proto.business_day_convention
    # Get rate index
    rate_index = fra_proto.floating_rate_term.floating_rate_type
    rate_index = rate_indices.RateIndex.from_proto(rate_index)
    rate_index.name = [rate_index.name]
    rate_index.source = [rate_index.source]

    rate_term = fra_proto.floating_rate_term.term
    h = utils.hasher([
        currency.value, bank_holidays, rate_term.type, rate_term.amount,
        rate_index.type.value, daycount_convention, business_day_convention
    ])
    return h, currency, rate_term, rate_index