Skip to content

Commit e4e8efb

Browse files
committed
Fix multi position handling bitmex
1 parent 0b45fa1 commit e4e8efb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

balancer.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self):
5454

5555
try:
5656
props = config['config']
57-
self.bot_version = '1.4.6'
57+
self.bot_version = '1.4.7'
5858
self.exchange = str(props['exchange']).strip('"').lower()
5959
self.api_key = str(props['api_key']).strip('"')
6060
self.api_secret = str(props['api_secret']).strip('"')
@@ -1483,9 +1483,11 @@ def get_used_balance():
14831483
try:
14841484
if CONF.exchange == 'bitmex':
14851485
position = EXCHANGE.private_get_position()
1486-
if not position:
1487-
return None
1488-
return float(position[0]['currentQty'])
1486+
if position:
1487+
for po in position:
1488+
if po['symbol'] == CONF.symbol:
1489+
return float(po['currentQty'])
1490+
return None
14891491
if CONF.exchange == 'kraken':
14901492
result = EXCHANGE.private_post_tradebalance()['result']
14911493
return float(result['e']) - float(result['mf'])
@@ -1541,7 +1543,9 @@ def get_position_info():
15411543
if CONF.exchange == 'bitmex':
15421544
position = EXCHANGE.private_get_position()
15431545
if position:
1544-
return position[0]
1546+
for po in position:
1547+
if po['symbol'] == CONF.symbol:
1548+
return po
15451549
return None
15461550
LOG.warning(NOT_IMPLEMENTED_MESSAGE, 'get_postion_info()', CONF.exchange)
15471551
return None

0 commit comments

Comments
 (0)