Skip to content

Commit

Permalink
BUGS! Minor bug fixes and small peerformance tweaks.
Browse files Browse the repository at this point in the history
The most significant bug fix revolves around OliverTwist not have any orders in the orphan list.

Changes to be committed:
	modified:   Base/JackrabbitOliverTwist
	modified:   Base/Library/JRRccxt.py
	modified:   Base/OANDA-PlaceOrder
  • Loading branch information
rapmd73 committed Sep 11, 2023
1 parent 7448484 commit 1eb7265
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
19 changes: 11 additions & 8 deletions Base/JackrabbitOliverTwist
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def ProcessOrphan(**kwargs):
# memData will be eithewr OrphanMemory or ConfitionalMemory

def ProcessChild(CurList,cur,memData,CurListChanged):
data=json.loads(cur.GetData())
data=json.loads(node)

# Get result from Locker

Expand Down Expand Up @@ -493,15 +493,18 @@ def main():
if cur==None:
cur=OrphanList.GetHead()

OrphanList,cur,OrphanListChanged=ProcessChild(OrphanList,cur,OrphanMemory,OrphanListChanged)
# Make sure we actuallyhave orphans to process

# Save the orphan list to disk, ONLY IF it actually changed
if cur!=None:
OrphanList,cur,OrphanListChanged=ProcessChild(OrphanList,cur,OrphanMemory,OrphanListChanged)

if OrphanListChanged==True:
OliverTwistLock.Lock()
WriteOrphanList('Orphan')
OrphanListChanged=False
OliverTwistLock.Unlock()
# Save the orphan list to disk, ONLY IF it actually changed

if OrphanListChanged==True:
OliverTwistLock.Lock()
WriteOrphanList('Orphan')
OrphanListChanged=False
OliverTwistLock.Unlock()

# Only allow "NumberProcesses" children to run as once.

Expand Down
7 changes: 4 additions & 3 deletions Base/Library/JRRccxt.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,10 @@ def GetTicker(self,**kwargs):
ask=0

Pair={}
Pair['Ask']=max(ask,bid)
Pair['Bid']=min(bid,ask)
Pair['Spread']=Pair['Ask']-Pair['Bid']
Pair['DateTime']=datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
Pair['Ask']=min(ask,bid)
Pair['Bid']=max(bid,ask)
Pair['Spread']=round(abs(Pair['Bid']-Pair['Ask']),8)

return Pair

Expand Down
10 changes: 6 additions & 4 deletions Base/OANDA-PlaceOrder
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def GetPCTtype(currency):
pct=float(vs)
return pct,PCTtype

def GetPCTvalue(pct,close,bal):
def GetPCTvalue(pct,close,bal,mr):
volume=round(((pct/100)*bal),8)
amount=round(volume/close,8)
amount=round((volume/close)/mr,8)

return amount,volume

Expand All @@ -46,8 +46,9 @@ def GetPCTamount(relay,close):

if "OverridePCTtable" not in relay.Active and "OverridePCTtable" not in relay.Order:
bal=relay.GetBalance()
mr=float(relay.Markets[relay.Asset]['marginRate'])
pct,PCTtype=GetPCTtype(relay.Order['Units'])
amount,volume=GetPCTvalue(pct,close,bal)
amount,volume=GetPCTvalue(pct,close,bal,mr)

pctData={}
pctData['PCT']=pct
Expand All @@ -63,7 +64,8 @@ def GetPCTamount(relay,close):
amount=payload['Amount']
else:
bal=relay.GetBalance()
amount=round(((float(relay.Order[currency].replace('%',''))/100)*bal)/close,8)
mr=float(relay.Markets[relay.Asset]['marginRate'])
amount=round((((float(relay.Order[currency].replace('%',''))/100)*bal)/close)/mr,8)
return amount

def HighestLotSize(relay,asset,units,step):
Expand Down

0 comments on commit 1eb7265

Please sign in to comment.