Skip to content

Commit 54093fd

Browse files
committed
Gracefully handle missing fields for the trade balance summary
1 parent cec46ae commit 54093fd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/clikraken/api/private/get_trade_balance.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ def get_trade_balance(args=None):
2222
res = query_api('private', 'TradeBalance', api_params, args)
2323

2424
tbal_list = [
25-
['equivalent balance', res['eb']],
26-
['trade balance', res['tb']],
27-
['margin amount of open positions', res['m']],
28-
['cost basis of open positions', res['c']],
29-
['current floating valuation of open positions', res['v']],
30-
['equity', res['e']],
31-
['free margin', res['mf']],
32-
['margin level', res['ml']],
33-
['unrealized net profit/loss of open positions', res['n']],
25+
['equivalent balance', res.get('eb', 'n/a')],
26+
['trade balance', res.get('tb', 'n/a')],
27+
['margin amount of open positions', res.get('m', 'n/a')],
28+
['cost basis of open positions', res.get('c', 'n/a')],
29+
['current floating valuation of open positions', res.get('v', 'n/a')],
30+
['equity', res.get('e', 'n/a')],
31+
['free margin', res.get('mf', 'n/a')],
32+
['margin level', res.get('ml', 'n/a')],
33+
['unrealized net profit/loss of open positions', res.get('n', 'n/a')],
3434
]
3535
print(tabulate(tbal_list))

0 commit comments

Comments
 (0)