forex/models.py
def conversion_factor(from_symbol, to_symbol, date):
    """
    Generates a multiplying factor used to convert two currencies
    """

    from_currency = Currency.objects.get(symbol=from_symbol)
    try:
        from_currency_price = CurrencyPrice.objects.get(currency=from_currency, date=date).mid_price
    except CurrencyPrice.DoesNotExist:
        print "Cannot fetch prices for %s on %s" % (str(from_currency), str(date))
        return None

    to_currency = Currency.objects.get(symbol=to_symbol)
    try:
        to_currency_price = CurrencyPrice.objects.get(currency=to_currency, date=date).mid_price
    except CurrencyPrice.DoesNotExist:
        print "Cannot fetch prices for %s on %s" % (str(to_currency), str(date))
        return None

    return to_currency_price / from_currency_price
def conversion_factor(from_symbol, to_symbol, date):
    """
    Generates a multiplying factor used to convert two currencies
    """

    from_currency = Currency.objects.get(symbol=from_symbol)
    try:
        from_currency_price = CurrencyPrice.objects.get(currency=from_currency, date=date).mid_price
    except CurrencyPrice.DoesNotExist:
        print "Cannot fetch prices for %s on %s" % (str(from_currency), str(date))
        return None

    to_currency = Currency.objects.get(symbol=to_symbol)
    try:
        to_currency_price = CurrencyPrice.objects.get(currency=to_currency, date=date).mid_price
    except CurrencyPrice.DoesNotExist:
        print "Cannot fetch prices for %s on %s" % (str(to_currency), str(date))
        return None

    return to_currency_price / from_currency_price
Generates a multiplying factor used to convert two currencies