Skip to content

Commit

Permalink
Added Try/Exception to price scan, to avoid Intermittent error 32603 …
Browse files Browse the repository at this point in the history
…(issue 61)
  • Loading branch information
tsarbuig committed Apr 5, 2022
1 parent ab4273d commit d34e2c9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions LimitSwap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4913,14 +4913,18 @@ def run():

token['_PREVIOUS_QUOTE'] = token['_QUOTE']

if token['LIQUIDITYINNATIVETOKEN'] == 'true':
token['_QUOTE'] = check_precise_price(token['_IN_TOKEN'], token['_OUT_TOKEN'], token['_WETH_DECIMALS'], token['_CONTRACT_DECIMALS'], token['_BASE_DECIMALS'])
else:
# if token['LIQUIDITYINNATIVETOKEN'] == 'false', we need to use check_price, because check_precise_price do not work for now
# TODO : improve check_precise_price
token['_QUOTE'] = check_price(token['_IN_TOKEN'], token['_OUT_TOKEN'], token['USECUSTOMBASEPAIR'], token['LIQUIDITYINNATIVETOKEN'], token['_CONTRACT_DECIMALS'], token['_BASE_DECIMALS'])


try:
if token['LIQUIDITYINNATIVETOKEN'] == 'true':
token['_QUOTE'] = check_precise_price(token['_IN_TOKEN'], token['_OUT_TOKEN'], token['_WETH_DECIMALS'], token['_CONTRACT_DECIMALS'], token['_BASE_DECIMALS'])
else:
# if token['LIQUIDITYINNATIVETOKEN'] == 'false', we need to use check_price, because check_precise_price do not work for now
# TODO : improve check_precise_price
token['_QUOTE'] = check_price(token['_IN_TOKEN'], token['_OUT_TOKEN'], token['USECUSTOMBASEPAIR'], token['LIQUIDITYINNATIVETOKEN'], token['_CONTRACT_DECIMALS'], token['_BASE_DECIMALS'])
except Exception as e:
printt_err("An exception occurred - check logs for more details. Let's continue")
logging.exception(e)
continue

# let's update ATH and ATL if necessary. We only do this if we have any tokens in our wallet already --> if token balance > 0
# why this condition ? Because trailing stop loss is based on ATH, and we want this to be activated only after buy
if token['_TOKEN_BALANCE'] > 0:
Expand Down

0 comments on commit d34e2c9

Please sign in to comment.