Home  ›  SignalPipe  ›  Documentation  ›  Position Sync

Position Sync

Position Sync

Position synchronization ensures your dashboard stays accurate by detecting when take-profit orders are filled on Alpaca and updating the corresponding deals in the database.

How Take-Profits Are Filled

When SignalPipe places a take-profit limit sell order on Alpaca, it runs independently of the webhook system. The order sits on Alpaca's order book until the market price reaches the limit price, at which point Alpaca fills the order automatically. This can happen at any time during market hours -- there is no webhook event from TradingView for this.

Real-Time Deal Monitoring

The dashboard uses a Firestore real-time listener that monitors your deals collection. When a deal document is modified (e.g., status changes from "active" to "completed"), the change is detected automatically:

  • The deal card disappears from the active deals section
  • A toast notification shows the symbol and realized P&L
  • The deal appears in the completed deals section

Dashboard Refresh Sync

Each time you load the SignalPipe Dashboard, the system:

  1. Fetches all active deals from the database
  2. Queries live position data from the Alpaca API
  3. Enriches each deal with current price, unrealized P&L, and actual position size from Alpaca
  4. Uses Alpaca's average entry price as the source of truth, which accounts for fees and adjustments

If an active deal exists in the database but no corresponding position is found on Alpaca, this indicates the take-profit was filled or the position was closed outside of SignalPipe.

Quote Refreshing

The dashboard periodically polls for updated price quotes every 15 seconds, keeping P&L values current without requiring a full dashboard reload.

Safety Order Race Condition Detection

SignalPipe includes built-in race condition protection during the safety order flow. Before cancelling an existing TP order to place an updated one, it checks the TP order's status on Alpaca:

  • If the TP order is still open -- It is cancelled and a new TP is placed at the recalculated price
  • If the TP order was already filled -- The deal is immediately marked as completed with the realized P&L, and the safety order buy that was just placed is noted in the deal record

This prevents a scenario where a safety order buy is placed for a position that has already been sold by the TP fill.

This is a static view of a single section. For full search and interactivity visit the docs app. Open interactive docs →