Skip to content

Commit

Permalink
Bug fixes and code optimizations.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rapmd73 committed Oct 1, 2024
1 parent e9eb2c8 commit b371700
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 57 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.990"
Version="0.0.0.1.995"
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 @@ -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'
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.990"
Version="0.0.0.1.995"
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.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', \
Expand Down
64 changes: 13 additions & 51 deletions Base/Library/JRRoanda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

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.990"
self.Version="0.0.0.1.995"
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 @@ -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='<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.Directories={}
self.Directories['Base']='/home/JackrabbitRelay2/Base'
Expand Down

0 comments on commit b371700

Please sign in to comment.