10 liens privés
#Interet : Bitcoin, Litecoin,Ethereum,Monero,Zcash,Dash
import urllib.request, json, datetime,matplotlib.pyplot as plt
cur_to_plt = "Litecoin"
dat_invest = '2017-05-01'
currency_name= {"Bitcoin" : "XBT", "Ethereum" : "ETH", "Bitcoin Cash": "BCH" , "Monero" : "XMR", "Dash" : "DASH" , "Litecoin" : "LTC" , "Ripple" : "XRP" , \
"Ethereum Classic" : "ETC" , "Augur REP tokens" : "REP", "Zcash" : "ZEC" }
currency_min_size = {"Augur" : 0.3 ,"Bitcoin" : 0.002, "Bitcoin Cash" : 0.002 ,"Dash" : 0.03 , "Dogecoin" : 3000 , "Ethereum" : 0.02, "Ethereum Classic" : 0.3, "Gnosis" : 0.03, \
"Litecoin" : 0.1, "Monero" : 0.1, "Ripple" : 30, "Zcash" : 0.03, "Tether" : 5}
with urllib.request.urlopen("https://api.kraken.com/0/public/OHLC?pair=" + currency_name[cur_to_plt]+"EUR&interval=1440") as url:
datas = json.loads(url.read().decode())
with open('OHLC.json', 'r') as f:
datas = json.load(f)
for i in datas['result'].keys() :
if 'EUR' in i : clef = i
for i in datas['result'][clef] :
if datetime.datetime.fromtimestamp(i[0]).strftime('%Y-%m-%d') == dat_invest :
gain = (float(datas['result'][clef][-1][1])*(50 / float(i[1])))-50
data_toplot = [float(i[1]) for i in datas['result'][clef] if (datetime.datetime.fromtimestamp(i[0])- datetime.datetime(int(dat_invest.split('-')[0]), int(dat_invest.split('-')[1]), int(dat_invest.split('-')[2]))).days > 1]
header = [datetime.datetime.fromtimestamp(i[0])for i in datas['result'][clef] if (datetime.datetime.fromtimestamp(i[0])- datetime.datetime(int(dat_invest.split('-')[0]), int(dat_invest.split('-')[1]), int(dat_invest.split('-')[2]))).days > 1]
plt.plot_date(header,data_toplot,linestyle='solid',markersize=2)
try:
plt.title(cur_to_plt + '\n € min order : ' +str("%.2f" % (currency_min_size[cur_to_plt]*data_toplot[-1])) + ' \n gain depuis ' + dat_invest +': ' + str("%.2f" % gain))
except :
pass
plt.show()