create account

Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday by geekgirl

View this thread on: hive.blogpeakd.comecency.com
· @geekgirl ·
$95.12
Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday
![ccxt.png](https://images.hive.blog/DQmP7AXNQQHk7FXFZruTqK3nagHuWBefrNA489MHsxVbH5a/ccxt.png)

I wrote about CCXT API in the past and how useful it can be to get list of exchanges, coin prices, and trading pairs. Since this information always changes, it is good to have scripts or tools that we can reuse to get the latest data. For example, we can find out if any new exchanges have listed the coins/tokens or maybe dropped them from their platforms. We can also get price data to compare the prices among all the exchanges. I have written a script that does just that for Hive and HBD. I would like to share the script again here with the latest results.

CCXT is a cryptocurrency exchange trading library for Javascript, Python, and PHP. It is a trading API that supports more than 120 crypto exchanges and continues to add more. While my personal preference is to use in my python projects, it is nice to know that it can be used in Javascript and PHP based projects. For more details feel free to visit [CCXT GitHub page](https://github.com/ccxt/ccxt).

What is really great about this library is that it provides access to many exchanges which include major exchanges like Coinbase, CoinbasePro, Binance, Bittrex, Huobi, etc. Various exchanges have their own python packages to interact with them. I think it is much better to have one interface that can connect to multiple exchanges, get necessary data, and even automate trading.

Most of the functions are available as public and do not need API access credentials. However, for projects that need access to a trading account, we will need to obtain the API access credentials for specific exchanges that we have accounts at.

This API can be used for simple things like getting data on what is being traded on exchanges, historical cryptocurrency prices. It can also be used for more complex projects like trading bots, web applications, etc.

Getting started with this API is super easy. For python we need to first pip install ccxt. Once that is done we can start using it in our python code.

To demonstrate how work with ccxt, I wanted to see what exchanges have HIVE and HBD listed, what trading pairs are available and the latest prices.

First to see what exchanges are supported we can write the following code:

```
import ccxt

print(ccxt.exchanges)
```
If we already know what exchange we would like to use in that list, we can start connecting to this exchange, and get trading pairs and latest data about this trading pairs as below:

```
import ccxt

binance = ccxt.binance()
print(binance.load_markets())
```

If we need to access our accounts we will need to pass api key and secrets as a dictionary argument like this:

```
import ccxt

binance = ccxt.binance({
    'apiKey': 'YOUR_PUBLIC_API_KEY',
    'secret': 'YOUR_SECRET_PRIVATE_KEY',
})

```

As you can see it is very easy to get started with CCXT. Exploring more available methods and properties we can write much more useful code.

As I mentioned I was curious to see if I could use CCXT to see all the exchanges that have HIVE and HBD listed, what trading pairs they have available, and latest prices. Let's do that now.

```
import ccxt

def create_table(prices):
    table = '<table><tr><th>Ticker Symbol</th><th>Exchange</th><th>Price</th></tr>'
    for price in prices:
        row = f'<tr><td>{price[0]}</td><td>{price[1]}</td><td>{str(price[2])+" "+price[3]}</td></tr>'
        table += row
    table += '</table>'
    return table

prices = []
for exchange_id in ccxt.exchanges:
    if exchange_id == 'cdax':
        continue

    try:
        exchange_class = getattr(ccxt, exchange_id)
        exchange = exchange_class()
        markets = exchange.load_markets()
    except:
        continue

    for market in markets:
        if 'HIVE' in market or 'HBD' in market:
            if 'HBDC' in market:
                continue
            ticker = exchange.fetch_ticker(market)
            if ticker['symbol'].split('/')[1] == 'BTC':
                prices.append((market, exchange_id, format(ticker['close'], '.8f'), ticker['symbol'].split('/')[1]))
            else:
                prices.append((market, exchange_id, ticker['close'], ticker['symbol'].split('/')[1]))

table = create_table(prices)
print(table)
```

What the main part of the code doing is, first we are trying to identify all the exchanges, then we are getting the method by the same name to create the instance of the exchange. Then we are looking what ticker symbols are traded in the exchange. If any of the tickers include Hive or HBD we are storing ticker symbol, exchange name, last close price in prices list. `create_table` is a helper function that puts together the results in a table format, so I can include them in the post. You can scroll down to see the results.

Initially when I was testing I was getting 12 exchanges that have Hive traded on. However, something went wrong when I tried to get the prices of **CDAX** exchange. After looking closely I was convinced Hive or HBD were not actually listed there. So I have do include a line of code to exclude **CDAX**. 

Another interesting thing we can see is from the results is that, for some reason **HBTC** exchange named the ticker symbol as **HIVE1/USDT** instead of just HIVE without 1.

In the past results from few months ago the results would show exchange names **LATOKEN** where all trading pair prices for Hive were zero. Now it seems this exchange doesn't show up in the results anymore.

This is not a full list of exchanges that have Hive or HBD listed. We can see how some exchanges like ionomy, blocktrades, beaxy, mxc, are not there. It is still great to see that all the major exchanges like Binance, Bittrex, Huobi, Upbit are supported in CCXT.

The code above can also be used for any other coins/tokens. If you learn about a new coin/token and would like to see if where it is traded, simply change the comparison logic from HIVE and HBD to that coin/token.

Comparing the results from few months ago, new results show that Hive is now also being traded at **coinex**. 

<center><h1>Hive and HBD Prices</h2></center>

<center>
<table><tr><th>Ticker Symbol</th><th>Exchange</th><th>Price</th></tr><tr><td>HIVE/BNB</td><td>binance</td><td>0.0 BNB</td></tr><tr><td>HIVE/BTC</td><td>binance</td><td>0.00001556 BTC</td></tr><tr><td>HIVE/USDT</td><td>binance</td><td>0.7468 USDT</td></tr><tr><td>HIVE/KRW</td><td>bithumb</td><td>903.8 KRW</td></tr><tr><td>HBD/BTC</td><td>bittrex</td><td>0.00002179 BTC</td></tr><tr><td>HIVE/BTC</td><td>bittrex</td><td>0.00001544 BTC</td></tr><tr><td>HIVE/USD</td><td>bittrex</td><td>0.74021 USD</td></tr><tr><td>HIVE/USDT</td><td>bittrex</td><td>0.739 USDT</td></tr><tr><td>HIVE/USDT</td><td>coinex</td><td>0.7474 USDT</td></tr><tr><td>HIVE/BTC</td><td>coinex</td><td>0.00001550 BTC</td></tr><tr><td>HIVE/USDT</td><td>gateio</td><td>0.7454 USDT</td></tr><tr><td>HIVE1/USDT</td><td>hbtc</td><td>0.74 USDT</td></tr><tr><td>HIVE/BTC</td><td>huobipro</td><td>0.00001552 BTC</td></tr><tr><td>HIVE/USDT</td><td>huobipro</td><td>0.745 USDT</td></tr><tr><td>HIVE/HT</td><td>huobipro</td><td>0.052618 HT</td></tr><tr><td>HIVE/IDR</td><td>indodax</td><td>10681.0 IDR</td></tr><tr><td>HIVE/USDT</td><td>probit</td><td>0.7492 USDT</td></tr><tr><td>HIVE/BTC</td><td>probit</td><td>0.00001556 BTC</td></tr><tr><td>HIVE/BTC</td><td>stex</td><td>0.00000561 BTC</td></tr><tr><td>HIVE/BTC</td><td>upbit</td><td>0.00001548 BTC</td></tr><tr><td>HBD/BTC</td><td>upbit</td><td>0.00002133 BTC</td></tr><tr><td>HIVE/KRW</td><td>upbit</td><td>904.0 KRW</td></tr></table>
</center>

Posted Using [LeoFinance <sup>Beta</sup>](https://leofinance.io/@geekgirl/getting-list-of-exchanges-and-prices-for-hive-and-hbd-with-ccxt-api-or-showcase-sunday)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 319 others
properties (23)
authorgeekgirl
permlinkgetting-list-of-exchanges-and-prices-for-hive-and-hbd-with-ccxt-api-or-showcase-sunday
categoryhive-167922
json_metadata{"app":"leofinance/0.2","format":"markdown","tags":["crypto","hive","coding","prices","dev","stem","ctp","proofofbrain","neoxian","palnet","leofinance"],"canonical_url":"https://leofinance.io/@geekgirl/getting-list-of-exchanges-and-prices-for-hive-and-hbd-with-ccxt-api-or-showcase-sunday","links":["https://github.com/ccxt/ccxt"],"image":["https://images.hive.blog/DQmP7AXNQQHk7FXFZruTqK3nagHuWBefrNA489MHsxVbH5a/ccxt.png"]}
created2021-09-19 08:31:24
last_update2021-09-19 08:31:24
depth0
children11
last_payout2021-09-26 08:31:24
cashout_time1969-12-31 23:59:59
total_payout_value47.612 HBD
curator_payout_value47.503 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,754
author_reputation1,588,017,852,468,897
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,401,401
net_rshares109,779,877,085,445
author_curate_reward""
vote details (383)
@ackza ·
$0.34
PUT That lil Nay Nay on the chainlink price feed oracle e ey ey ey eye
👍  
properties (23)
authorackza
permlinkqzohey
categoryhive-167922
json_metadata{"app":"hiveblog/0.1"}
created2021-09-19 11:04:12
last_update2021-09-19 11:04:12
depth1
children1
last_payout2021-09-26 11:04:12
cashout_time1969-12-31 23:59:59
total_payout_value0.171 HBD
curator_payout_value0.171 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length70
author_reputation288,201,244,970,537
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id106,403,559
net_rshares395,233,155,849
author_curate_reward""
vote details (1)
@geekgirl ·
$0.02
I wish I knew how that works. I have no idea what chainlink does.
👍  
properties (23)
authorgeekgirl
permlinkqzpp26
categoryhive-167922
json_metadata{"app":"hiveblog/0.1"}
created2021-09-20 02:46:54
last_update2021-09-20 02:46:54
depth2
children0
last_payout2021-09-27 02:46:54
cashout_time1969-12-31 23:59:59
total_payout_value0.012 HBD
curator_payout_value0.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length65
author_reputation1,588,017,852,468,897
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,420,451
net_rshares27,363,013,435
author_curate_reward""
vote details (1)
@alokkumar121 ·
$0.35
This is an interesting pricing update from mutiple exchanges. Just wondering if there can a link which can be accessed anytime to get prices updated in real time?
👍  
properties (23)
authoralokkumar121
permlinkqzqt12
categoryhive-167922
json_metadata{"tags":["stem"],"app":"stemgeeks/0.1","canonical_url":"https://stemgeeks.net/@alokkumar121/qzqt12"}
created2021-09-20 17:10:18
last_update2021-09-20 17:10:18
depth1
children1
last_payout2021-09-27 17:10:18
cashout_time1969-12-31 23:59:59
total_payout_value0.177 HBD
curator_payout_value0.177 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length162
author_reputation2,489,689,464,257,268
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,436,593
net_rshares425,001,092,221
author_curate_reward""
vote details (1)
@geekgirl ·
Not sure what you mean with a link. But you probably could create one using ccxt.
properties (22)
authorgeekgirl
permlinkqzs1af
categoryhive-167922
json_metadata{"app":"hiveblog/0.1"}
created2021-09-21 09:06:15
last_update2021-09-21 09:06:15
depth2
children0
last_payout2021-09-28 09:06:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length81
author_reputation1,588,017,852,468,897
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,451,100
net_rshares0
@jedigeiss ·
$0.37
Very cool stuff my dear, for my current discord price bot I am using coingeckos API in python.
But I can definitely see the advantages of using this one instead of the one that coingecko is providing. Will give it a try soon. 
Thanks for sharing! 
Yours
Jan
👍  , , , ,
properties (23)
authorjedigeiss
permlinkre-geekgirl-qzoaxe
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2021.09.1"}
created2021-09-19 08:44:06
last_update2021-09-19 08:44:06
depth1
children3
last_payout2021-09-26 08:44:06
cashout_time1969-12-31 23:59:59
total_payout_value0.187 HBD
curator_payout_value0.186 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length257
author_reputation329,730,247,512,253
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,401,552
net_rshares432,406,543,586
author_curate_reward""
vote details (5)
@geekgirl ·
$0.04
Thank You Jan! Awesome! I hope you will find it useful. Is your discord bot in python? If yes is the code publicly available somewhere to copy? :)

Once I tried making a python discord bot that would update with latest community posts. Then it would stop working after few days, and I gave up with discord bots. I may need to try again.
👍  , , ,
properties (23)
authorgeekgirl
permlinkqzobg2
categoryhive-167922
json_metadata{"app":"hiveblog/0.1"}
created2021-09-19 08:55:15
last_update2021-09-19 08:55:15
depth2
children2
last_payout2021-09-26 08:55:15
cashout_time1969-12-31 23:59:59
total_payout_value0.019 HBD
curator_payout_value0.018 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length336
author_reputation1,588,017,852,468,897
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,401,711
net_rshares46,946,951,132
author_curate_reward""
vote details (4)
@jedigeiss · (edited)
$0.36
Hi 
yep it is on github, but in a very outdated way and it does a lot more than just show graphs of cryptos. ... but this is a very good reason to finally get my github updates going again ;) 
once I got it sorted I will let you know ok ? :)
Oh and yes it is written in python ;)
👍  , , ,
properties (23)
authorjedigeiss
permlinkqzocff
categoryhive-167922
json_metadata{"app":"hiveblog/0.1"}
created2021-09-19 09:16:27
last_update2021-09-19 09:17:27
depth3
children1
last_payout2021-09-26 09:16:27
cashout_time1969-12-31 23:59:59
total_payout_value0.181 HBD
curator_payout_value0.180 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length279
author_reputation329,730,247,512,253
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,402,006
net_rshares419,003,811,755
author_curate_reward""
vote details (4)
@leoplaw · (edited)
$0.38
A great deal can be built atop CCXT. There are a number of trading desks that use it.

