Skip to content

Commit

Permalink
Fixed bug where FIFO regulation were not being honored with Flip action.
Browse files Browse the repository at this point in the history
Changes to be committed:
	modified:   Base/OANDA-PlaceOrder
  • Loading branch information
rapmd73 committed May 14, 2024
1 parent ba2498d commit b238337
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions Base/OANDA-PlaceOrder
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def LowestLotSize(relay,asset,units,step):
else:
sign=1

relay.JRLog.Write(f'EnforceFIFO: next unit size is {nextSize*sign}')
return nextSize*sign

# Find highest lot size
Expand Down Expand Up @@ -283,18 +284,6 @@ def main():
if AlreadyBought(relay,relay.Order['Asset'],ticker['Bid'],devPips):
relay.JRLog.Error("Deviation", f"{relay.Order['Deviation']}: Required condition not met")

# Check and manage FIFO rule
if 'EnforceFIFO' in relay.Active or 'EnforceFIFO' in relay.Order:
if 'Step' in relay.Order:
step=int(relay.Order['Step'])
else:
step=1

if relay.Order['Action']=='buy':
amount=LowestLotSize(relay,relay.Order['Asset'],amount,step)
elif 'Ticket' in relay.Order:
amount=GetTicket(relay,relay.Order['Asset'],relay.Order['Ticket'],amount)

# Figure limit order pricing, minimum cost is ignored as limit orders can be
# anything.

Expand Down Expand Up @@ -356,6 +345,18 @@ def main():
# Make ure units is in range of what we actually hold
amount=units

# Check and manage FIFO rule
if 'EnforceFIFO' in relay.Active or 'EnforceFIFO' in relay.Order:
if 'Step' in relay.Order:
step=int(relay.Order['Step'])
else:
step=1

if relay.Order['Action']=='buy':
amount=LowestLotSize(relay,relay.Order['Asset'],amount,step)
elif 'Ticket' in relay.Order:
amount=GetTicket(relay,relay.Order['Asset'],relay.Order['Ticket'],amount)

# Determine trade action and carry it out

if type(amount) is int:
Expand Down

0 comments on commit b238337

Please sign in to comment.