Skip to content

Commit

Permalink
Merge pull request #13 from Ton-Dynasty/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
grace0950 authored Mar 3, 2024
2 parents 8ed5494 + 1bca5f4 commit c5d7ade
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
39 changes: 22 additions & 17 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c5d7ade

Please sign in to comment.