From b371700cb3746d7f7e9cbd4e50f4ce1960109c23 Mon Sep 17 00:00:00 2001 From: Rose Heart Date: Tue, 1 Oct 2024 23:07:49 +0000 Subject: [PATCH] Bug fixes and code optimizations. Changes to be committed: modified: Base/JackrabbitLocker modified: Base/JackrabbitOliverTwist modified: Base/JackrabbitRelay modified: Base/Library/JRRmimic.py modified: Base/Library/JRRoanda.py modified: Base/Library/JackrabbitProxy.py modified: Base/Library/JackrabbitRelay.py --- Base/JackrabbitLocker | 2 +- Base/JackrabbitOliverTwist | 2 +- Base/JackrabbitRelay | 2 +- Base/Library/JRRmimic.py | 2 +- Base/Library/JRRoanda.py | 64 +++++++-------------------------- Base/Library/JackrabbitProxy.py | 2 +- Base/Library/JackrabbitRelay.py | 2 +- 7 files changed, 19 insertions(+), 57 deletions(-) diff --git a/Base/JackrabbitLocker b/Base/JackrabbitLocker index 321c56a..16d031d 100755 --- a/Base/JackrabbitLocker +++ b/Base/JackrabbitLocker @@ -28,7 +28,7 @@ import json import JRRsupport -Version="0.0.0.1.990" +Version="0.0.0.1.995" BaseDirectory='/home/JackrabbitRelay2/Base' ConfigDirectory='/home/JackrabbitRelay2/Config' LogDirectory="/home/JackrabbitRelay2/Logs" diff --git a/Base/JackrabbitOliverTwist b/Base/JackrabbitOliverTwist index 9b713a9..19c7f68 100755 --- a/Base/JackrabbitOliverTwist +++ b/Base/JackrabbitOliverTwist @@ -60,7 +60,7 @@ import subprocess import JRRsupport import JackrabbitRelay as JRR -Version="0.0.0.1.990" +Version="0.0.0.1.995" BaseDirectory='/home/JackrabbitRelay2/Base' DataDirectory='/home/JackrabbitRelay2/Data' ConfigDirectory='/home/JackrabbitRelay2/Config' diff --git a/Base/JackrabbitRelay b/Base/JackrabbitRelay index 452cdbb..753a1e9 100755 --- a/Base/JackrabbitRelay +++ b/Base/JackrabbitRelay @@ -16,7 +16,7 @@ import json import JRRsupport -Version="0.0.0.1.990" +Version="0.0.0.1.995" 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 fd43f29..5fe28a4 100755 --- 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.990" + self.Version="0.0.0.1.995" self.StableCoinUSD=['USDT','USDC','BUSD','UST','DAI','FRAX','TUSD', \ 'USDP','LUSD','USDN','HUSD','FEI','TRIBE','RSR','OUSD','XSGD', \ diff --git a/Base/Library/JRRoanda.py b/Base/Library/JRRoanda.py index a84d61d..e49a500 100755 --- a/Base/Library/JRRoanda.py +++ b/Base/Library/JRRoanda.py @@ -200,68 +200,30 @@ def GetPositions(self,**kwargs): # Get candlestick (OHLCV) data def GetOHLCV(self,**kwargs): - RFC3339="%Y-%m-%dT%H:%M:%SZ" symbol=kwargs.get('symbol').replace('/','_') pair=symbol.replace('_','') timeframe=kwargs.get('timeframe') limit=str(kwargs.get('limit',None)) - tffrom=str(kwargs.get('tffrom',None)) - tfto=str(kwargs.get('tfto',None)) - stime=None - etime=None if limit!=None and limit!="None": params={"granularity":timeframe.upper(), "count":limit } - elif tffrom!=None: - stime=v20Generic.secs2time(int(tffrom)/1000).strftime(RFC3339) - if limit==None or limit=="None": - limit=5000 - if tfto==None or tfto=="None": - etime=v20Generic.secs2time(time.time()).strftime(RFC3339) - else: - etime=v20Generic.secs2time(int(tfto)/1000).strftime(RFC3339) - params={"granularity":timeframe.upper(), "from":stime, "to":etime, "count":limit } candles=[] self.SetPipValue(symbol) - if 'from' not in params: - res=v20Instruments.InstrumentsCandles(instrument=symbol,params=params) - self.Results=self.API("GetOHLCV",request=res) - - for cur in self.Results['candles']: - candle=[] - candle.append(int(datetime.strptime(cur['time'],'%Y-%m-%dT%H:%M:%S.000000000Z').timestamp())*1000) - candle.append(float(cur['mid']['o'])) - candle.append(float(cur['mid']['h'])) - candle.append(float(cur['mid']['l'])) - candle.append(float(cur['mid']['c'])) - candle.append(float(cur['volume'])) - candles.append(candle) - return candles - else: - # Fetch full history. This will NOT be fast as S5 goes back to 2005... - - # Too big for memory so save in Data Directory. I'm going this way because I need ratelimit and - # retry functionality already built into Relay. This will have to be written to disk and post - # processed. - - ParamList=v20Factories.InstrumentsCandlesFactory(instrument=symbol,params=params) - fn=f"{self.DataDirectory}/{pair}.{timeframe}.csv" - for r in ParamList: - sParams=r.__dict__['params'] - result=v20Instruments.InstrumentsCandles(instrument=symbol,params=sParams) - res=self.API("GetOHLCV",request=result) - - for cur in res['candles']: - dt=int(datetime.strptime(cur['time'],'%Y-%m-%dT%H:%M:%S.000000000Z').timestamp())*1000 - o=float(cur['mid']['o']) - h=float(cur['mid']['h']) - l=float(cur['mid']['l']) - c=float(cur['mid']['c']) - v=float(cur['volume']) - JRRsupport.AppendFile(fn,f'{dt},{o:.5f},{h:.5f},{l:.5f},{c:.5f},{v:.5f}\n') - return fn + res=v20Instruments.InstrumentsCandles(instrument=symbol,params=params) + self.Results=self.API("GetOHLCV",request=res) + + for cur in self.Results['candles']: + candle=[] + candle.append(int(datetime.strptime(cur['time'],'%Y-%m-%dT%H:%M:%S.000000000Z').timestamp())*1000) + candle.append(float(cur['mid']['o'])) + candle.append(float(cur['mid']['h'])) + candle.append(float(cur['mid']['l'])) + candle.append(float(cur['mid']['c'])) + candle.append(float(cur['volume'])) + candles.append(candle) + return candles # Get the bid/ask values of the curent ticker diff --git a/Base/Library/JackrabbitProxy.py b/Base/Library/JackrabbitProxy.py index 3b318d9..f52cdb8 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.990" + self.Version="0.0.0.1.995" 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 e88b3a8..ab7a5fb 100755 --- a/Base/Library/JackrabbitRelay.py +++ b/Base/Library/JackrabbitRelay.py @@ -110,7 +110,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,RaiseError=False): # All the default locations - self.Version="0.0.0.1.990" + self.Version="0.0.0.1.995" self.NOhtml='NO!

NO!

' self.Directories={} self.Directories['Base']='/home/JackrabbitRelay2/Base'