CCXT Pro offers a unified websocket API for the exchanges. That's the major difference between the two versions of the library.
👍  , , , ,
properties (23)
authorleoplaw
permlinkre-geekgirl-qzobqk
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2021.09.1"}
created2021-09-19 09:05:45
last_update2021-09-19 09:08:27
depth1
children1
last_payout2021-09-26 09:05:45
cashout_time1969-12-31 23:59:59
total_payout_value0.191 HBD
curator_payout_value0.190 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length214
author_reputation189,628,210,789,149
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,401,827
net_rshares443,632,399,978
author_curate_reward""
vote details (5)
@geekgirl ·
That's good to know. Thank You. I will experiment more with CCXT when I get a chance.
properties (22)
authorgeekgirl
permlinkqzpp0b
categoryhive-167922
json_metadata{"app":"hiveblog/0.1"}
created2021-09-20 02:45:48
last_update2021-09-20 02:45:48
depth2
children0
last_payout2021-09-27 02:45:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length85
author_reputation1,588,017,852,468,897
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,420,426
net_rshares0
@mlrequena78 ·
Thanks for the info.
properties (22)
authormlrequena78
permlinkqzp6vg
categoryhive-167922
json_metadata{"app":"hiveblog/0.1"}
created2021-09-19 20:13:51
last_update2021-09-19 20:13:51
depth1
children0
last_payout2021-09-26 20:13:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length20
author_reputation7,346,493,787,724
root_title"Getting List Of Exchanges & Prices For Hive & HBD with CCXT API | Showcase Sunday"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id106,414,351
net_rshares0