Skip to content

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
Issues with Mimic wallets resolved (I hope).

Code Optimizations and diagnostics code removed.

Version update.

Changes to be committed:
	modified:   Base/JackrabbitLocker
	modified:   Base/JackrabbitOliverTwist
	modified:   Base/JackrabbitRelay
	modified:   Base/Library/JRRmimic.py
	modified:   Base/Library/JackrabbitProxy.py
	modified:   Base/Library/JackrabbitRelay.py
	modified:   Extras/Mimic/WalletInspect
  • Loading branch information
rapmd73 committed May 11, 2024
1 parent 68ffa6d commit a28ca1c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Base/JackrabbitLocker
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import json

import JRRsupport

Version="0.0.0.1.835"
Version="0.0.0.1.840"
BaseDirectory='/home/JackrabbitRelay2/Base'
ConfigDirectory='/home/JackrabbitRelay2/Config'
LogDirectory="/home/JackrabbitRelay2/Logs"
Expand Down
2 changes: 1 addition & 1 deletion Base/JackrabbitOliverTwist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import subprocess
import JRRsupport
import JackrabbitRelay as JRR

Version="0.0.0.1.835"
Version="0.0.0.1.840"
BaseDirectory='/home/JackrabbitRelay2/Base'
DataDirectory='/home/JackrabbitRelay2/Data'
ConfigDirectory='/home/JackrabbitRelay2/Config'
Expand Down
2 changes: 1 addition & 1 deletion Base/JackrabbitRelay
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import json

import JRRsupport

Version="0.0.0.1.835"
Version="0.0.0.1.840"
BaseDirectory='/home/JackrabbitRelay2/Base'
ConfigDirectory='/home/JackrabbitRelay2/Config'
LogDirectory="/home/JackrabbitRelay2/Logs"
Expand Down
2 changes: 1 addition & 1 deletion Base/Library/JRRmimic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class mimic:
# placed in init and released at exit.

def __init__(self,Exchange,Config,Active,DataDirectory=None):
self.Version="0.0.0.1.835"
self.Version="0.0.0.1.840"

self.StableCoinUSD=['USDT','USDC','BUSD','UST','DAI','FRAX','TUSD', \
'USDP','LUSD','USDN','HUSD','FEI','TRIBE','RSR','OUSD','XSGD', \
Expand Down
2 changes: 1 addition & 1 deletion Base/Library/JackrabbitProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
class JackrabbitProxy:
def __init__(self,framework=None,payload=None,exchange=None,account=None,asset=None,Usage=None):
# All the default locations
self.Version="0.0.0.1.835"
self.Version="0.0.0.1.840"
self.BaseDirectory='/home/JackrabbitRelay2/Base'
self.ConfigDirectory='/home/JackrabbitRelay2/Config'
self.DataDirectory="/home/JackrabbitRelay2/Data"
Expand Down
2 changes: 1 addition & 1 deletion Base/Library/JackrabbitRelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def Success(self,f,s):
class JackrabbitRelay:
def __init__(self,framework=None,payload=None,exchange=None,account=None,asset=None,secondary=None,NoIdentityVerification=False,Usage=None):
# All the default locations
self.Version="0.0.0.1.835"
self.Version="0.0.0.1.840"
self.NOhtml='<html><title>NO!</title><body style="background-color:#ffff00;display:flex;weight:100vw;height:100vh;align-items:center;justify-content:center"><h1 style="color:#ff0000;font-weight:1000;font-size:10rem">NO!</h1></body></html>'
self.BaseDirectory='/home/JackrabbitRelay2/Base'
self.ConfigDirectory='/home/JackrabbitRelay2/Config'
Expand Down
72 changes: 43 additions & 29 deletions Extras/Mimic/WalletInspect
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ if not os.path.exists(acn):
lines=JRRsupport.ReadFile(acn).strip().split('\n')

fees={}
cnr={}
Wallet={}

for line in lines:
Expand All @@ -47,47 +46,62 @@ for line in lines:
sys.exit(1)

asset=data['Asset']
base,quote=asset.split('/')
if ':' in asset:
quote=asset.split(':')[1]
if '-' in quote:
quote=quote.split('-')[0]

dt=data['DateTime']
act=data['Action'].upper()[0]
bw=float(data[base])
qw=float(data[quote])
a=float(data['Amount'])
p=float(data['Price'])
f=float(data['Fee'])

if data['Asset'] not in cnr:
cnr[data['Asset']]=0

if data['Asset'] not in Wallet:
Wallet[data['Asset']]=[]

if data['Asset'] not in fees:
fees[data['Asset']]=0

if act=='B':
if bw!=0:
cnr[data['Asset']]-=abs(p*a)
else:
cnr[data['Asset']]+=abs(p*a)
elif act=='S':
cnr[data['Asset']]+=abs(p*a)

fees[data['Asset']]+=f

str=f"{dt} {act} {bw:14.8f} {qw:14.8f} {a:14.8f} {p:.8f} {f:.8f} {cnr[data['Asset']]:14.8f}"
Wallet[data['Asset']].append(str)
Wallet[data['Asset']].append(line)

for pair in sorted(Wallet.keys()):
if len(sys.argv)>2 and sys.argv[2]!=pair:
continue

print(f"{pair}: {fees[pair]:.8f} paid in fees")
for l in Wallet[pair]:
print(f" {l}")

# This will become the initial balance of the wallet.
balance=0

# Scan thie current pair
for line in Wallet[pair]:
try:
data=json.loads(line)
except:
print("Line damaged:")
print(f" {line}")
sys.exit(1)

asset=data['Asset']
base,quote=asset.split('/')
if ':' in asset:
quote=asset.split(':')[1]
if '-' in quote:
quote=quote.split('-')[0]

dt=data['DateTime']
act=data['Action'].upper()[0]
bw=float(data[base])
qw=float(data[quote])
a=float(data['Amount'])
p=float(data['Price'])
f=float(data['Fee'])

if balance==0:
balance=qw+f+(abs(bw)*p)

pnl=(qw+(abs(bw)*p))-balance
"""
if act=='B':
pnl=(qw+(abs(bw)*p)+f)-balance
elif act=='S':
pnl=(qw+(abs(bw)*p)+(abs(a)*p)+f)-balance
"""

str=f" {dt} {act} {bw:14.8f} {qw:14.8f} {a:14.8f} {p:.8f} {f:.8f} {pnl:.8f}"
print(str)

print()

0 comments on commit a28ca1c

Please sign in to comment.