Skip to content

Commit

Permalink
**IMPORTANT**: Be sure to run UpdatePlaceOrder with your exchanges, e…
Browse files Browse the repository at this point in the history
…xcept Oanda and Mimic.

Bug fix in PCT table with position flipping fixed.

Changes to be committed:
	modified:   Base/CCXT-PlaceOrder.future
	modified:   Base/CCXT-PlaceOrder.margin
	modified:   Base/CCXT-PlaceOrder.swap
	modified:   Base/MIMIC-PlaceOrder
	modified:   Base/OANDA-PlaceOrder
  • Loading branch information
rapmd73 committed May 16, 2024
1 parent 8f251ae commit f1c1e59
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Base/CCXT-PlaceOrder.future
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion Base/CCXT-PlaceOrder.margin
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion Base/CCXT-PlaceOrder.swap
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion Base/MIMIC-PlaceOrder
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions Base/OANDA-PlaceOrder
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'])
Expand Down

0 comments on commit f1c1e59

Please sign in to comment.