The Sell Flow
When SignalPipe receives a sell signal, it closes all sub-positions for the specified instrument.
Sell Execution Steps
- Close all sub-positions -- Each open sub-position in the deal is individually closed on Capital.com. This is necessary because Capital.com manages each DCA position as a separate deal.
- Collect profit data -- Capital.com returns profit/loss data for each closed sub-position in the confirmation response.
- Calculate total P&L -- The realized profit or loss is summed across all closed sub-positions.
- Mark deal as completed -- The deal status is updated to "completed" with the close timestamp and total realized P&L.
- Log the closure -- A detailed log entry records the P&L, number of sub-positions, and ladder depth.
Example: Sell Flow
- Active deal: AAPL, 2 sub-positions (base + 1 safety order), 25 total units, avg entry $144.00
- Sub-positions closed individually on Capital.com
- Combined P&L from confirmations: +$100.00
- All sub-positions marked CLOSED
- Deal marked completed
Edge Cases
No Active Deal Found
If a sell signal arrives but there is no active deal in the database for that instrument, a warning is logged noting that no matching deal was found. This can happen if:
- The deal was already completed by a take-profit fill
- The deal was closed manually on Capital.com
- The position was opened outside of SignalPipe
Position Already Closed
If a Capital.com sub-position was already closed (for example, by a TP level being hit), the close request may return an error. SignalPipe handles this gracefully -- it logs the situation and continues processing the remaining sub-positions.