diff --git a/Base/CCXT-PlaceOrder.future b/Base/CCXT-PlaceOrder.future index 25bb0fe..dd33e11 100755 --- a/Base/CCXT-PlaceOrder.future +++ b/Base/CCXT-PlaceOrder.future @@ -49,7 +49,7 @@ def GetPCTvalue(pct,close,bal): def GetPCTamount(relay,currency,quote,close): fn=relay.Directories['Data']+'/'+relay.Exchange+'.'+relay.Account+'.PCTtable' PCTtable=JRRsupport.TimedList("PCTtable",fn,Log=relay.JRLog) - if relay.Order['Action'].lower()=='close': + if relay.Order['Action'].lower()=='close' or relay.Order['Action'].lower()=='flip': expire=0 else: expire=(3650*86400) @@ -71,6 +71,8 @@ def GetPCTamount(relay,currency,quote,close): payload=json.loads(results['Payload']['Payload'],strict=False) amount=payload['Amount'] + if (pct<0 and amount>0) or (pct>0 and amount<0): + amount=amount*-1 else: bal=relay.GetBalance(Base=quote) amount=round(((float(relay.Order[currency].replace('%',''))/100)*bal)/close,8) diff --git a/Base/CCXT-PlaceOrder.margin b/Base/CCXT-PlaceOrder.margin index b0cf046..c5105f7 100755 --- a/Base/CCXT-PlaceOrder.margin +++ b/Base/CCXT-PlaceOrder.margin @@ -49,7 +49,7 @@ def GetPCTvalue(pct,close,bal): def GetPCTamount(relay,currency,quote,close): fn=relay.Directories['Data']+'/'+relay.Exchange+'.'+relay.Account+'.PCTtable' PCTtable=JRRsupport.TimedList("PCTtable",fn,Log=relay.JRLog) - if relay.Order['Action'].lower()=='close': + if relay.Order['Action'].lower()=='close' or relay.Order['Action'].lower()=='flip': expire=0 else: expire=(3650*86400) @@ -71,6 +71,8 @@ def GetPCTamount(relay,currency,quote,close): payload=json.loads(results['Payload']['Payload'],strict=False) amount=payload['Amount'] + if (pct<0 and amount>0) or (pct>0 and amount<0): + amount=amount*-1 else: bal=relay.GetBalance(Base=quote) amount=round(((float(relay.Order[currency].replace('%',''))/100)*bal)/close,8) diff --git a/Base/CCXT-PlaceOrder.swap b/Base/CCXT-PlaceOrder.swap index 52bc8ee..4777796 100755 --- a/Base/CCXT-PlaceOrder.swap +++ b/Base/CCXT-PlaceOrder.swap @@ -49,7 +49,7 @@ def GetPCTvalue(pct,close,bal): def GetPCTamount(relay,currency,quote,close): fn=relay.Directories['Data']+'/'+relay.Exchange+'.'+relay.Account+'.PCTtable' PCTtable=JRRsupport.TimedList("PCTtable",fn,Log=relay.JRLog) - if relay.Order['Action'].lower()=='close': + if relay.Order['Action'].lower()=='close' or relay.Order['Action'].lower()=='flip': expire=0 else: expire=(3650*86400) @@ -71,6 +71,8 @@ def GetPCTamount(relay,currency,quote,close): payload=json.loads(results['Payload']['Payload'],strict=False) amount=payload['Amount'] + if (pct<0 and amount>0) or (pct>0 and amount<0): + amount=amount*-1 else: bal=relay.GetBalance(Base=quote) amount=round(((float(relay.Order[currency].replace('%',''))/100)*bal)/close,8) diff --git a/Base/MIMIC-PlaceOrder b/Base/MIMIC-PlaceOrder index 21fb301..83391bd 100755 --- a/Base/MIMIC-PlaceOrder +++ b/Base/MIMIC-PlaceOrder @@ -49,7 +49,7 @@ def GetPCTvalue(pct,close,bal): def GetPCTamount(relay,currency,quote,close): fn=relay.Directories['Data']+'/'+relay.Exchange+'.'+relay.Account+'.PCTtable' PCTtable=JRRsupport.TimedList("PCTtable",fn,Log=relay.JRLog) - if relay.Order['Action'].lower()=='close': + if relay.Order['Action'].lower()=='close' or relay.Order['Action'].lower()=='flip': expire=0 else: expire=(3650*86400) @@ -71,6 +71,8 @@ def GetPCTamount(relay,currency,quote,close): payload=json.loads(results['Payload']['Payload'],strict=False) amount=payload['Amount'] + if (pct<0 and amount>0) or (pct>0 and amount<0): + amount=amount*-1 else: bal=relay.GetBalance(Base=quote) amount=round(((float(relay.Order[currency].replace('%',''))/100)*bal)/close,8) diff --git a/Base/OANDA-PlaceOrder b/Base/OANDA-PlaceOrder index c814419..1976110 100755 --- a/Base/OANDA-PlaceOrder +++ b/Base/OANDA-PlaceOrder @@ -33,13 +33,12 @@ def GetPCTtype(currency): def GetPCTvalue(pct,close,bal,mr): volume=round(((pct/100)*bal),8) amount=round((volume/close)/mr,8) - return amount,volume def GetPCTamount(relay,close): fn=relay.Directories['Data']+'/'+relay.Exchange+'.'+relay.Account+'.PCTtable' PCTtable=JRRsupport.TimedList("PCTtable",fn,Log=relay.JRLog) - if relay.Order['Action'].lower()=='close': + if relay.Order['Action'].lower()=='close' or relay.Order['Action'].lower()=='flip': expire=0 else: expire=(3650*86400) @@ -62,6 +61,8 @@ def GetPCTamount(relay,close): payload=json.loads(results['Payload']['Payload'],strict=False) amount=payload['Amount'] + if (pct<0 and amount>0) or (pct>0 and amount<0): + amount=amount*-1 else: bal=relay.GetBalance() mr=float(relay.Markets[relay.Asset]['marginRate'])