INNER CODE UNIT · Python
position_leveraged_stop_loss
hadialaddin/crypto-genie · crypto-genie.py:2449
position_leveraged_stop_loss = round_to_tick((entry_price + (((stop_loss_cap_ratio_short/100) / leverage_for_sl_calc) * entry_price)), tick_size[symbol])
if stop_price <= position_leveraged_stop_loss and float(conditional_order['qty']) == size:
# Stop Loss found inside the allowed range, keep it
total_allowed_stop_loss_found += float(conditional_order['qty'])
else:
# Stop Loss found outside the allowed range, useless so remove it
try:
session.cancel_conditional_order(symbol=symbol, stop_order_id=stop_order_id)
except Exception:
pass
else: # Inverse Perpetuals or Futures
stop_price = float(conditional_order['stop_px'])
stop_order_id = conditional_order['order_id']
position_leveraged_stop_loss = round_to_tick((entry_price + (((stop_loss_cap_ratio_short/100) / leverage_for_sl_calc) * entry_price)), tick_size[symbol])
if stop_price <= position_leveraged_stop_loss and float(conditional_order['qty']) == size:
# Stop Loss found inside the allowed range, keep it
total_allowed_stop_loss_found += float(conditional_order['qty'])