Skip to content

Instantly share code, notes, and snippets.

# ibaaj/get.py

Created May 9, 2017
09/05 bot
 import json import csv thuneEUR = 100 thuneETH = 0 paramChange = 1 s = 0 # 0 = faire rien, -{paramChange} vendre, +{paramChange} acheter # ex : 0 vendre, +2 acheter def t(old,new): return round( (1 - old/new)*100, 4) v_1 = v_2 = 0 lastGoodPrice = 0 l = [] #for i in range(1,10): with open('./data.csv') as csvfile: reader = csv.DictReader(csvfile) for row in reader: isSomethingDone = 0 v_2 = float(row['value']) if v_1 == 0: # initialisation (on a besoin d'une valeur ancienne..) v_1 = v_2 continue # calcul du taux variation = t(v_1,v_2) v_1 = v_2 # new becoming old ... if variation >= 0: s += 1 if s == paramChange: if thuneEUR != 0 and v_1 > lastGoodPrice: # get new ETHER !!!! # price is v_1 thuneETH += round(thuneEUR/v_1, 6) thuneETH -= round(0.0026*(thuneEUR/v_1),6) # transaction fees ~ 0.26% thuneEUR = 0 print("Variation:" + str(variation) + " - Decision: achat d'ether") print("il y a : " + str(thuneEUR) + " EUROS correspondant à " + str(round(thuneEUR/v_1,6)) + "ETH") print("il y a : " + str(thuneETH) + " ETHERS correspondant à " + str(round(thuneETH*v_1,6)) + "EUR") isSomethingDone = 1 if s > paramChange: s = paramChange else: s -= 1 if s == 0: if thuneETH != 0: # time to pass in EUR thuneEUR += round(thuneETH*v_1, 6) thuneEUR -= round(thuneETH*v_1*.0026,6) # transaction fees ~ 0.26% thuneETH = 0 print("Variation:" + str(variation) + " - Decision: vendre les ether en euro") print("il y a : " + str(thuneEUR) + " EUROS correspondant à " + str(round(thuneEUR/v_1,6)) + "ETH") print("il y a : " + str(thuneETH) + " ETHERS correspondant à " + str(round(thuneETH*v_1,6)) + "EUR") isSomethingDone = 1 lastGoodPrice = v_1 if s < -0: s = 0 if isSomethingDone == 0: print("Variation:" + str(variation) + " - faire rien") l.append(thuneEUR if thuneEUR > 0 else round(thuneETH*v_1,6)) print("FINISHED : ") print("il y a : " + str(thuneEUR) + " EUROS correspondant à " + str(round(thuneEUR/v_1,6)) + "ETH") print("il y a : " + str(thuneETH) + " ETHERS correspondant à " + str(round(thuneETH*v_1,6)) + "EUR") #for i in range(len(l)): # print(l[i])
to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.