Skip to content

Commit 51dd2e9

Browse files
authoredMay 3, 2023
Update bybit_auto_sell.py
1 parent 69c0644 commit 51dd2e9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎core/bybit_auto_sell.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import hashlib
33
import hmac
4+
import math
45
from json import dumps, loads
56
from time import time
67

@@ -78,7 +79,7 @@ async def get_target_coin_balance(self,
7879
for current_balance in loads(response_text)['result']['list']:
7980
if current_balance['accountType'] == 'SPOT':
8081
if current_balance['coin']:
81-
return float(current_balance['coin'][0]['free'])
82+
return float(current_balance['coin'][0]['walletBalance'])
8283

8384
return None
8485

@@ -178,7 +179,10 @@ async def main_work(self) -> None:
178179
logger.error(f'Error When Getting Base Precision: {self.token_from.upper()}, Using 0.1')
179180
token_base_precision: float = 0.1
180181

181-
token_from_balance: float = round(token_from_balance, len(str(token_base_precision).split('.')[-1]))
182+
token_from_balance: float = math.floor(
183+
token_from_balance * 10 ** len(str(token_base_precision).split('.')[1])) / 10 ** len(
184+
str(token_base_precision).split('.')[1])
185+
182186
logger.info(f'{self.token_from.upper()} - {token_from_balance}')
183187

184188
await self.run_tasks(session=session,

0 commit comments

Comments
 (0)
Please sign in to comment.