@@ -59,8 +59,11 @@ def _convert_return_fields(self, fields, decimal_fields, convert_all):
59
59
elif isinstance (fields , dict ):
60
60
new_fields = {}
61
61
for k , v in fields .items ():
62
- if (decimal_fields is not None and k in decimal_fields ) \
63
- or convert_all :
62
+ if isinstance (v , dict ):
63
+ new_fields [k ] = self ._convert_return_fields (
64
+ v , decimal_fields , convert_all )
65
+ elif ((decimal_fields is not None and k in decimal_fields )
66
+ or convert_all ):
64
67
if isinstance (v , list ):
65
68
new_fields [k ] = self ._convert_return_fields (
66
69
v , decimal_fields , convert_all )
@@ -193,7 +196,6 @@ async def get_currencies(self):
193
196
async def get_time (self ):
194
197
return await self ._get ('/time' )
195
198
196
- # TODO: convert return values
197
199
# authenticated API
198
200
async def get_account (self , account_id = '' ):
199
201
assert self .authenticated
@@ -320,7 +322,13 @@ async def margin_transfer(self, margin_profile_id, transfer_type,
320
322
321
323
async def get_position (self ):
322
324
assert self .authenticated
323
- return await self ._get ('/position' )
325
+ return await self ._get (
326
+ '/position' ,
327
+ decimal_return_fields = {'max_funding_value' , 'funding_value' ,
328
+ 'amount' , 'balance' , 'hold' ,
329
+ 'funded_amount' , 'default_amount' , 'price' ,
330
+ 'sell' , 'size' , 'funds' , 'complement' ,
331
+ 'max_size' })
324
332
325
333
async def close_position (self , repay_only = False ):
326
334
assert self .authenticated
@@ -336,7 +344,8 @@ async def deposit(self, amount, currency, payment_method_id):
336
344
"currency" : currency ,
337
345
"payment_method_id" : payment_method_id ,
338
346
}
339
- return await self ._post ('/deposits/payment-method' , data = payload )
347
+ return await self ._post ('/deposits/payment-method' , data = payload ,
348
+ decimal_return_fields = {'amount' })
340
349
341
350
async def coinbase_deposit (self , amount , currency , coinbase_account_id ):
342
351
assert self .authenticated
@@ -345,7 +354,8 @@ async def coinbase_deposit(self, amount, currency, coinbase_account_id):
345
354
"currency" : currency ,
346
355
"coinbase_account_id" : coinbase_account_id ,
347
356
}
348
- return await self ._post ('/deposits/coinbase-account' , data = payload )
357
+ return await self ._post ('/deposits/coinbase-account' , data = payload ,
358
+ decimal_return_fields = {'amount' })
349
359
350
360
async def withdraw (self , amount , currency , payment_method_id ):
351
361
assert self .authenticated
@@ -354,7 +364,8 @@ async def withdraw(self, amount, currency, payment_method_id):
354
364
"currency" : currency ,
355
365
"payment_method_id" : payment_method_id ,
356
366
}
357
- return await self ._post ('/withdrawals/payment-method' , data = payload )
367
+ return await self ._post ('/withdrawals/payment-method' , data = payload ,
368
+ decimal_return_fields = {'amount' })
358
369
359
370
async def coinbase_withdraw (self , amount , currency , coinbase_account_id ):
360
371
assert self .authenticated
@@ -363,7 +374,8 @@ async def coinbase_withdraw(self, amount, currency, coinbase_account_id):
363
374
"currency" : currency ,
364
375
"coinbase_account_id" : coinbase_account_id ,
365
376
}
366
- return await self ._post ('/withdrawals/coinbase' , data = payload )
377
+ return await self ._post ('/withdrawals/coinbase' , data = payload ,
378
+ decimal_return_fields = {'amount' })
367
379
368
380
async def crypto_withdraw (self , amount , currency , crypto_address ):
369
381
assert self .authenticated
@@ -372,15 +384,17 @@ async def crypto_withdraw(self, amount, currency, crypto_address):
372
384
"currency" : currency ,
373
385
"crypto_address" : crypto_address
374
386
}
375
- return await self ._post ('/withdrawals/crypto' , data = payload )
387
+ return await self ._post ('/withdrawals/crypto' , data = payload ,
388
+ decimal_return_fields = {'amount' })
376
389
377
390
async def get_payment_methods (self ):
378
391
assert self .authenticated
379
392
return await self ._get ('/payment-methods' )
380
393
381
394
async def get_coinbase_accounts (self ):
382
395
assert self .authenticated
383
- return await self ._get ('/coinbase-accounts' )
396
+ return await self ._get ('/coinbase-accounts' ,
397
+ decimal_return_fields = {'balance' })
384
398
385
399
async def create_report (self , report_type , start_date , end_date ,
386
400
product_id = None , account_id = None ,
@@ -417,7 +431,9 @@ async def get_report(self, report_id):
417
431
418
432
async def get_trailing_volume (self ):
419
433
assert self .authenticated
420
- return await self ._get ("/users/self/trailing-volume" )
434
+ return await self ._get ('/users/self/trailing-volume' ,
435
+ decimal_return_fields = {'exchange_volume' ,
436
+ 'volume' })
421
437
422
438
423
439
async def main (): # pragma: no cover
0 commit comments