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

Function assert_fee_structure

python/ccxt/test/exchange/base/test_shared_methods.py:286–305  ·  view source on GitHub ↗
(exchange, skipped_properties, method, entry, key, allow_null=True)

Source from the content-addressed store, hash-verified

284
285
286def assert_fee_structure(exchange, skipped_properties, method, entry, key, allow_null=True):
287 log_text = log_template(exchange, method, entry)
288 key_string = string_value(key)
289 if isinstance(key, int):
290 assert isinstance(entry, list), 'fee container is expected to be an array' + log_text
291 assert key < len(entry), 'fee key ' + key_string + ' was expected to be present in entry' + log_text
292 else:
293 assert exchange.is_dictionary(entry), 'fee container is expected to be a dict' + log_text
294 assert key in entry, 'fee key "' + key + '" was expected to be present in entry' + log_text
295 fee_object = exchange.safe_value(entry, key)
296 assert fee_object is not None or allow_null, 'fee object is null' + log_text
297 # todo: remove undefined check to make stricter
298 if fee_object is not None:
299 assert 'cost' in fee_object, key_string + ' fee object should contain "cost" key' + log_text
300 if fee_object['cost'] is None:
301 return # todo: remove undefined check to make stricter
302 assert isinstance(fee_object['cost'], numbers.Real), key_string + ' "cost" must be numeric type' + log_text
303 # assertGreaterOrEqual (exchange, skippedProperties, method, feeObject, 'cost', '0'); # fee might be negative in the case of a rebate or reward
304 assert 'currency' in fee_object, '"' + key_string + '" fee object should contain "currency" key' + log_text
305 assert_currency_code(exchange, skipped_properties, method, entry, fee_object['currency'])
306
307
308def assert_timestamp_order(exchange, method, code_or_symbol, items, ascending=True):

Callers

nothing calls this directly

Calls 5

log_templateFunction · 0.85
string_valueFunction · 0.85
assert_currency_codeFunction · 0.85
is_dictionaryMethod · 0.80
safe_valueMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…