Closed SoftTouchxxXL closed 2 years ago
For anybody who, like me is just starting out and stuck with a problem like this...here's how you solve this problem
{'account_id': '619', 'asset': 'ZAR', 'balance': '6.19', 'reserved': '6.19', 'unconfirmed': '6.19'}
is a list within a dict, you should get the first item on the list and then use the key from the inside the dict like this.
BalR['balance'][0]['balance']
Hello again, everybody. Three quick questions
BalR= c.get_balances(assets=['ZAR'])
BalR=BalR['balance']
print(BalR)
{'account_id': '619', 'asset': 'ZAR', 'balance': '6.19', 'reserved': '6.19', 'unconfirmed': '6.19'}
1)How do I create a Variable for the (‘ZAR’,’balance’) ? I can’t use:BalR[2]
because:len(BalR)
equals to1
If, I add another row of:BalR=BalR['balance']
under:BalR=BalR['balance']
then I get the following errorlist indices must be integers or slices, not str
If I try a:print(BalR('balance'))
I get the following errorTypeError: 'list' object is not callable
If I add:BalR=BalR[2]
under:BalR=BalR[0]
then:2
is returned I even went as far as poking in the dark with json with thisBalR=BalR['balance']
readable_json = json.loads(BalR)
BalR = readable_json['balance']
for i in BalR:
print(i['balance'])
the JSON object must be str, bytes or bytearray, not list
BalR= c.get_balances(assets=['ZAR'])
BalR=BalR['balance']
readable_json = json.loads(BalR)
for i in readable_json:
print(i['balance'])
the JSON object must be str, bytes or bytearray, not list
print(i['balance'])
the JSON object must be str, bytes or bytearray, not list
The second Question is almost identical to the first, only difference being needing to make a Variable for (‘ETH’,’balance’). Or is there another way to automatically add the maximum updated Zar to a buy order and automatically add the maximum amount of updated Eth to a sell order?
Please advise.