Executes partial close at profit level (moving toward TP).
Closes a percentage of the active pending position at profit. Price must be moving toward take profit (in profit 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 profit direction:
import { partialProfit } from "backtest-kit";// Close 30% of LONG position at profitconst success = await partialProfit("BTCUSDT", 30);if (success) { console.log('Partial profit executed');} Copy
import { partialProfit } from "backtest-kit";// Close 30% of LONG position at profitconst success = await partialProfit("BTCUSDT", 30);if (success) { console.log('Partial profit executed');}
Executes partial close at profit level (moving toward TP).
Closes a percentage of the active pending position at profit. Price must be moving toward take profit (in profit direction).
Automatically detects backtest/live mode from execution context.