From 63a89cec6808331397e0f2f513913e652214ef1a Mon Sep 17 00:00:00 2001 From: grace0950 Date: Sun, 3 Mar 2024 22:30:36 +0800 Subject: [PATCH 1/2] Update: try catch when check balance --- bot.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/bot.py b/bot.py index 0b20843..d8e3072 100644 --- a/bot.py +++ b/bot.py @@ -144,23 +144,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: From 1bca5f41b84d78c9c9337b5a64fd03ac7aa87823 Mon Sep 17 00:00:00 2001 From: grace0950 Date: Sun, 3 Mar 2024 22:46:17 +0800 Subject: [PATCH 2/2] Add: qps option in config --- bot.py | 3 ++- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index d8e3072..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") 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