diff --git a/web/src/views/SimpleView.tsx b/web/src/views/SimpleView.tsx index 680d85b..b26f651 100644 --- a/web/src/views/SimpleView.tsx +++ b/web/src/views/SimpleView.tsx @@ -667,6 +667,10 @@ export function SimpleView() { () => simpleHoldings.find((holding) => holding.symbol === normalizedSymbol) || null, [simpleHoldings, normalizedSymbol], ); + const availableSellHoldings = useMemo( + () => [...simpleHoldings].sort((left, right) => left.symbol.localeCompare(right.symbol)), + [simpleHoldings], + ); const supportedSymbols = useMemo(() => { const fromState = Object.keys(symbolState || {}).map(normalizeKnownSymbol).filter(Boolean) as string[]; @@ -751,6 +755,24 @@ export function SimpleView() { setDraft((prev) => ({ ...prev, [key]: value })); } + function applyHoldingToDraft(holding: SimpleHolding) { + setMarketPriceSource(null); + setDraft((prev) => ({ + ...prev, + side: 'sell', + symbol: holding.symbol, + quantity: String(holding.size), + currentMarketPrice: '', + })); + } + + useEffect(() => { + if (draft.side !== 'sell') return; + if (matchingHolding) return; + if (availableSellHoldings.length === 0) return; + applyHoldingToDraft(availableSellHoldings[0]); + }, [draft.side, matchingHolding, availableSellHoldings]); + async function copyIdentifier(kind: 'trade' | 'order', value: string | null | undefined) { if (!value) return; try { @@ -950,7 +972,7 @@ export function SimpleView() {
{editingSetupId ? 'Edit setup' : 'New setup'} - Saved trigger workflow, not an immediate broker order + Build a short-term buy plan or attach a managed profit exit to an existing holding.
+ + + + {draft.side === 'sell' && ( + + )} +