Skip to content

Commit

Permalink
Bug fix in shorting for Mimic and crypto.
Browse files Browse the repository at this point in the history
Changes to be committed:
	modified:   Base/Library/CONDccxt.py
	modified:   Base/Library/CONDmimic.py
  • Loading branch information
rapmd73 committed May 2, 2024
1 parent c336a17 commit bb06da5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Base/Library/CONDccxt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -187,9 +188,9 @@ def OrderProcessor(Orphan):
rpl=round((amount*price)-(amount*sprice),8)
else:
if sprice<tp: # ticker['Ask']
rpl=round((amount*price)-(amount*sprice),8)
rpl=round((abs(amount)*price)-(abs(amount)*sprice),8)
if sl!=0 and sprice>sl: # 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:
Expand Down
17 changes: 9 additions & 8 deletions Base/Library/CONDmimic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 sprice<sl: # ticker['Bid']
rpl=round((amount*price)-(amount*sprice),8)
if ticker['Bid']>tp
rpl=round((abs(amount)*sprice)-(abs(amount)*price),8)
if sl!=0 and ticker['Bid']<sl
rpl=round((abs(amount)*price)-(abs(amount)*sprice),8)
else:
if sprice<tp: # ticker['Ask']
rpl=round((amount*price)-(amount*sprice),8)
if sl!=0 and sprice>sl: # ticker['Ask']
rpl=round((amount*sprice)-(amount*price),8)
if ticker['Ask']<tp
rpl=round((abs(amount)*price)-(abs(amount)*sprice),8)
if sl!=0 and 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:
Expand Down

0 comments on commit bb06da5

Please sign in to comment.