@@ -256,7 +256,7 @@ def main():
256
256
257
257
# Initialize amount and price
258
258
amount = None
259
- price = None
259
+ price = ( ticker [ 'Ask' ] + ticker [ 'Bid' ]) / 2
260
260
261
261
# Get Minimum allowed amount (units) and cost
262
262
@@ -276,15 +276,14 @@ def main():
276
276
price = (ticker ['Ask' ]+ ticker ['Bid' ])/ 2
277
277
amount = int (GetPCTamount (relay ,price ))
278
278
else :
279
- amount = int (relay .Order ['Units' ].split ('.' )[0 ])
280
- if amount < 0 :
281
- price = max (ticker ['Ask' ],ticker ['Bid' ])
279
+ if type (relay .Order ['Units' ])!= str :
280
+ amount = int (relay .Order ['Units' ].split ('.' )[0 ])
282
281
else :
283
- price = min ( ticker [ 'Ask' ], ticker [ 'Bid' ])
282
+ amount = relay . Order [ 'Units' ]
284
283
285
284
# Make sure minimum is enforced. Negative is for short.
286
285
287
- if abs (amount )< minimum :
286
+ if type ( amount ) != str and abs (amount )< minimum :
288
287
if amount >= 0 :
289
288
amount = minimum
290
289
else :
@@ -384,17 +383,20 @@ def main():
384
383
or (type (amount ) is int and amount < 0 ):
385
384
dir = 'Short'
386
385
387
- relay .JRLog .Write ("Placing Order" )
388
- relay .JRLog .Write (f"|- Asset: { relay .Order ['Asset' ]} " )
389
- relay .JRLog .Write (f"|- Action: { relay .Order ['Action' ]} " )
390
- if 'Ticket' in relay .Order :
391
- relay .JRLog .Write (f"|- Ticket: { relay .Order ['Ticket' ]} " )
392
- if type (amount ) is int :
393
- relay .JRLog .Write (f"|- Units: { abs (amount ):.8f} { dir } " )
394
- else :
395
- relay .JRLog .Write (f"|- Units: { amount :.8f} { dir } " )
396
- relay .JRLog .Write (f"|- Price: { price :.8f} " )
397
- relay .JRLog .Write (f"|- Total: { total :.8f} " )
386
+ try :
387
+ relay .JRLog .Write ("Placing Order" )
388
+ relay .JRLog .Write (f"|- Asset: { relay .Order ['Asset' ]} " )
389
+ relay .JRLog .Write (f"|- Action: { relay .Order ['Action' ]} " )
390
+ if 'Ticket' in relay .Order :
391
+ relay .JRLog .Write (f"|- Ticket: { relay .Order ['Ticket' ]} " )
392
+ if type (amount ) is int :
393
+ relay .JRLog .Write (f"|- Units: { abs (amount ):.8f} { dir } " )
394
+ else :
395
+ relay .JRLog .Write (f"|- Units: { amount :.8f} { dir } " )
396
+ relay .JRLog .Write (f"|- Price: { price :.8f} " )
397
+ relay .JRLog .Write (f"|- Total: { total :.8f} " )
398
+ except Exception as err :
399
+ relay .JRLog .Write (f"{ Orphan ['Key' ]} : Code Error - { sys .exc_info ()[- 1 ].tb_lineno } /{ str (e )} " ,stdOut = False )
398
400
399
401
if (type (amount ) is int and amount != 0 ) \
400
402
or (type (amount ) is str and amount .upper ()== 'ALL' ):
0 commit comments