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

Function tco_assert_filled_order

python/ccxt/test/exchange/sync/test_create_order.py:143–161  ·  view source on GitHub ↗
(exchange, market, log_prefix, skipped_properties, created_order, fetched_order, requested_side, requested_amount)

Source from the content-addressed store, hash-verified

141
142
143def tco_assert_filled_order(exchange, market, log_prefix, skipped_properties, created_order, fetched_order, requested_side, requested_amount):
144 # test filled amount
145 precision_amount = exchange.safe_string(market['precision'], 'amount')
146 entryorder_amount_string = exchange.number_to_string(requested_amount)
147 filled_string = exchange.safe_string(fetched_order, 'filled')
148 assert filled_string is not None, log_prefix + ' order should be filled, but it is not. ' + exchange.json(fetched_order)
149 # filled amount should be whithin the expected range i.e. if you buy 100 DOGECOIN and amount-precision is 1,
150 # and also considering possible roundings in implementation, then filled amount should be between 99 and 101
151 max_expected_filled_amount = Precise.string_add(entryorder_amount_string, precision_amount)
152 min_expected_filled_amount = Precise.string_sub(entryorder_amount_string, precision_amount)
153 assert Precise.string_le(filled_string, max_expected_filled_amount), log_prefix + ' filled amount is more than expected, possibly some implementation issue. ' + exchange.json(fetched_order)
154 assert Precise.string_ge(filled_string, min_expected_filled_amount), log_prefix + ' filled amount is less than expected, possibly some implementation issue. ' + exchange.json(fetched_order)
155 # order state should be "closed"
156 test_shared_methods.assert_order_state(exchange, skipped_properties, 'createdOrder', created_order, 'closed', False)
157 test_shared_methods.assert_order_state(exchange, skipped_properties, 'fetchedOrder', fetched_order, 'closed', True)
158 # ensure that order side matches
159 test_shared_methods.assert_in_array(exchange, skipped_properties, 'createdOrder', created_order, 'side', [None, requested_side])
160 test_shared_methods.assert_in_array(exchange, skipped_properties, 'fetchedOrder', fetched_order, 'side', [None, requested_side])
161 return True
162
163
164# ----------------------------------------------------------------------------

Callers 1

Calls 6

safe_stringMethod · 0.80
string_addMethod · 0.80
string_subMethod · 0.80
string_leMethod · 0.80
string_geMethod · 0.80
jsonMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…