Executes partial close at loss level (moving toward SL).
Closes a percentage of the active pending position at loss. Price must be moving toward stop loss (in loss direction).
Automatically detects backtest/live mode from execution context.
Trading pair symbol
Percentage of position to close (0-100, absolute value)
Promise - true if partial close executed, false if skipped
Error if currentPrice is not in loss direction:
import { partialLoss } from "backtest-kit";// Close 40% of LONG position at lossconst success = await partialLoss("BTCUSDT", 40);if (success) { console.log('Partial loss executed');} Copy
import { partialLoss } from "backtest-kit";// Close 40% of LONG position at lossconst success = await partialLoss("BTCUSDT", 40);if (success) { console.log('Partial loss executed');}
Executes partial close at loss level (moving toward SL).
Closes a percentage of the active pending position at loss. Price must be moving toward stop loss (in loss direction).
Automatically detects backtest/live mode from execution context.