@@ -254,6 +254,10 @@ def main():
254
254
if "ReduceOnly" in relay .Active :
255
255
ReduceOnly = True
256
256
257
+ # Initialize amount and price
258
+ amount = None
259
+ price = None
260
+
257
261
# Get Minimum allowed amount (units) and cost
258
262
259
263
isMinimum = False
@@ -273,6 +277,10 @@ def main():
273
277
amount = int (GetPCTamount (relay ,price ))
274
278
else :
275
279
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' ])
276
284
277
285
# Make sure minimum is enforced. Negative is for short.
278
286
@@ -366,7 +374,7 @@ def main():
366
374
# Determine trade action and carry it out
367
375
368
376
if type (amount ) is int :
369
- total = abs (round (amount * price ,8 ))
377
+ total = abs (round (amount * price ,5 ))
370
378
else :
371
379
total = abs (pBalance )
372
380
if (type (amount ) is str and amount .upper ()== 'ALL' and pBalance >= 0 ) \
@@ -384,7 +392,7 @@ def main():
384
392
if type (amount ) is int :
385
393
relay .JRLog .Write (f"|- Units: { abs (amount ):.8f} { dir } " )
386
394
else :
387
- relay .JRLog .Write (f"|- Units: { amount } { dir } " )
395
+ relay .JRLog .Write (f"|- Units: { amount :.8f } { dir } " )
388
396
relay .JRLog .Write (f"|- Price: { price :.8f} " )
389
397
relay .JRLog .Write (f"|- Total: { total :.8f} " )
390
398
0 commit comments