|
@@ -0,0 +1,99 @@
|
|
1
|
+#! /usr/bin/env python3
|
|
2
|
+import math
|
|
3
|
+import numpy as np
|
|
4
|
+import pandas as pd
|
|
5
|
+import MagnaSim1 as MaSi
|
|
6
|
+from tkinter import *
|
|
7
|
+
|
|
8
|
+window = Tk()
|
|
9
|
+
|
|
10
|
+window.title("MaSi")
|
|
11
|
+
|
|
12
|
+#window.geometry('600x500')
|
|
13
|
+
|
|
14
|
+lbl_client_txt = ["BTC","ETH","MGN","BTC/ETH","ETH/MGN","MGN/BTC","B/E/M"]
|
|
15
|
+
|
|
16
|
+lbl_client = Label(window, text="Nbr clients:")
|
|
17
|
+lbl_client.grid(column=0, row=0)
|
|
18
|
+lbl_client_coord = {"BTC":(0,1),"ETH":(0,3),"MGN":(0,5),"BTC/ETH":(1,1),"ETH/MGN":(1,3),"MGN/BTC":(1,5),"B/E/M":(2,1)}
|
|
19
|
+txt_client_coord = {"BTC":(0,2),"ETH":(0,4),"MGN":(0,6),"BTC/ETH":(1,2),"ETH/MGN":(1,4),"MGN/BTC":(1,6),"B/E/M":(2,2)}
|
|
20
|
+lbl_client_token = {}
|
|
21
|
+txt_client_token = {}
|
|
22
|
+for token in lbl_client_txt:
|
|
23
|
+ lbl_client_token[token] = Label(window, text=token)
|
|
24
|
+ txt_client_token[token] = Entry(window, width=10)
|
|
25
|
+ txt_client_token[token].insert(0,"0")
|
|
26
|
+ lbl_client_token[token].grid(row=lbl_client_coord[token][0], column=lbl_client_coord[token][1])
|
|
27
|
+ txt_client_token[token].grid(row=txt_client_coord[token][0], column=txt_client_coord[token][1])
|
|
28
|
+
|
|
29
|
+lbl_rates = Label(window, text="% Frais:")
|
|
30
|
+lbl_rates.grid(column=0, row=3)
|
|
31
|
+lbl_rates_coord = {"BTC":(3,1),"ETH":(3,3),"MGN":(3,5)}
|
|
32
|
+txt_rates_coord = {"BTC":(3,2),"ETH":(3,4),"MGN":(3,6)}
|
|
33
|
+lbl_rates = {}
|
|
34
|
+txt_rates = {}
|
|
35
|
+for token in lbl_client_txt[0:3]:
|
|
36
|
+ lbl_rates[token] = Label(window, text=token)
|
|
37
|
+ txt_rates[token] = Entry(window, width=10)
|
|
38
|
+ txt_rates[token].insert(0,"0")
|
|
39
|
+ lbl_rates[token].grid(row=lbl_rates_coord[token][0], column=lbl_rates_coord[token][1])
|
|
40
|
+ txt_rates[token].grid(row=txt_rates_coord[token][0], column=txt_rates_coord[token][1])
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+def clicked():
|
|
44
|
+ # First we get the number of clients
|
|
45
|
+ # in each category
|
|
46
|
+ nbr_client = {}
|
|
47
|
+ for token in lbl_client_txt:
|
|
48
|
+ nbr_client[token] = int(txt_client_token[token].get())
|
|
49
|
+ if nbr_client[token] == None:#To avoid erors
|
|
50
|
+ nbr_client[token] = 0
|
|
51
|
+ # Then we get the rates for each token
|
|
52
|
+ rates_fee = {}
|
|
53
|
+ for token in lbl_client_txt[0:3]:
|
|
54
|
+ rates_fee[token] = float(txt_rates[token].get())
|
|
55
|
+ # We print the total of clients
|
|
56
|
+ lbl_SUM.configure(text=sum(nbr_client.values()))
|
|
57
|
+ print(sum(nbr_client.values()))
|
|
58
|
+ # We create a population
|
|
59
|
+ pop = MaSi.Populations(nbr_client)
|
|
60
|
+ # We create the list of transaction
|
|
61
|
+ trans = MaSi.Transaction()
|
|
62
|
+ trans_value = {"BTC":0,"ETH":0,"MGN":0}
|
|
63
|
+ trans_fees = {"BTC":0,"ETH":0,"MGN":0}
|
|
64
|
+ for i in pop.population:
|
|
65
|
+ x = abs(np.random.normal(i.magna_wallet_btc[0],i.magna_wallet_btc[1]))
|
|
66
|
+ if x != 0:
|
|
67
|
+ trans.btc += 1
|
|
68
|
+ trans_value["BTC"] += x
|
|
69
|
+ trans_fees["BTC"] += x*rates_fee[token]
|
|
70
|
+ y = abs(np.random.normal(i.magna_wallet_eth[0],i.magna_wallet_eth[1]))
|
|
71
|
+ if y != 0:
|
|
72
|
+ trans.eth += 1
|
|
73
|
+ trans_value["ETH"] += y
|
|
74
|
+ trans_fees["ETH"] += y*rates_fee["ETH"]
|
|
75
|
+ z = abs(np.random.normal(i.magna_wallet_mgn[0],i.magna_wallet_mgn[1]))
|
|
76
|
+ if z != 0:
|
|
77
|
+ trans.mgn += 1
|
|
78
|
+ trans_value["MGN"] += z
|
|
79
|
+ trans_fees["MGN"] += z*rates_fee["MGN"]
|
|
80
|
+
|
|
81
|
+# print("Nombre de BTC : {:f}".format(MaSi.fees_btc(trans.btc)*0.0000001))
|
|
82
|
+ print("Pour le BTC:\nLes transfères du aux frais coûtent :{:f} satoshi\n".format(MaSi.fees_btc(trans.btc)))
|
|
83
|
+ print("Pour le ETH:\nLes transfères du aux frais coûtent :{:f} Gwei\n".format(MaSi.fees_eth(trans.eth)))
|
|
84
|
+ print("Pour le MGN:\nLes transfères du aux frais coûtent :{:f} stroops\n".format(MaSi.fees_mgn(trans.mgn)))
|
|
85
|
+ print("frais :", trans_fees)
|
|
86
|
+ print("total mouvement:", trans_value)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+btn = Button(window, text="Launch", command=clicked)
|
|
90
|
+lbl_SUM0 = Label(window, text="clients :")
|
|
91
|
+lbl_SUM0.grid(column=7, row=21)
|
|
92
|
+lbl_SUM = Label(window, text="0")
|
|
93
|
+lbl_SUM.grid(column=8, row=21)
|
|
94
|
+
|
|
95
|
+btn.grid(column=8, row=20)
|
|
96
|
+
|
|
97
|
+txt_client_token["BTC"].focus()
|
|
98
|
+
|
|
99
|
+window.mainloop()
|