forex/models.py
def convert_currency(from_symbol, to_symbol, value, date):
    """
    Converts an amount of money from one currency to another on a specified date.
    """
    if from_symbol == to_symbol:
        return value

    factor = conversion_factor(from_symbol, to_symbol, date)

    if type(value) == float:
        output = value * float(factor)
    elif type(value) == Decimal:
        output = Decimal(format(value * factor, '.%sf' % str(PRICE_PRECISION)))
    elif type(value) in [np.float16, np.float32, np.float64, np.float128, np.float]:
        output = float(value) * float(factor)
    else:
        output = None

    return output
def convert_currency(from_symbol, to_symbol, value, date):
    """
    Converts an amount of money from one currency to another on a specified date.
    """
    if from_symbol == to_symbol:
        return value

    factor = conversion_factor(from_symbol, to_symbol, date)

    if type(value) == float:
        output = value * float(factor)
    elif type(value) == Decimal:
        output = Decimal(format(value * factor, '.%sf' % str(PRICE_PRECISION)))
    elif type(value) in [np.float16, np.float32, np.float64, np.float128, np.float]:
        output = float(value) * float(factor)
    else:
        output = None

    return output
Converts an amount of money from one currency to another on a specified date.