File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,8 +88,13 @@ for line in lines:
8888
8989 if balance == 0 :
9090 balance = qw + f + (abs (bw )* p )
91+ pnl = balance
9192
92- pnl = (qw + (abs (bw )* p ))- balance
93+ # pnl=(qw+(abs(bw)*p))-balance
94+ if act == 'B' :
95+ pnl -= (abs (a )* p )+ f
96+ else :
97+ pnl += (abs (a )* p )- f
9398
9499 xps .append (dt )
95100 if base not in StableCoinUSD :
Original file line number Diff line number Diff line change @@ -93,9 +93,13 @@ for pair in sorted(Wallet.keys()):
9393 if balance == 0 :
9494 balance = qw + f + (abs (bw )* p )
9595
96- pnl = (qw + (abs (bw )* p ))- f
96+ # pnl=(qw+(abs(bw)*p))-f-balance
97+ if act == 'B' :
98+ balance -= (abs (a )* p )+ f
99+ else :
100+ balance += (abs (a )* p )- f
97101
98- str = f" { dt } { act } { bw :14.8f} { qw :14.8f} { a :14.8f} { p :.8f} { f :.8f} { pnl :.8f} "
102+ str = f" { dt } { act } { bw :14.8f} { qw :14.8f} { a :14.8f} { p :.8f} { f :.8f} { balance :.8f} "
99103 print (str )
100104
101105 print ()
Original file line number Diff line number Diff line change @@ -57,12 +57,22 @@ for line in lines:
5757
5858 Wallet [data ['Asset' ]].append (line )
5959
60+ maxbuys = 0
61+ maxsells = 0
62+ maxfees = 0
63+ maxbal = 0
64+ maxpmax = 0
65+
6066for pair in sorted (Wallet .keys ()):
6167 if len (sys .argv )> 2 and sys .argv [2 ]!= pair :
6268 continue
6369
6470 # This will become the initial balance of the wallet.
6571 balance = 0
72+ buys = 0
73+ sells = 0
74+ maxpos = 0
75+ curpos = 0
6676
6777 # Scan thie current pair
6878 for line in Wallet [pair ]:
@@ -82,17 +92,39 @@ for pair in sorted(Wallet.keys()):
8292
8393 dt = data ['DateTime' ]
8494 act = data ['Action' ].upper ()[0 ]
85- bw = float (data [base ])
86- qw = float (data [quote ])
95+ bw = float (data [base ]) # base wallet
96+ qw = float (data [quote ]) # quote wallet
8797 a = float (data ['Amount' ])
8898 p = float (data ['Price' ])
8999 f = float (data ['Fee' ])
90100
91- if balance == 0 :
92- balance = qw + f + (abs (bw )* p )
101+ # if balance==0:
102+ # balance=qw+f+(abs(bw)*p)
103+
104+ # pnl=(qw+(abs(bw)*p))-f-balance
105+ if act == 'B' :
106+ balance -= (abs (a )* p )+ f
107+ buys += 1
108+ curpos += 1
109+ else :
110+ balance += (abs (a )* p )- f
111+ sells += 1
112+ curpos -= 1
113+ if curpos < 0 :
114+ curpos = 0
115+
116+ if curpos > maxpos :
117+ maxpos = curpos
118+
119+ # str=f" {dt} {act} {bw:14.8f} {qw:14.8f} {a:14.8f} {p:.8f} {f:.8f} {balance:.8f}"
120+ # print(str)
93121
94- pnl = (qw + (abs (bw )* p ))
122+ maxbal += balance
123+ maxbuys += buys
124+ maxsells += sells
125+ maxfees += fees [pair ]
126+ maxpmax += maxpos
95127
96- str = f"{ pair :16} { fees [pair ]:12.8f} { pnl :16.8f} "
97- print (str )
128+ print (f"{ pair :<16} { buys :5.0f} { sells :5.0f} { buys - sells :8.0f} { maxpos :4.0f} { fees [pair ]:16.8f} { balance :20.8f} " )
98129
130+ print (f"{ " " :16} { maxbuys :5.0f} { maxsells :5.0f} { maxbuys - maxsells :8.0f} { maxpmax :4.0f} { maxfees :16.8f} { maxbal :20.8f} " )
You can’t perform that action at this time.
0 commit comments