forked from kodorvan/stcs
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			948 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			948 B
		
	
	
	
		
			Python
		
	
	
	
	
	
import logging.config
 | 
						|
 | 
						|
from app.bybit import get_bybit_client
 | 
						|
from app.bybit.logger_bybit.logger_bybit import LOGGING_CONFIG
 | 
						|
 | 
						|
logging.config.dictConfig(LOGGING_CONFIG)
 | 
						|
logger = logging.getLogger("get_instruments_info")
 | 
						|
 | 
						|
 | 
						|
async def get_instruments_info(tg_id: int, symbol: str) -> dict | None:
 | 
						|
    """
 | 
						|
    Get instruments info
 | 
						|
    :param tg_id: int - User ID
 | 
						|
    :param symbol: str - Symbol
 | 
						|
    :return: dict - Instruments info
 | 
						|
    """
 | 
						|
    try:
 | 
						|
        client = await get_bybit_client(tg_id=tg_id)
 | 
						|
        response = client.get_instruments_info(category="linear", symbol=symbol)
 | 
						|
        if response["retCode"] == 0:
 | 
						|
            logger.info("Instruments info for user: %s", tg_id)
 | 
						|
            return response["result"]["list"][0]
 | 
						|
        else:
 | 
						|
            logger.error("Error getting price: %s", tg_id)
 | 
						|
            return None
 | 
						|
    except Exception as e:
 | 
						|
        logger.error("Error connecting to Bybit for user %s: %s", tg_id, e)
 | 
						|
        return None
 |