diff --git a/bot.py b/bot.py index 0b20843..f8e82d5 100644 --- a/bot.py +++ b/bot.py @@ -18,6 +18,7 @@ load_dotenv() THRESHOLD_PRICE = os.getenv("TICTON_THRESHOLD_PRICE", 0.7) +QPS = int(os.getenv("QPS", 9)) # set up logger logger = logging.getLogger(__name__) @@ -56,7 +57,7 @@ async def check_balance( async def main(): - client = await TicTonAsyncClient.init(testnet=True) + client = await TicTonAsyncClient.init(testnet=True, qps=QPS) my_address = os.getenv("MY_ADDRESS", "") logger.info("Syncing Oracle Metadata") @@ -144,23 +145,27 @@ async def main(): except Exception as e: logger.error(f"Error in estimate wind {e}") continue - - buy_num = await check_balance( - balance, - need_base_asset, - need_quote_asset, - max_buy_num, - ) - if isinstance(buy_num, int): - profitable_alarms.append( - ProfitableAlarm( - id=alarm.id, - price_delta=price_delta, - need_base_asset=need_base_asset * buy_num, - need_quote_asset=need_quote_asset * buy_num, - buy_num=buy_num, - ) + try: + buy_num = await check_balance( + balance, + need_base_asset, + need_quote_asset, + max_buy_num, ) + if isinstance(buy_num, int): + profitable_alarms.append( + ProfitableAlarm( + id=alarm.id, + price_delta=price_delta, + need_base_asset=need_base_asset * buy_num, + need_quote_asset=need_quote_asset * buy_num, + buy_num=buy_num, + ) + ) + except Exception as e: + logger.error(f"Error in check balance {e}") + continue + logger.info(f"Profitable Alarms: \n{profitable_alarms}") async for profitable_alarm in greedy_strategy(profitable_alarms, balance): try: diff --git a/requirements.txt b/requirements.txt index d98a08b..5dcfe97 100644 --- a/requirements.txt +++ b/requirements.txt @@ -43,7 +43,7 @@ PyYAML==6.0.1 redis==5.0.1 requests==2.31.0 six==1.16.0 -ticton==0.1.25 +ticton==0.1.27 tomli==2.0.1 tonpy==0.0.0.1.2b0 tonsdk==1.0.13