From bb06da5c70f7156b4259a4260a42e8bffdd06942 Mon Sep 17 00:00:00 2001 From: Rose Heart Date: Thu, 2 May 2024 14:23:52 +0000 Subject: [PATCH] Bug fix in shorting for Mimic and crypto. Changes to be committed: modified: Base/Library/CONDccxt.py modified: Base/Library/CONDmimic.py --- Base/Library/CONDccxt.py | 5 +++-- Base/Library/CONDmimic.py | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Base/Library/CONDccxt.py b/Base/Library/CONDccxt.py index 7b2a333..1664750 100755 --- a/Base/Library/CONDccxt.py +++ b/Base/Library/CONDccxt.py @@ -171,6 +171,7 @@ def OrderProcessor(Orphan): relay.JRLog.Write(LogMSG,stdOut=False) resp=relay.GetOrderDetails(id=oid,symbol=relay.Order['Asset']) # Order must be closed as it succedded + relay.JRLog.Write(json.dumps(resp),stdOut=False) sprice=float(resp['price']) # find trade close time and duration @@ -187,9 +188,9 @@ def OrderProcessor(Orphan): rpl=round((amount*price)-(amount*sprice),8) else: if spricesl: # ticker['Ask'] - rpl=round((amount*sprice)-(amount*price),8) + rpl=round((abs(amount)*sprice)-(abs(amount)*price),8) # rpl is reported by broker. This is the actual profit/loss of trade. if rpl>=0: diff --git a/Base/Library/CONDmimic.py b/Base/Library/CONDmimic.py index 0580873..66b5287 100755 --- a/Base/Library/CONDmimic.py +++ b/Base/Library/CONDmimic.py @@ -168,6 +168,7 @@ def OrderProcessor(Orphan): resp=relay.GetOrderDetails(id=oid,symbol=relay.Order['Asset']) # Order must be closed as it succedded newOrder['ID']=oid + relay.JRLog.Write(json.dumps(resp),stdOut=False) sprice=float(resp['Price']) # find trade close time and duration @@ -178,15 +179,15 @@ def OrderProcessor(Orphan): rpl=0 if dir=='long': - if sprice>tp: # ticker['Bid'] - rpl=round((amount*sprice)-(amount*price),8) - if sl!=0 and spricetp + rpl=round((abs(amount)*sprice)-(abs(amount)*price),8) + if sl!=0 and ticker['Bid']sl: # ticker['Ask'] - rpl=round((amount*sprice)-(amount*price),8) + if ticker['Ask']sl + rpl=round((abs(amount)*sprice)-(abs(amount)*price),8) # rpl is reported by broker. This is the actual profit/loss of trade. if rpl>=0: