estimateGroupTpSlReturn
Estimate a grouped position’s return if every child’s take profit (or stop loss) triggers at its target.
Per child: pnl = openQuantity × (triggerPrice − openPrice), negated for a SHORT. Children with no trigger on the requested side contribute nothing. All bigint, 18-decimal wei.
Leverage deliberately does not appear. The reference formula this ports from multiplies one factor by leverage and divides the other by it, so it cancels algebraically — carrying it would only add a divide-by-zero hazard for identical output. A regression test pins that down.
import { estimateGroupTpSlReturn } from "@symmio/trading-core";
const { totalPnl, returnPercent } = estimateGroupTpSlReturn(children, {
conditionalOrderType: "take_profit",
overrides: editor.desired,
});Parameters
The grouped position’s children.
parameters.conditionalOrderTypeTpSlConditionalOrderTyperequiredWhich side to estimate — "take_profit" or "stop_loss".
parameters.overridesGroupTpSlDesiredMapoptionalPending per-child edits that win over the confirmed snapshot.
Returns
Signed totals plus the per-child breakdown. returnPercent is undefined when no child contributes.
Related
GroupTpSlReturnEstimate— the result shape.useQuoteGroupTpSlEditor— recomputes this as the buffer changes.