Fixed take profit calculation. Added a position check for the current pair when trying to change the margin.
This commit is contained in:
@@ -296,10 +296,10 @@ async def open_positions(
|
||||
if (liq_long > 0 or liq_short > 0) and price_for_cals > 0:
|
||||
if side == "Buy":
|
||||
base_tp = price_for_cals + (price_for_cals - liq_long)
|
||||
take_profit_price = base_tp + commission_fee_percent
|
||||
take_profit_price = base_tp + commission_fee_percent / qty_formatted
|
||||
else:
|
||||
base_tp = price_for_cals - (liq_short - price_for_cals)
|
||||
take_profit_price = base_tp - commission_fee_percent
|
||||
take_profit_price = base_tp - commission_fee_percent / qty_formatted
|
||||
take_profit_price = max(take_profit_price, 0)
|
||||
else:
|
||||
take_profit_price = None
|
||||
@@ -307,10 +307,10 @@ async def open_positions(
|
||||
stop_loss_price = None
|
||||
else:
|
||||
if side == "Buy":
|
||||
take_profit_price = price_for_cals * (1 + take_profit_percent / 100) + commission_fee_percent
|
||||
take_profit_price = price_for_cals * (1 + take_profit_percent / 100) + commission_fee_percent / qty_formatted
|
||||
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
|
||||
take_profit_price = price_for_cals * (1 - take_profit_percent / 100) - commission_fee_percent / qty_formatted
|
||||
stop_loss_price = price_for_cals * (1 + stop_loss_percent / 100)
|
||||
|
||||
take_profit_price = max(take_profit_price, 0)
|
||||
|
Reference in New Issue
Block a user