@@ -54,7 +54,7 @@ def __init__(self):
5454
5555 try :
5656 props = config ['config' ]
57- self .bot_version = '1.4.5 '
57+ self .bot_version = '1.4.6 '
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 ('"' )
@@ -860,7 +860,7 @@ def get_margin_balance_of_fiat():
860860 try :
861861 if CONF .exchange == 'bitmex' :
862862 pos = get_position_info ()
863- if not pos or not pos ['markPrice' ]:
863+ if not pos or not 'markPrice' in pos or not pos ['markPrice' ]:
864864 return {'total' : 0 }
865865 return {'total' : float (pos ['homeNotional' ]) * float (pos ['markPrice' ])}
866866 LOG .warning (NOT_IMPLEMENTED_MESSAGE , 'get_margin_balance_of_fiat()' , CONF .exchange )
@@ -1694,10 +1694,11 @@ def calculate_balances():
16941694 pos = get_position_info ()
16951695 # aka margin balance
16961696 balance ['totalBalanceInCrypto' ] = get_crypto_balance ()['total' ]
1697- balance ['price' ] = float (pos ['markPrice' ])
1697+ if 'markPrice' in pos :
1698+ balance ['price' ] = float (pos ['markPrice' ])
16981699 if not balance ['price' ]:
16991700 balance ['price' ] = get_current_price ()
1700- if pos ['avgEntryPrice' ]:
1701+ if pos ['avgEntryPrice' ] and float ( pos [ 'avgEntryPrice' ]) > 0 :
17011702 balance ['cryptoBalance' ] = (abs (int (pos ['foreignNotional' ])) / float (pos ['avgEntryPrice' ]) * balance ['price' ]) / float (pos ['avgEntryPrice' ])
17021703 return balance
17031704 balance ['cryptoBalance' ] = get_crypto_balance ()['total' ]
0 commit comments