version 1 STCS
This commit is contained in:
40
app/services/Bybit/functions/price_symbol.py
Normal file
40
app/services/Bybit/functions/price_symbol.py
Normal file
@@ -0,0 +1,40 @@
|
||||
import app.telegram.database.requests as rq
|
||||
|
||||
from pybit import exceptions
|
||||
from pybit.unified_trading import HTTP
|
||||
|
||||
client = HTTP()
|
||||
|
||||
async def get_price(tg_id, message):
|
||||
api_key = await rq.get_bybit_api_key(tg_id)
|
||||
secret_key = await rq.get_bybit_secret_key(tg_id)
|
||||
SYMBOL = await rq.get_symbol(tg_id)
|
||||
|
||||
client = HTTP(
|
||||
api_key=api_key,
|
||||
api_secret=secret_key
|
||||
)
|
||||
|
||||
try:
|
||||
price = float(client.get_tickers(category='linear', symbol=SYMBOL).get('result').get('list')[0].get('ask1Price'))
|
||||
|
||||
print(f'''
|
||||
=====================
|
||||
=====PRICE=========
|
||||
===================
|
||||
===================
|
||||
=================
|
||||
|
||||
{price}
|
||||
|
||||
===============
|
||||
===============
|
||||
=============
|
||||
===============
|
||||
==============
|
||||
''')
|
||||
|
||||
return price
|
||||
except exceptions.InvalidRequestError as e:
|
||||
await message.answer('Неверно указана торговая пара')
|
||||
return 1.0
|
Reference in New Issue
Block a user