def get_gain(row):
    """Finds the gain of the row

    Parameters
    ----------
    row : pandas row
       Row obtained by merging a transaction with a
       bid dataframe

    Returns
    -------
    gain
        The gain obtained by the row

    """
    gap = row.price_y - row.price_x
    if not row.buying:
        gap = - gap
    return gap * row.quantity