create account

A Python program to see if arbitrage trading is profitable by hmushtaq

View this thread on: hive.blogpeakd.comecency.com
· @hmushtaq · (edited)
$4.12
A Python program to see if arbitrage trading is profitable
Have you ever wondered if you can earn profit by buying a coin at one exchange and selling it at another. Well, I've made a simple python script to tell you just that. It queries ask and bid rates from 4 different exchanges, which are, Cryptopia, Bittrex, HitBTC and Poloniex, to show you the results. This kind of trading is known as arbitrage trading. You can find my script at https://github.com/HamidMushtaq/steemtools/blob/master/getarbitragerates.py, and it works with both Python 2 and 3.

Here is one sample output of the program. I asked it how much possible profit I can get by trading 10 litecoins. I asked that two times, and both times, it said that it is best to buy from Cryptopia and sell it at Bittrex. Here, of course I am ignoring the transaction fees. Withdrawal fees are not included either, but they can be avoided anyway, by keeping stock of both litecoins and bitcoins on both exhanges.

![](https://steemitimages.com/DQmdFiBzm92wHwFRCdDEVJfMf8rzY9a64DFuMPSvcV18NKw/image.png)

One interesting result is that of STEEM, which I queried the third time. Apparently, I can get a lot of profit by buying from Poloniex and selling it at HitBTC. However, don't be fooled by this, because if you check, you'll notice that the wallet of STEEM at HitBTC is still under maintenance. So, basically, this type of trade is not even possible.

In my Python program, I have got information from these exchanges, using their REST APIs. The information is then extracted from the resulting output in JSON form. Although, in my code, I have listed the sources from where I got help for these APIs, here I am listing them again.

1. **Cryptopia**: https://www.cryptopia.co.nz/Forum/Thread/255
2. **Poloniex**: https://poloniex.com/support/api/
3. **Bittrex**: https://bittrex.com/home/api
4. **HitBTC**: https://api.hitbtc.com/?python#rest-api-reference
___
I hope that you will find this program useful. If you have any questions relating to the code, I would be happy to answer them.

**UPDATE**
I have now also added Binance into the list of exchanges. So, now rates from 5 exchanges are shown.
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorhmushtaq
permlinka-python-program-to-see-if-arbitrage-trading-is-profitable
categoryutopian-io
json_metadata{"tags":["utopian-io","cryptocurrency","crypto","programming","python"],"image":["https://steemitimages.com/DQmdFiBzm92wHwFRCdDEVJfMf8rzY9a64DFuMPSvcV18NKw/image.png"],"links":["https://github.com/HamidMushtaq/steemtools/blob/master/getarbitragerates.py","https://www.cryptopia.co.nz/Forum/Thread/255","https://poloniex.com/support/api/","https://bittrex.com/home/api","https://api.hitbtc.com/?python#rest-api-reference"],"app":"steemit/0.1","format":"markdown"}
created2018-02-04 14:36:51
last_update2018-02-04 19:03:36
depth0
children10
last_payout2018-02-11 14:36:51
cashout_time1969-12-31 23:59:59
total_payout_value3.386 HBD
curator_payout_value0.735 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,101
author_reputation5,954,376,833,183
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,902,713
net_rshares602,606,577,399
author_curate_reward""
vote details (26)
@bitpost ·
$0.03
Good and useful effort, nice program, email me if you can expand it to other exchanges and cryptos...
hadi.k.esfahani@gmail.com
@bitpost
πŸ‘  
properties (23)
authorbitpost
permlinkre-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180204t145046710z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["bitpost"],"app":"steemit/0.1"}
created2018-02-04 14:50:45
last_update2018-02-04 14:50:45
depth1
children0
last_payout2018-02-11 14:50:45
cashout_time1969-12-31 23:59:59
total_payout_value0.034 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length136
author_reputation137,732,233,960
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,905,815
net_rshares5,373,558,962
author_curate_reward""
vote details (1)
@hamzayousaf ·
$0.35
Bittrex, Poloniex are my favorite exchanging sites. so what about HitBTC because  i havn't used this site?
πŸ‘  ,
properties (23)
authorhamzayousaf
permlinkre-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180204t185831205z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-02-04 18:58:30
last_update2018-02-04 18:58:30
depth1
children1
last_payout2018-02-11 18:58:30
cashout_time1969-12-31 23:59:59
total_payout_value0.306 HBD
curator_payout_value0.046 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length106
author_reputation38,737,399,354,190
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,955,445
net_rshares52,043,569,276
author_curate_reward""
vote details (2)
@hmushtaq ·
$0.24
HitBTC is not bad too. But after adding Binance into the list of exchanges for this program, I can see that Binance has the lowest rates.
πŸ‘  
properties (23)
authorhmushtaq
permlinkre-hamzayousaf-re-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180204t190502882z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-02-04 19:05:03
last_update2018-02-04 19:05:03
depth2
children0
last_payout2018-02-11 19:05:03
cashout_time1969-12-31 23:59:59
total_payout_value0.178 HBD
curator_payout_value0.058 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length137
author_reputation5,954,376,833,183
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,956,698
net_rshares35,344,445,681
author_curate_reward""
vote details (1)
@jauharialz ·
this information is very useful for me. in the future i will try.
πŸ‘  
properties (23)
authorjauharialz
permlinkre-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180204t144240842z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-02-04 14:42:21
last_update2018-02-04 14:42:21
depth1
children0
last_payout2018-02-11 14:42:21
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_length65
author_reputation4,305,757,255,451
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,903,996
net_rshares1,934,481,226
author_curate_reward""
vote details (1)
@leoumesh ·
$0.04
I can see a great and depth passion of yours in programmingπŸ˜‹
πŸ‘  
properties (23)
authorleoumesh
permlinkre-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180205t021712454z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-02-05 02:17:15
last_update2018-02-05 02:17:15
depth1
children0
last_payout2018-02-12 02:17:15
cashout_time1969-12-31 23:59:59
total_payout_value0.030 HBD
curator_payout_value0.007 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length60
author_reputation212,340,493,251,438
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id35,028,571
net_rshares6,241,271,856
author_curate_reward""
vote details (1)
@m3mt ·
$0.05
Humm, the only downside to his would be the feeds for moving coins around from one exchange to another and the time it takes, i would rather focus in trading in the same exchange, but nevertheless it is a good tool if you know how to use it, thanks for sharing it.
πŸ‘  
properties (23)
authorm3mt
permlinkre-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180204t155219465z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-02-04 15:52:18
last_update2018-02-04 15:52:18
depth1
children1
last_payout2018-02-11 15:52:18
cashout_time1969-12-31 23:59:59
total_payout_value0.034 HBD
curator_payout_value0.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length264
author_reputation276,485,595,715
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,918,312
net_rshares7,097,384,516
author_curate_reward""
vote details (1)
@hmushtaq · (edited)
$0.26
Basically moving of the coins can be avoided if you keep a stock of BTC and the other coin on both exchanges. But like you said, trading is definitely more profitable if you do it right. One interesting phenomena I have observed is that when the values of other cryptos are goin down, the value of digixdao goes up and vice versa. That is because digixdao is backed by gold. I'll make a post about that soon. But first, I have to observe things more in depth.
πŸ‘  ,
properties (23)
authorhmushtaq
permlinkre-m3mt-re-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180204t163837057z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-02-04 16:38:39
last_update2018-02-04 16:39:18
depth2
children0
last_payout2018-02-11 16:38:39
cashout_time1969-12-31 23:59:59
total_payout_value0.202 HBD
curator_payout_value0.054 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length459
author_reputation5,954,376,833,183
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,927,860
net_rshares37,806,728,376
author_curate_reward""
vote details (2)
@mercurybot ·
re-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180206t093202293z
You got a 2.12% upvote from @mercurybot courtesy of @hmushtaq!
properties (22)
authormercurybot
permlinkre-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180206t093202293z
categoryutopian-io
json_metadata{"app":"postpromoter/1.7.4"}
created2018-02-06 09:32:00
last_update2018-02-06 09:32:00
depth1
children0
last_payout2018-02-13 09:32:00
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_length62
author_reputation732,353,368,070
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id35,360,872
net_rshares0
@pranto ·
I will try thank you
properties (22)
authorpranto
permlinkre-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180204t143916219z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-02-04 14:39:15
last_update2018-02-04 14:39:15
depth1
children0
last_payout2018-02-11 14:39: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_length20
author_reputation4,636,466,930,802
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,903,296
net_rshares0
@taslimabegum ·
$0.02
Thanks for sharing. Learned something and i will try it.
πŸ‘  ,
properties (23)
authortaslimabegum
permlinkre-hmushtaq-a-python-program-to-see-if-arbitrage-trading-is-profitable-20180204t143818024z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-02-04 14:38:18
last_update2018-02-04 14:38:18
depth1
children0
last_payout2018-02-11 14:38:18
cashout_time1969-12-31 23:59:59
total_payout_value0.022 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length56
author_reputation1,231,512,563,619
root_title"A Python program to see if arbitrage trading is profitable"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id34,903,064
net_rshares3,851,174,826
author_curate_reward""
vote details (2)