diff --git a/app/bybit/open_positions.py b/app/bybit/open_positions.py index 7b8d3b4..7728cc4 100644 --- a/app/bybit/open_positions.py +++ b/app/bybit/open_positions.py @@ -16,9 +16,7 @@ logging.config.dictConfig(LOGGING_CONFIG) logger = logging.getLogger("open_positions") -async def start_trading_cycle( - tg_id: int -) -> str | None: +async def start_trading_cycle(tg_id: int) -> str | None: """ Start trading cycle :param tg_id: Telegram user ID @@ -29,9 +27,7 @@ async def start_trading_cycle( additional_data = await rq.get_user_additional_settings(tg_id=tg_id) risk_management_data = await rq.get_user_risk_management(tg_id=tg_id) commission_fee = risk_management_data.commission_fee - user_deals_data = await rq.get_user_deal_by_symbol( - tg_id=tg_id, symbol=symbol - ) + user_deals_data = await rq.get_user_deal_by_symbol(tg_id=tg_id, symbol=symbol) trade_mode = additional_data.trade_mode switch_side = additional_data.switch_side margin_type = additional_data.margin_type @@ -107,7 +103,7 @@ async def start_trading_cycle( leverage=leverage, take_profit_percent=take_profit_percent, stop_loss_percent=stop_loss_percent, - commission_fee_percent=total_commission + commission_fee_percent=total_commission, ) if res == "OK": @@ -125,7 +121,7 @@ async def start_trading_cycle( max_bets_in_series=max_bets_in_series, take_profit_percent=take_profit_percent, stop_loss_percent=stop_loss_percent, - base_quantity=order_quantity + base_quantity=order_quantity, ) return "OK" return ( @@ -142,7 +138,7 @@ async def start_trading_cycle( "position idx not match position mode", "Qty invalid", "The number of contracts exceeds maximum limit allowed", - "The number of contracts exceeds minimum limit allowed" + "The number of contracts exceeds minimum limit allowed", } else None ) @@ -152,12 +148,12 @@ async def start_trading_cycle( return None -async def trading_cycle( - tg_id: int, symbol: str, reverse_side: str -) -> str | None: +async def trading_cycle(tg_id: int, symbol: str, reverse_side: str) -> str | None: try: user_deals_data = await rq.get_user_deal_by_symbol(tg_id=tg_id, symbol=symbol) - user_auto_trading_data = await rq.get_user_auto_trading(tg_id=tg_id, symbol=symbol) + user_auto_trading_data = await rq.get_user_auto_trading( + tg_id=tg_id, symbol=symbol + ) total_fee = user_auto_trading_data.total_fee trade_mode = user_deals_data.trade_mode margin_type = user_deals_data.margin_type @@ -188,9 +184,7 @@ async def trading_cycle( if trade_mode == "Switch": side = "Sell" if real_side == "Buy" else "Buy" - next_quantity = safe_float(order_quantity) * ( - safe_float(martingale_factor) - ) + next_quantity = safe_float(order_quantity) * (safe_float(martingale_factor)) current_step += 1 if max_bets_in_series < current_step: @@ -206,7 +200,7 @@ async def trading_cycle( leverage=leverage, take_profit_percent=take_profit_percent, stop_loss_percent=stop_loss_percent, - commission_fee_percent=total_fee + commission_fee_percent=total_fee, ) if res == "OK": @@ -224,7 +218,7 @@ async def trading_cycle( 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, ) return "OK" @@ -255,7 +249,7 @@ async def open_positions( leverage: str, take_profit_percent: float, stop_loss_percent: float, - commission_fee_percent: float + commission_fee_percent: float, ) -> str | None: try: client = await get_bybit_client(tg_id=tg_id)