diff --git a/database/request.py b/database/request.py index 6492cea..4f963ae 100644 --- a/database/request.py +++ b/database/request.py @@ -893,20 +893,20 @@ async def set_stop_timer(tg_id: int, timer_end: int) -> bool: # USER DEALS async def set_user_deal( - tg_id: int, - symbol: str, - last_side: str, - current_step: int, - trade_mode: str, - margin_type: str, - leverage: str, - order_quantity: float, - trigger_price: float, - martingale_factor: float, - max_bets_in_series: int, - take_profit_percent: int, - stop_loss_percent: int, - base_quantity: float + tg_id: int, + symbol: str, + last_side: str, + current_step: int, + trade_mode: str, + margin_type: str, + leverage: str, + order_quantity: float, + trigger_price: float, + martingale_factor: float, + max_bets_in_series: int, + take_profit_percent: int, + stop_loss_percent: int, + base_quantity: float, ): """ Set the user deal in the database. @@ -969,7 +969,7 @@ async def set_user_deal( max_bets_in_series=max_bets_in_series, take_profit_percent=take_profit_percent, stop_loss_percent=stop_loss_percent, - base_quantity=base_quantity + base_quantity=base_quantity, ) session.add(new_deal) @@ -978,7 +978,9 @@ async def set_user_deal( return True except Exception as e: - logger.error("Error setting user deal for user %s and symbol %s: %s", tg_id, symbol, e) + logger.error( + "Error setting user deal for user %s and symbol %s: %s", tg_id, symbol, e + ) return False @@ -998,7 +1000,9 @@ async def get_user_deal_by_symbol(tg_id: int, symbol: str): deal = result_deal.scalars().first() return deal except Exception as e: - logger.error("Error getting deal for user %s and symbol %s: %s", tg_id, symbol, e) + logger.error( + "Error getting deal for user %s and symbol %s: %s", tg_id, symbol, e + ) return None @@ -1040,18 +1044,26 @@ async def set_fee_user_deal_by_symbol(tg_id: int, symbol: str, fee: float): if record: record.fee = fee else: - logger.error(f"User deal with user_id={user.id} and symbol={symbol} not found") + logger.error( + f"User deal with user_id={user.id} and symbol={symbol} not found" + ) return False await session.commit() logger.info("Set fee for user %s and symbol %s", tg_id, symbol) return True except Exception as e: - logger.error("Error setting user deal fee for user %s and symbol %s: %s", tg_id, symbol, e) + logger.error( + "Error setting user deal fee for user %s and symbol %s: %s", + tg_id, + symbol, + e, + ) return False # USER AUTO TRADING + async def get_all_user_auto_trading(tg_id: int): """Get all user auto trading from the database asynchronously.""" try: @@ -1086,7 +1098,9 @@ async def get_user_auto_trading(tg_id: int, symbol: str): auto_trading = result_auto_trading.scalars().first() return auto_trading except Exception as e: - logger.error("Error getting auto trading for user %s and symbol %s: %s", tg_id, symbol, e) + logger.error( + "Error getting auto trading for user %s and symbol %s: %s", tg_id, symbol, e + ) return None @@ -1120,10 +1134,17 @@ async def set_auto_trading(tg_id: int, symbol: str, auto_trading: bool) -> bool: ) session.add(new_record) await session.commit() - logger.info("Set auto_trading=%s for user %s and symbol %s", auto_trading, tg_id, symbol) + logger.info( + "Set auto_trading=%s for user %s and symbol %s", + auto_trading, + tg_id, + symbol, + ) return True except Exception as e: - logger.error("Error setting auto_trading for user %s and symbol %s: %s", tg_id, symbol, e) + logger.error( + "Error setting auto_trading for user %s and symbol %s: %s", tg_id, symbol, e + ) return False @@ -1161,11 +1182,18 @@ async def set_fee_user_auto_trading(tg_id: int, symbol: str, fee: float) -> bool logger.info("Set fee for user %s and symbol %s", tg_id, symbol) return True except Exception as e: - logger.error("Error setting user auto trading fee for user %s and symbol %s: %s", tg_id, symbol, e) + logger.error( + "Error setting user auto trading fee for user %s and symbol %s: %s", + tg_id, + symbol, + e, + ) return False -async def set_total_fee_user_auto_trading(tg_id: int, symbol: str, total_fee: float) -> bool: +async def set_total_fee_user_auto_trading( + tg_id: int, symbol: str, total_fee: float +) -> bool: """ Set the total fee for a user auto trading in the database. :param tg_id: Telegram user ID @@ -1199,5 +1227,10 @@ async def set_total_fee_user_auto_trading(tg_id: int, symbol: str, total_fee: fl logger.info("Set total fee for user %s and symbol %s", tg_id, symbol) return True except Exception as e: - logger.error("Error setting user auto trading total fee for user %s and symbol %s: %s", tg_id, symbol, e) + logger.error( + "Error setting user auto trading total fee for user %s and symbol %s: %s", + tg_id, + symbol, + e, + ) return False