def safe_currency_code(self, data, key, currency=None):
    code = None
    currency_id = self.safe_string(data, key)
    if (currency_id in self.currencies_by_id):
        currency = self.currencies_by_id[currency_id]
    else:
        code = self.common_currency_code(currency_id)
    if (currency is not None):
        code = currency['code']
    return code
def safe_currency_code(self, data, key, currency=None):
    code = None
    currency_id = self.safe_string(data, key)
    if (currency_id in self.currencies_by_id):
        currency = self.currencies_by_id[currency_id]
    else:
        code = self.common_currency_code(currency_id)
    if (currency is not None):
        code = currency['code']
    return code