diff --git a/Base/JackrabbitLocker b/Base/JackrabbitLocker index 9984368..f4a9d6c 100755 --- a/Base/JackrabbitLocker +++ b/Base/JackrabbitLocker @@ -28,7 +28,7 @@ import json import JRRsupport -Version="0.0.0.1.400" +Version="0.0.0.1.425" BaseDirectory='/home/JackrabbitRelay2/Base' ConfigDirectory='/home/JackrabbitRelay2/Config' LogDirectory="/home/JackrabbitRelay2/Logs" diff --git a/Base/JackrabbitOliverTwist b/Base/JackrabbitOliverTwist index d1c7c86..89d6294 100755 --- a/Base/JackrabbitOliverTwist +++ b/Base/JackrabbitOliverTwist @@ -38,7 +38,7 @@ import subprocess import JRRsupport import JackrabbitRelay as JRR -Version="0.0.0.1.400" +Version="0.0.0.1.425" BaseDirectory='/home/JackrabbitRelay2/Base' DataDirectory='/home/JackrabbitRelay2/Data' ConfigDirectory='/home/JackrabbitRelay2/Config' diff --git a/Base/JackrabbitRelay b/Base/JackrabbitRelay index 74b1a60..09b93be 100755 --- a/Base/JackrabbitRelay +++ b/Base/JackrabbitRelay @@ -16,7 +16,7 @@ import json import JRRsupport -Version="0.0.0.1.400" +Version="0.0.0.1.425" BaseDirectory='/home/JackrabbitRelay2/Base' ConfigDirectory='/home/JackrabbitRelay2/Config' LogDirectory="/home/JackrabbitRelay2/Logs" diff --git a/Base/Library/JRRccxt.py b/Base/Library/JRRccxt.py index 6d2598a..193d16b 100755 --- a/Base/Library/JRRccxt.py +++ b/Base/Library/JRRccxt.py @@ -314,54 +314,45 @@ def GetOHLCV(self,**kwargs): return self.Results def GetTicker(self,**kwargs): - if self.Broker.has['fetchTickers']==False: - symbol=kwargs.get('symbol') - tf=list(self.Broker.timeframes.keys())[0] - ohlcv=self.GetOHLCV(symbol=symbol,timeframe=tf,limit=1) - if ohlcv==[]: - bid=0 - ask=0 - else: - bid=ohlcv[0][4] - ask=ohlcv[0][1] - else: + # Best case situation, exchange has a ticker api. + + if self.Broker.has['fetchTickers']==True: self.Results=self.API("fetch_ticker",**kwargs) + print(self.Results) bid=self.Results['bid'] ask=self.Results['ask'] - # Last resort - o=self.Results['open'] - c=self.Results['close'] - - # Kucoin/Binance system doesn't always give complete data - # This is an absolute crap way of faking it, but the only way I've come up with. + else: + # Worst case situation, pull the orderbook. takes at least 5 seconds. + symbol=kwargs.get('symbol') + ob=self.GetOrderBook(symbol=symbol) + if (ob['bids']==None or ob['bids']==[]): + if (ob['asks']==None or ob['asks']==[]): + bid=None + else: + bid=ob['asks'][0][0] + else: + bid=ob['bids'][0][0] - if (bid==None or ask==None): - # Worst case situation, pull the orderbook. takes at least 5 seconds. - symbol=kwargs.get('symbol') - ob=self.GetOrderBook(symbol=symbol) + if (ob['asks']==None or ob['asks']==[]): if (ob['bids']==None or ob['bids']==[]): - if (ob['asks']==None or ob['asks']==[]): - bid=None - else: - bid=ob['asks'][0][0] + ask=None else: - bid=ob['bids'][0][0] + ask=ob['bids'][0][0] + else: + ask=ob['asks'][0][0] - if (ob['asks']==None or ob['asks']==[]): - if (ob['bids']==None or ob['bids']==[]): - ask=None - else: - ask=ob['bids'][0][0] - else: - ask=ob['asks'][0][0] + # Absolute worst case situation, orderbook is empty... Thank you ALPACA - if (bid==None or ask==None): - if o!=None and c!=None: - bid=max(o,c) - ask=min(o,c) - else: + if bid==None or ask==None: + symbol=kwargs.get('symbol') + tf=list(self.Broker.timeframes.keys())[0] + ohlcv=self.GetOHLCV(symbol=symbol,timeframe=tf,limit=1) + if ohlcv==[]: bid=0 ask=0 + else: + bid=ohlcv[0][4] + ask=ohlcv[0][1] Pair={} Pair['DateTime']=datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') @@ -400,7 +391,7 @@ def GetOpenTrades(self,**kwargs): # symbol, type, side (action), amount, price, params # PlaceOrder(exchange, Active, pair=pair, orderType=orderType, - # action=action, amount=amount, close=close, ReduceOnly=ReduceOnly, + # action=action, amount=amount, close=close, ReduceOnly=ReduceOnly, # LedgerNote=ledgerNote) def PlaceOrder(self,**kwargs): diff --git a/Base/Library/JackrabbitRelay.py b/Base/Library/JackrabbitRelay.py index 321d73e..d7fcd38 100755 --- a/Base/Library/JackrabbitRelay.py +++ b/Base/Library/JackrabbitRelay.py @@ -104,7 +104,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.400" + self.Version="0.0.0.1.425" self.NOhtml='