diff --git a/Base/Conditional.oanda b/Base/Conditional.oanda index 5cf616f..2b19dd0 100755 --- a/Base/Conditional.oanda +++ b/Base/Conditional.oanda @@ -75,7 +75,7 @@ def GetOrderID(res): # Calculate Price -def CalculatePriceExit(order,ts,dir,price): +def CalculatePriceExit(order,ts,dir,price,onePip): # Figure out TakeProfit or Stoploss if ts=='TakeProfit': if '%' in order[ts]: @@ -86,9 +86,9 @@ def CalculatePriceExit(order,ts,dir,price): # Pips elif 'p' in order[ts].lower(): if dir=='long': - val=price+(float(order[ts].lower().replace('p','').strip())*0.0001) + val=price+(float(order[ts].lower().replace('p','').strip())*onePip) else: - val=price-(float(order[ts].lower().replace('p','').strip())*0.0001) + val=price-(float(order[ts].lower().replace('p','').strip())*onePip) else: val=float(order[ts]) elif ts=='StopLoss': @@ -100,9 +100,9 @@ def CalculatePriceExit(order,ts,dir,price): # Pips elif 'p' in order[ts].lower(): if dir=='long': - val=price-(float(order[ts].lower().replace('p','').strip())*0.0001) + val=price-(float(order[ts].lower().replace('p','').strip())*onePip) else: - val=price+(float(order[ts].lower().replace('p','').strip())*0.0001) + val=price+(float(order[ts].lower().replace('p','').strip())*onePip) else: val=float(order[ts]) @@ -199,11 +199,11 @@ def main(): if 'TakeProfit' not in relay.Order: relay.Order['TakeProfit']='10p' # Calculate Take Profit - tp=round(CalculatePriceExit(relay.Order,'TakeProfit',dir,price),5) + tp=round(CalculatePriceExit(relay.Order,'TakeProfit',dir,price,relay.Broker.onePip),5) # Figure out StopLoss, if there is one if 'StopLoss' in relay.Order: - sl=round(CalculatePriceExit(relay.Order,'StopLoss',dir,price),5) + sl=round(CalculatePriceExit(relay.Order,'StopLoss',dir,price,relay.Broker.onePip),5) # find trade open time parts=orderDetail[0]['time'].split('.') diff --git a/Base/JackrabbitLocker b/Base/JackrabbitLocker index 4eac076..1b4fe66 100755 --- a/Base/JackrabbitLocker +++ b/Base/JackrabbitLocker @@ -28,7 +28,7 @@ import json import JRRsupport -Version="0.0.0.1.455" +Version="0.0.0.1.460" BaseDirectory='/home/JackrabbitRelay2/Base' ConfigDirectory='/home/JackrabbitRelay2/Config' LogDirectory="/home/JackrabbitRelay2/Logs" diff --git a/Base/JackrabbitOliverTwist b/Base/JackrabbitOliverTwist index bd44a8d..1942be9 100755 --- a/Base/JackrabbitOliverTwist +++ b/Base/JackrabbitOliverTwist @@ -38,7 +38,7 @@ import subprocess import JRRsupport import JackrabbitRelay as JRR -Version="0.0.0.1.455" +Version="0.0.0.1.460" BaseDirectory='/home/JackrabbitRelay2/Base' DataDirectory='/home/JackrabbitRelay2/Data' ConfigDirectory='/home/JackrabbitRelay2/Config' diff --git a/Base/JackrabbitRelay b/Base/JackrabbitRelay index 96ea918..39d20e8 100755 --- a/Base/JackrabbitRelay +++ b/Base/JackrabbitRelay @@ -16,7 +16,7 @@ import json import JRRsupport -Version="0.0.0.1.455" +Version="0.0.0.1.460" BaseDirectory='/home/JackrabbitRelay2/Base' ConfigDirectory='/home/JackrabbitRelay2/Config' LogDirectory="/home/JackrabbitRelay2/Logs" diff --git a/Base/Library/JRRoanda.py b/Base/Library/JRRoanda.py index e18626c..4e9ab56 100644 --- a/Base/Library/JRRoanda.py +++ b/Base/Library/JRRoanda.py @@ -68,6 +68,18 @@ def __init__(self,Exchange,Config,Active,DataDirectory=None): self.Currency=None self.Markets=self.GetMarkets() + self.onePip=None + + # Set the value of one pip + + def SetPipValue(self,asset): + # Value needed to calculate 1 pip for this pair + if self.onePip==None: + if abs(float(self.Markets[asset.replace('_','/')]['pipLocation']))==2: + self.onePip=0.01 + else: + self.onePip=0.0001 + # Handle the retry functionality and send the request to the broker. def API(self,function,**kwargs): @@ -169,6 +181,7 @@ def GetPositions(self,**kwargs): for pos in self.Results['positions']: asset=pos['instrument'].replace('_','/') if symbol==asset: + self.SetPipValue(symbol) if 'averagePrice' in pos['long']: units=int(pos['long']['units']) position=float(pos['long']['averagePrice'])*units @@ -189,6 +202,7 @@ def GetOHLCV(self,**kwargs): limit=str(kwargs.get('limit')) params={"granularity":timeframe.upper(), "count":limit } candles=[] + self.SetPipValue(symbol) res=v20Instruments.InstrumentsCandles(instrument=symbol,params=params) self.Results=self.API("GetOHLCV",request=res) @@ -208,6 +222,7 @@ def GetOHLCV(self,**kwargs): def GetTicker(self,**kwargs): symbol=kwargs.get('symbol').replace('/','_') params={"instruments":symbol } + self.SetPipValue(symbol) res=v20Pricing.PricingInfo(accountID=self.AccountID,params=params) self.Results=self.API("GetTicker",request=res) @@ -230,6 +245,7 @@ def GetTicker(self,**kwargs): def GetOrderBook(self,**kwargs): symbol=kwargs.get('symbol').replace('/','_') + self.SetPipValue(symbol) req=v20Instruments.InstrumentsOrderBook(instrument=symbol,params={}) self.Results=self.API("GetOrderBook",request=req,noError=True) @@ -255,6 +271,7 @@ def GetOpenOrders(self,**kwargs): if symbol==order['instrument']: oList.append(order) + self.SetPipValue(symbol) return oList # As references in GetPosition, a position may consist of one or more actual @@ -263,6 +280,7 @@ def GetOpenOrders(self,**kwargs): def GetOpenTrades(self,**kwargs): symbol=kwargs.get('symbol').replace('/','_') params={"instrument":symbol } + self.SetPipValue(symbol) req=v20Trades.TradesList(accountID=self.AccountID,params=params) self.Results=self.API("GetOpenTrades",request=req) @@ -420,6 +438,7 @@ def PlaceOrder(self,**kwargs): def GetMinimum(self,**kwargs): symbol=kwargs.get('symbol') + self.SetPipValue(symbol) minimum=1 mincost=self.GetTicker(symbol=symbol)['Ask'] diff --git a/Base/Library/JackrabbitRelay.py b/Base/Library/JackrabbitRelay.py index 680728f..9f37e24 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.455" + self.Version="0.0.0.1.460" self.NOhtml='