The CCXT fetch_balance is about 5/6 times slower than get_account on Binance
See original GitHub issueMUST READ THIS BEFORE SUBMITTING ISSUES (read the links, then delete this message before submitting):
- https://github.com/ccxt/ccxt/wiki/FAQ
- https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-submit-an-issue
Make sure your local version of CCXT is up to date. Check by comparing the output of ccxt.version
to https://github.com/ccxt/ccxt/blob/master/package.json#L3
- OS: MacOS
- Programming Language version: Python
- CCXT version: 1.55.69
import ccxt
from binance.client import Client
import time
apiKey = "*****"
secret = "*****"
# binance-python client
client = Client(apiKey, secret, testnet=True)
# ccxt client
exchange_id = 'binance'
exchange_class = getattr(ccxt, exchange_id)
exchange = exchange_class({
"apiKey": apiKey,
"secret": secret,
})
exchange.set_sandbox_mode(True)
start_time = time.time()
exchange.fetch_balance()
end_time = time.time()
print(f"ccxt: {end_time - start_time}")
start_time = time.time()
client.get_account()
end_time = time.time()
print(f"binance: {end_time - start_time}")
ccxt: 1.3862950801849365
binance: 0.24796199798583984
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Binance: Timestamp for this request is not valid #300 - GitHub
That error on Binance means your system time is out of sync with their clock by more than 5 seconds... Check the UTC-alignment...
Read more >Exchanges — ccxt 2.4.71 documentation
The ccxt library is a collection of available crypto exchanges or exchange classes. Each class implements the public and private API for a...
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 >how to get balance on binance (with python & ccxt) - YouTube
in this video i show you how to get your balance on binance or any other exchange using the ccxt library and pythonthis...
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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@wkamer
If you don’t want any delays, you can disable the rate limiter entirely, at your risk (since if you disable the rate limiter, your requests may be too aggressive for the exchange API and they might ban you temporarily for too many requests).
Reuse the exchange instance instead – create it once at the start of your script. Then do a fetch_balance call. Then leave your script running, and repeat the consequent fetch_balance calls on the already existing exchange instance, instead of exiting the script and restarting it again and again. The snippet in this post does exactly that.
Thanks, I tried the script your way and see it has good results by. Still a little slower, but around 500ms. I see that you refer to your wiki about instantiate it every time and with that it looks up the market every time? How to handle this when I use the fetch_balance as an api endpoint? I do an instantiate every time I call the fetch_balance.