def _get_rate(self, currency, date):
if currency == self.ref_currency:<EOL><INDENT>return <NUM_LIT:1.0><EOL><DEDENT>if date not in self._rates[currency]:<EOL><INDENT>first_date, last_date = self.bounds[currency]<EOL>if not self.fallback_on_wrong_date:<EOL><INDENT>raise RateNotFoundError('<STR_LIT>'.format(<EOL>date, currency, first_date, last_date))<EOL><DEDENT>if date < first_date:<EOL><INDENT>fallback_date = first_date<EOL><DEDENT>elif date > last_date:<EOL><INDENT>fallback_date = last_date<EOL><DEDENT>else:<EOL><INDENT>raise AssertionError('<STR_LIT>')<EOL><DEDENT>if self.verbose:<EOL><INDENT>print(r'<STR_LIT>'.format(<EOL>date, currency, first_date, last_date, fallback_date))<EOL><DEDENT>date = fallback_date<EOL><DEDENT>rate = self._rates[currency][date]<EOL>if rate is None:<EOL><INDENT>raise RateNotFoundError('<STR_LIT>'.format(currency, date))<EOL><DEDENT>return rate<EOL>
Get a rate for a given currency and date.

        :type date: datetime.date

        >>> from datetime import date
        >>> c = CurrencyConverter()
        >>> c._get_rate('USD', date=date(2014, 3, 28))
        1.375...
        >>> c._get_rate('BGN', date=date(2010, 11, 21))
        Traceback (most recent call last):
        RateNotFoundError: BGN has no rate for 2010-11-21