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

Function test_position

python/ccxt/test/exchange/base/test_position.py:17–60  ·  view source on GitHub ↗
(exchange, skipped_properties, method, entry, symbol, now)

Source from the content-addressed store, hash-verified

15from ccxt.test.exchange.base import test_shared_methods # noqa E402
16
17def test_position(exchange, skipped_properties, method, entry, symbol, now):
18 format = {
19 'info': {},
20 'symbol': 'XYZ/USDT',
21 'timestamp': 1504224000000,
22 'datetime': '2017-09-01T00:00:00',
23 'initialMargin': exchange.parse_number('1.234'),
24 'initialMarginPercentage': exchange.parse_number('0.123'),
25 'maintenanceMargin': exchange.parse_number('1.234'),
26 'maintenanceMarginPercentage': exchange.parse_number('0.123'),
27 'entryPrice': exchange.parse_number('1.234'),
28 'notional': exchange.parse_number('1.234'),
29 'leverage': exchange.parse_number('1.234'),
30 'unrealizedPnl': exchange.parse_number('1.234'),
31 'contracts': exchange.parse_number('1'),
32 'contractSize': exchange.parse_number('1.234'),
33 'marginRatio': exchange.parse_number('1.234'),
34 'liquidationPrice': exchange.parse_number('1.234'),
35 'markPrice': exchange.parse_number('1.234'),
36 'collateral': exchange.parse_number('1.234'),
37 'marginMode': 'cross',
38 'side': 'long',
39 'percentage': exchange.parse_number('1.234'),
40 }
41 emptyot_allowed_for = ['liquidationPrice', 'initialMargin', 'initialMarginPercentage', 'maintenanceMargin', 'maintenanceMarginPercentage', 'marginRatio']
42 test_shared_methods.assert_structure(exchange, skipped_properties, method, entry, format, emptyot_allowed_for)
43 test_shared_methods.assert_timestamp_and_datetime(exchange, skipped_properties, method, entry, now)
44 test_shared_methods.assert_symbol(exchange, skipped_properties, method, entry, 'symbol', symbol)
45 test_shared_methods.assert_in_array(exchange, skipped_properties, method, entry, 'side', ['long', 'short'])
46 test_shared_methods.assert_in_array(exchange, skipped_properties, method, entry, 'marginMode', ['cross', 'isolated'])
47 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'leverage', '0')
48 test_shared_methods.assert_less_or_equal(exchange, skipped_properties, method, entry, 'leverage', '200')
49 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'initialMargin', '0')
50 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'initialMarginPercentage', '0')
51 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'maintenanceMargin', '0')
52 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'maintenanceMarginPercentage', '0')
53 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'entryPrice', '0')
54 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'notional', '0')
55 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'contracts', '0')
56 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'contractSize', '0')
57 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'marginRatio', '0')
58 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'liquidationPrice', '0')
59 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'markPrice', '0')
60 test_shared_methods.assert_greater(exchange, skipped_properties, method, entry, 'collateral', '0')

Callers 4

test_fetch_positionsFunction · 0.90
test_fetch_positionsFunction · 0.90
test_watch_positionFunction · 0.90
test_watch_positionsFunction · 0.90

Calls 1

parse_numberMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…