Closed jjziets closed 5 years ago
This works fine. So I'm a little lost why getBankAmounts will not work.
Dictionary<string, decimal> balances = await HitBTC.GetAmountsAvailableToTradeAsync();
foreach (KeyValuePair<string, decimal> entry in balances)
{
stats += " " + entry.Key + " " + entry.Value.ToString();
}
I think the problem is here. There is no "balance"
public async Task<Dictionary<string, decimal>> GetBankAmountsAsync()
{
Dictionary<string, decimal> amounts = new Dictionary<string, decimal>();
JToken obj = await MakeJsonRequestAsync<JToken>("/account/balance", null, await GetNoncePayloadAsync());
foreach (JToken token in obj["balance"])
{
decimal amount = token["available"].ConvertInvariant<decimal>();
if (amount > 0m) amounts[token["currency"].ToStringInvariant()] = amount;
}
return amounts;
}
Name | Value | Type | |
---|---|---|---|
◢ | obj |
I have no idea how to pull a request but this seems to have fix the problem.
public async Task<Dictionary<string, decimal>> GetBankAmountsAsync()
{
Dictionary<string, decimal> amounts = new Dictionary<string, decimal>();
JToken obj = await MakeJsonRequestAsync<JToken>("/account/balance", null, await GetNoncePayloadAsync());
foreach (JToken token in obj)
{
decimal amount = token["available"].ConvertInvariant<decimal>();
if (amount > 0m) amounts[token["currency"].ToStringInvariant()] = amount;
}
return amounts;
}
Stick at something simple
results in exception
System.ArgumentException: 'Accessed JArray values with invalid key value: "balance". Int32 array index expected
Is this a bug in the HitBTC code or my implementations