MCPcopy Create free account
hub / github.com/ccxt/ccxt / safe_integer

Method safe_integer

python/ccxt/base/exchange.py:795–802  ·  view source on GitHub ↗
(dictionary, key, default_value=None)

Source from the content-addressed store, hash-verified

793
794 @staticmethod
795 def safe_integer(dictionary, key, default_value=None):
796 try:
797 # needed to avoid breaking on "100.0"
798 # https://stackoverflow.com/questions/1094717/convert-a-string-to-integer-with-decimal-in-python#1094721
799 return int(float(dictionary[key]))
800 except Exception:
801 # catch any exception, not only (KeyError, IndexError, TypeError, ValueError):
802 return default_value
803
804 @staticmethod
805 def safe_integer_product(dictionary, key, factor, default_value=None):

Callers 15

test_safe_methodsFunction · 0.95
safe_ledger_entryMethod · 0.95
set_marketsMethod · 0.95
safe_orderMethod · 0.95
parse_ohlcvMethod · 0.95
handle_param_integerMethod · 0.95
currency_to_precisionMethod · 0.95

Calls

no outgoing calls

Tested by 3

test_safe_methodsFunction · 0.76
test_fetch_currenciesFunction · 0.64
test_fetch_currenciesFunction · 0.64