Callback function to handle partial profit events
Unsubscribe function to stop listening to events
import { listenPartialProfit } from "./function/event";
const unsubscribe = listenPartialProfit((event) => {
console.log(`Signal ${event.data.id} reached ${event.level}% profit`);
console.log(`Symbol: ${event.symbol}, Price: ${event.currentPrice}`);
console.log(`Mode: ${event.backtest ? "Backtest" : "Live"}`);
});
// Later: stop listening
unsubscribe();
Subscribes to partial profit level events with queued async processing.
Emits when a signal reaches a profit level milestone (10%, 20%, 30%, etc). Events are processed sequentially in order received, even if callback is async. Uses queued wrapper to prevent concurrent execution of the callback.