GroupTpSlDesiredSides
The desired take profit and/or stop loss for one child. An omitted side is left entirely untouched.
interface GroupTpSlDesiredSide {
/** Trigger price (decimal string), or `""` to clear the side. */
triggerPrice: string;
/** Mark vs last-close. Defaults to the child's current price type when omitted. */
priceType?: TpSlPriceType;
}
interface GroupTpSlDesiredSides {
tp?: GroupTpSlDesiredSide;
sl?: GroupTpSlDesiredSide;
}
/** Keyed by `GroupTpSlChild.key`. */
type GroupTpSlDesiredMap = Readonly<Record<string, GroupTpSlDesiredSides>>;An empty triggerPrice means clear this side — planGroupTpSl turns that into a delete when the handler holds a live order, and drops it otherwise.
Applying one price across a whole position is a one-liner:
const desired = Object.fromEntries(children.map((child) => [child.key, { tp: { triggerPrice: "150" } }]));Related
planGroupTpSl— consumes the map.useQuoteGroupTpSlEditor— owns the map in React.
Last updated on