Skip to content

Commit

Permalink
Mimic wallet bug fixes. Direction operation confusion sorted.
Browse files Browse the repository at this point in the history
Any value moving from quote to base is a buy (long or short), while any value moving from base to quote is a
sell. Quote is ALWAYS >= 0 or account is liquidated.

Version updated.

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 Mar 26, 2024
1 parent 083cf9d commit 21d0eeb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 16 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.780"
Version="0.0.0.1.785"
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.780"
Version="0.0.0.1.785"
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.780"
Version="0.0.0.1.785"
BaseDirectory='/home/JackrabbitRelay2/Base'
ConfigDirectory='/home/JackrabbitRelay2/Config'
LogDirectory="/home/JackrabbitRelay2/Logs"
Expand Down
14 changes: 4 additions & 10 deletions 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.780"
self.Version="0.0.0.1.785"

self.StableCoinUSD=['USDT','USDC','BUSD','UST','DAI','FRAX','TUSD', \
'USDP','LUSD','USDN','HUSD','FEI','TRIBE','RSR','OUSD','XSGD', \
Expand Down Expand Up @@ -271,16 +271,11 @@ def LiquidateWallet(self,asset,fee_rate=0):
else:
self.Wallet['Wallet'][quote]=total_proceeds # Initialize quote currency balance if not present

# Figure out liquidation direction
if amount>0:
action='sell'
else:
action='buy'
# Update successful
order={}
order['DateTime']=(datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
order['ID']=f"{time.time()*10000000:.0f}"
order['Action']=action
order['Action']='sell'
order['Asset']=asset
order[base]=self.Wallet['Wallet'][base]
order[quote]=self.Wallet['Wallet'][quote]
Expand Down Expand Up @@ -430,9 +425,8 @@ def UpdateWallet(self,action,asset,amount,price,fee_rate=0):

# CRITICAL:

# For position fliping
# if b>0, a<0: sell base, buy amount
# if b<0, a>0: buy bbase, sell amount
# Any value moving from quote to base is a buy.
# Any value moving from base to quote is a sell.

def PlaceOrder(self,**kwargs):
pair=kwargs.get('pair')
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.780"
self.Version="0.0.0.1.785"
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.780"
self.Version="0.0.0.1.785"
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
5 changes: 4 additions & 1 deletion Extras/Mimic/WalletInspect
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ for line in lines:
f=float(data['Fee'])

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

Expand Down

0 comments on commit 21d0eeb

Please sign in to comment.