def __init__(self,holding):
   if not holding.has_key('quote'):
     raise HoldingError("Quote missing")
   self.name = holding['quote']
   quote = get_quote(self.name)
   self.last_price = quote.price
   self.currency = quote.currency
   self.day_gain = quote.gain
   self.lots = None
   self.gain = 0
   self.value = 0
   if holding.has_key('lots'):
     self.lots = holding['lots']
     for lot in self.lots:
       if not (lot.has_key("Amount") and lot.has_key("Value")):
         raise HoldingError("Missing attribute in lots")
       self.gain += float(lot["Amount"]) * (self.last_price - float(lot["Value"])) 
       self.value += float(lot["Amount"]) * self.last_price
def to_curr(amount, old, new):
    if old == new:
        return amount
    quote = get_quote(old + new + ":CUR")
    return quote.price * float(amount)