question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Occasionally calls to fetch_balance() cause a TypeError, occurring with multiple exchanges

See original GitHub issue
  • OS: Ubuntu 20.04
  • Programming Language version: PHP 8.0.10
  • CCXT version: 1.55.92
$balances = $exchange->fetch_balance();
PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /home/error-test/vendor/ccxt/ccxt/php/bitfinex2.php:587
Stack trace:
#0 /home/error-test/vendor/ccxt/ccxt/php/bitfinex2.php(587): count()
#1 /home/error-test/fetch-balance.php(85): ccxt\bitfinex2->fetch_balance()
#2 {main}
  thrown in /home/error-test/vendor/ccxt/ccxt/php/bitfinex2.php on line 587

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /home/error-test/vendor/ccxt/ccxt/php/bitfinex2.php:587

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rxallcommented, Sep 13, 2021

Thanks @kroitor, noted down.

Response below using code similar to that posted above, with fetch_balance() called within a loop.

Note this response is for Coinbase and previous error was for Bitfinex.

Array
(
    [0] => Response:
    [1] => GET
    [2] => https://api.pro.coinbase.com/accounts
    [3] => 0
    [4] => Operation timed out after 10001 milliseconds with 0 bytes received
    [5] => Array
        (
        )

    [6] => 
)
PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /home/error-test/vendor/ccxt/ccxt/php/coinbasepro.php:388
Stack trace:
#0 /home/error-test/vendor/ccxt/ccxt/php/coinbasepro.php(388): count()
#1 /home/error-test/fetch-balance.php(86): ccxt\coinbasepro->fetch_balance()
#2 {main}
  thrown in /home/error-test/vendor/ccxt/ccxt/php/coinbasepro.php on line 388
0reactions
rxallcommented, Oct 20, 2021

no problem, really appreciate the work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bittrex fetchBalance() fails · Issue #57 · ccxt/ccxt - GitHub
Using a fresh API key pair: const balance = await market.fetchBalance() produces bittrex ...
Read more >
ccxt-dev/ccxt - Gitter
I'd like to do a conditional check before running a particular method based on whether or not it is supported by that particular...
Read more >
Exchanges — ccxt 2.4.71 documentation
In terms of the ccxt library, every exchange offers multiple markets within itself. Each market is defined by two or more currencies. The...
Read more >
How to use fetchBalance() parameters with ccxt - Stack Overflow
The params argument on fetchBalances() is for passing exchange specific data to the request. As each exchange offers different endpoints, ...
Read more >
(intermediate value) is not iterable - You.com | The AI Search ...
TypeError : (intermediate value)(intermediate value)(intermediate value) is not iterable. The error seems to only happen once I pass the destructured ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found