-
Notifications
You must be signed in to change notification settings - Fork 0
/
CryptoArbitrage.py
82 lines (54 loc) · 2.51 KB
/
CryptoArbitrage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import requests
import matplotlib.pyplot as plt
import numpy
from twilio.rest import Client
client = Client(account_sid, auth_token)
i = 0
date = []
arbitrage = []
while (i<1):
data = requests.get('https://localbitcoins.com/buy-bitcoins-online/COP/.json')
if (data.status_code != 200):
data = requests.get('https://localbitcoins.com/buy-bitcoins-online/COP/.json')
COPprice = data.json()['data']['ad_list'][0]['data']['temp_price']
USD2COP = 2923.8050
BTC = requests.get('https://api.coinbase.com/v2/prices/BTC-USD/buy')
if (BTC.status_code != 200):
BTC = requests.get('https://api.coinbase.com/v2/prices/BTC-USD/buy')
BTCoinbase = BTC.json()['data']['amount']
t = requests.get('https://api.coinbase.com/v2/time')
if (t.status_code != 200):
t = requests.get('https://api.coinbase.com/v2/time')
Time = t.json()['data']['epoch']
iso = t.json()['data']['iso']
Gain = round((( float(BTCoinbase)/(float(COPprice) / USD2COP) ) - 1)*100, 2)
# To get date and time replace epoch with iso
date.append(Time)
arbitrage.append(Gain)
plt.plot(date, arbitrage)
plt.title("BTC Colombian Arbitrage")
plt.ylabel("Profit % (USD $)")
plt.xlabel("Time")
plt.pause(1)
plt.draw()
if (Gain >= 10):
client.messages.create(
to = "+17866630320",
from_= "+19548926238",
body = "The Current BTC Arbitrage profit is " + str(Gain) + "% " + "That is a $" + str(round(float(BTCoinbase) - round((float(COPprice) / USD2COP),2),2)) + " discount...You should buy NOW!"
)
print("Current Time: " + str(iso))
print("+++++++++++++++++++++++++++++++++++++++")
print("+++++++++++++++++++++++++++++++++++++++")
print("+++++++++++++++++++++++++++++++++++++++")
print("+++++++++++++++++++++++++++++++++++++++")
print("Current Coinbase Price: $" + BTCoinbase)
print("+++++++++++++++++++++++++++++++++++++++")
print("+++++++++++++++++++++++++++++++++++++++")
print("Current Local Bitcoins Price: $" + str(round((float(COPprice) / USD2COP),2)))
print("+++++++++++++++++++++++++++++++++++++++")
print("Arbitrage gain: " + str(Gain) + "%" + " A $" + str(round(float(BTCoinbase) - round((float(COPprice) / USD2COP),2),2)) + " Discount")
print("+++++++++++++++++++++++++++++++++++++++")
print("+++++++++++++++++++++++++++++++++++++++")
print("+++++++++++++++++++++++++++++++++++++++")
print("+++++++++++++++++++++++++++++++++++++++")