Closed akasimo closed 6 years ago
Hi!
Most of the time, you need to load markets to be able to access symbols and their properties.
https://github.com/ccxt/ccxt/wiki/Manual#loading-markets
This will be done automatically upon your first call to the Unified API. But if you are not calling the unified methods after instantiation and try to access markets right away after creating the exchange, it can fail, because those markets don't get loaded implicitly.
So, in most cases, you will be fine if you do load_markets() first before accessing markets and symbols anyway:
import ccxt
exchange = ccxt.kraken()
exchange.load_markets()
# from here exchange.symbols are accessible whatever the exchange is
print(exchange.symbols)
Thank you for the info!
P.S. The above is easily explained: we avoid hardcoding the markets, and we load them from the exchange itself after the instantiation where available, but we don't want to make it implicitly, therefore you should call that method explicitly where markets are not hardcoded. This explains why some exchanges work right away (hardcoded markets) and some require a load_markets()
first (markets are always up to date fetched from the exchange on demand).
The .markets
and .symbols
will be loaded for you automatically if you call some method of the unified API, say, do this:
exchange = ccxt.kraken()
exchange.fetch_ticker('BTC/USD')
# or
# exchange.fetch_balance()
# or ...
# from here, exchange.symbols are present
print(exchange.symbols)
Hi,
Thank you for all your work. I am not an experienced python user, however it seems to me that some exchanges return None when using exchange.symbols method, such as:
binance, bithumb, bitmex, bittrex, cex, cryptopia, kraken
,while the exchanges below return the symbol list with no problem:
bitfinex2, bitstamp1, btcturk, coinfloor, itbit
Please let me know if I have been doing anything incorrectly.