Skip to content

Commit b1bcc85

Browse files
committed
Bug fixed in Oanda PlaceOrder that would not get price data correctly.
Changes to be committed: modified: Base/OANDA-PlaceOrder modified: Extras/OliverTwist/otProfits
1 parent 52c713b commit b1bcc85

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Base/OANDA-PlaceOrder

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ def main():
254254
if "ReduceOnly" in relay.Active:
255255
ReduceOnly=True
256256

257+
# Initialize amount and price
258+
amount=None
259+
price=None
260+
257261
# Get Minimum allowed amount (units) and cost
258262

259263
isMinimum=False
@@ -273,6 +277,10 @@ def main():
273277
amount=int(GetPCTamount(relay,price))
274278
else:
275279
amount=int(relay.Order['Units'].split('.')[0])
280+
if amount<0:
281+
price=max(ticker['Ask'],ticker['Bid'])
282+
else:
283+
price=min(ticker['Ask'],ticker['Bid'])
276284

277285
# Make sure minimum is enforced. Negative is for short.
278286

@@ -366,7 +374,7 @@ def main():
366374
# Determine trade action and carry it out
367375

368376
if type(amount) is int:
369-
total=abs(round(amount*price,8))
377+
total=abs(round(amount*price,5))
370378
else:
371379
total=abs(pBalance)
372380
if (type(amount) is str and amount.upper()=='ALL' and pBalance>=0) \
@@ -384,7 +392,7 @@ def main():
384392
if type(amount) is int:
385393
relay.JRLog.Write(f"|- Units: {abs(amount):.8f} {dir}")
386394
else:
387-
relay.JRLog.Write(f"|- Units: {amount} {dir}")
395+
relay.JRLog.Write(f"|- Units: {amount:.8f} {dir}")
388396
relay.JRLog.Write(f"|- Price: {price:.8f}")
389397
relay.JRLog.Write(f"|- Total: {total:.8f}")
390398

Extras/OliverTwist/otProfits

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ for i in range(1,len(sys.argv)):
4545
data=line.split(' ')
4646

4747
dmy=data[0].split(' ')[0].split('-')
48-
date=dmy[0]+'-'+dmy[1] # +'-'+dmy[2]
48+
date=dmy[0]+'-'+dmy[1] # +'-'+dmy[2]
4949

5050
pdata=line.split('/')[1].strip().split(',')[0]
5151

0 commit comments

Comments
 (0)