From a28ca1c7c43152f6580d6c71811ef0a3059d38bd Mon Sep 17 00:00:00 2001 From: Rose Heart Date: Sat, 11 May 2024 17:32:51 +0000 Subject: [PATCH] Bug fixes. 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 --- Base/JackrabbitLocker | 2 +- Base/JackrabbitOliverTwist | 2 +- Base/JackrabbitRelay | 2 +- Base/Library/JRRmimic.py | 2 +- Base/Library/JackrabbitProxy.py | 2 +- Base/Library/JackrabbitRelay.py | 2 +- Extras/Mimic/WalletInspect | 72 ++++++++++++++++++++------------- 7 files changed, 49 insertions(+), 35 deletions(-) diff --git a/Base/JackrabbitLocker b/Base/JackrabbitLocker index c7b7410..002e3f4 100755 --- a/Base/JackrabbitLocker +++ b/Base/JackrabbitLocker @@ -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" diff --git a/Base/JackrabbitOliverTwist b/Base/JackrabbitOliverTwist index 2f764e2..fb30bfc 100755 --- a/Base/JackrabbitOliverTwist +++ b/Base/JackrabbitOliverTwist @@ -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' diff --git a/Base/JackrabbitRelay b/Base/JackrabbitRelay index 54dc978..321486d 100755 --- a/Base/JackrabbitRelay +++ b/Base/JackrabbitRelay @@ -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" diff --git a/Base/Library/JRRmimic.py b/Base/Library/JRRmimic.py index 707b7e2..42b3d77 100644 --- a/Base/Library/JRRmimic.py +++ b/Base/Library/JRRmimic.py @@ -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', \ diff --git a/Base/Library/JackrabbitProxy.py b/Base/Library/JackrabbitProxy.py index a79e5d0..cc1c746 100755 --- a/Base/Library/JackrabbitProxy.py +++ b/Base/Library/JackrabbitProxy.py @@ -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" diff --git a/Base/Library/JackrabbitRelay.py b/Base/Library/JackrabbitRelay.py index ffc6d49..e8918aa 100755 --- a/Base/Library/JackrabbitRelay.py +++ b/Base/Library/JackrabbitRelay.py @@ -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='NO!

NO!

' self.BaseDirectory='/home/JackrabbitRelay2/Base' self.ConfigDirectory='/home/JackrabbitRelay2/Config' diff --git a/Extras/Mimic/WalletInspect b/Extras/Mimic/WalletInspect index d461dab..104c25d 100755 --- a/Extras/Mimic/WalletInspect +++ b/Extras/Mimic/WalletInspect @@ -32,7 +32,6 @@ if not os.path.exists(acn): lines=JRRsupport.ReadFile(acn).strip().split('\n') fees={} -cnr={} Wallet={} for line in lines: @@ -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()