def _compute_missing_rates(self, currency):
rates = self._rates[currency]<EOL>tmp = defaultdict(lambda: [None, None])<EOL>for date in sorted(rates):<EOL><INDENT>rate = rates[date]<EOL>if rate is not None:<EOL><INDENT>closest_rate = rate<EOL>dist = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>dist += <NUM_LIT:1><EOL>tmp[date][<NUM_LIT:0>] = closest_rate, dist<EOL><DEDENT><DEDENT>for date in sorted(rates, reverse=True):<EOL><INDENT>rate = rates[date]<EOL>if rate is not None:<EOL><INDENT>closest_rate = rate<EOL>dist = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>dist += <NUM_LIT:1><EOL>tmp[date][<NUM_LIT:1>] = closest_rate, dist<EOL><DEDENT><DEDENT>for date in sorted(tmp):<EOL><INDENT>(r0, d0), (r1, d1) = tmp[date]<EOL>rates[date] = (r0 * d1 + r1 * d0) / (d0 + d1)<EOL>if self.verbose:<EOL><INDENT>print(('<STR_LIT>'<EOL>'<STR_LIT>').format(currency, date, r0, d0, r1, d1))<EOL><DEDENT><DEDENT>
Fill missing rates of a currency.

        This is done by linear interpolation of the two closest available rates.

        :param str currency: The currency to fill missing rates for.