Browse Source

recupération de la fonction btc fees et main.py

Mushu 5 years ago
parent
commit
3db64cf1e8
2 changed files with 34 additions and 5 deletions
  1. 29 2
      MagnaSim.py
  2. 5 3
      main.py

+ 29 - 2
MagnaSim.py View File

@@ -35,7 +35,6 @@ class Populations:
35 35
         self.population = self.population.append(pd.Series(inds, index=range(start, end)))
36 36
         self.nmbr += nb
37 37
         return
38
-    
39 38
 
40 39
 class Individu: #tout OK
41 40
     """
@@ -76,4 +75,32 @@ class Individu: #tout OK
76 75
             abs(np.random.normal(
77 76
                 loc=10, scale=50))
78 77
         )
79
-        return
78
+        return
79
+
80
+class Transaction:
81
+    """
82
+    This class keeps track of the transactions
83
+    """
84
+    def __init__(self):
85
+        self.btc=0
86
+        self.etg=0
87
+        self.mgn=0
88
+        return
89
+    
90
+
91
+def fees_btc(nbr_transaction_btc):
92
+    """
93
+    Cette fonction calcule une version simplifié des frais de transaction
94
+    """
95
+    # Dans un premier temps je vais prendre pour valeur pour valeur de transfere :
96
+    # 20sat/byte
97
+    # On simplifie aussi en considerant qu'on a 1 input et 1 output
98
+    fees_btc = (nbr_transaction_btc*180 + 40 + nbr_transaction_btc)*20
99
+    return fees_btc
100
+
101
+def fees_eth(nbr_transaction_eth):
102
+    return
103
+
104
+def fees_mgn(nbr_transaction_mgn):
105
+    return
106
+

+ 5 - 3
main.py View File

@@ -2,9 +2,11 @@
2 2
 import math
3 3
 import numpy as np
4 4
 import pandas as pd
5
-import MagnaSim
6
-pop = MagnaSim.Populations(10)
7
-
5
+import MagnaSim as MaSi
6
+pop = MaSi.Populations(10)
7
+trans = MaSi.Transaction()
8 8
 for i in pop.population:
9 9
     x = np.random.normal(i.magna_wallet_btc[0],i.magna_wallet_btc[1])
10
+    trans.btc+=1
10 11
     print(abs(x))
12
+print("Nombre de BTC : {:f}".format(MaSi.fees_btc(trans.btc)*0.0000001))