Added position mode setting, fixed stop loss calculation
This commit is contained in:
@@ -10,6 +10,7 @@ from app.bybit.get_functions.get_tickers import get_tickers
|
||||
from app.bybit.logger_bybit.logger_bybit import LOGGING_CONFIG
|
||||
from app.bybit.set_functions.set_leverage import set_leverage
|
||||
from app.bybit.set_functions.set_margin_mode import set_margin_mode
|
||||
from app.bybit.set_functions.set_switch_position_mode import set_switch_position_mode
|
||||
from app.helper_functions import get_liquidation_price, safe_float
|
||||
|
||||
logging.config.dictConfig(LOGGING_CONFIG)
|
||||
@@ -90,6 +91,10 @@ async def start_trading_cycle(
|
||||
price_for_cals = trigger_price if po_trigger_price is not None else price_symbol
|
||||
total_commission = price_for_cals * qty_formatted * commission_fee_percent
|
||||
|
||||
await set_switch_position_mode(
|
||||
tg_id=tg_id,
|
||||
symbol=symbol,
|
||||
mode=0)
|
||||
await set_margin_mode(tg_id=tg_id, margin_mode=margin_type)
|
||||
await set_leverage(
|
||||
tg_id=tg_id,
|
||||
@@ -303,10 +308,10 @@ async def open_positions(
|
||||
else:
|
||||
if side == "Buy":
|
||||
take_profit_price = price_for_cals * (1 + take_profit_percent / 100) + commission_fee_percent
|
||||
stop_loss_price = price_for_cals * (1 - stop_loss_percent / 100) - commission_fee_percent
|
||||
stop_loss_price = price_for_cals * (1 - stop_loss_percent / 100)
|
||||
else:
|
||||
take_profit_price = price_for_cals * (1 - take_profit_percent / 100) - commission_fee_percent
|
||||
stop_loss_price = price_for_cals * (1 + stop_loss_percent / 100) + commission_fee_percent
|
||||
stop_loss_price = price_for_cals * (1 + stop_loss_percent / 100)
|
||||
|
||||
take_profit_price = max(take_profit_price, 0)
|
||||
stop_loss_price = max(stop_loss_price, 0)
|
||||
|
Reference in New Issue
Block a user