Abhi-AlgoForge Back home

Binance Webhook Executor

A lean TradingView → Binance Futures bridge with self-healing trailing stops — built to run many instances side by side.

Client engagement — source code stays private. Shown: architecture and flows.

Sometimes the right system is a small one. This executor does exactly one thing: receive TradingView alerts with zero added latency and execute them on Binance USDT-margined futures. Every incoming signal is forked into its own process, so the webhook answers instantly no matter what execution is doing — the client's requirement was running ten to twenty of these concurrently.

The trade lifecycle is complete despite the footprint: an opposite signal flips the position (close, cancel, retrack), leverage is set, a market entry is sized as a percentage of balance with full exchange-precision rounding, a stop-market order goes in — and then a one-second trailing loop ratchets that stop along with price until it fills.

At around four hundred lines, the engineering is in the edges: every exchange call wrapped in bounded retries with clean abort paths, and a trailing monitor that survives Binance losing track of its own orders — when the stop order ID vanishes, the bot rediscovers it from open orders and carries on.

System architecture

The modules that make it up, and how data flows between them.

Webhook receiver

Forks a worker per TradingView signal

Execution engine

Sizing · entry · stop placement

Trailing-stop monitor

1s ratchet · self-heals

Hover a module to trace what it feeds.

Signal flow

One alert, end to end — from webhook to a trailed exit.

  1. 1

    Alert arrives

    TradingView posts the signal; it's parsed and handed to a fresh worker process, and the webhook answers immediately.

  2. 2

    Reversal check

    Opposite position open

    The existing position is market-closed with retries, its orders cancelled and state cleared — then the new side proceeds.

    Fresh signal

    No conflict — straight to sizing.

  3. 3

    Sizing

    Quantity from balance × margin % × leverage at mark price, rounded to the symbol's step size and precision.

  4. 4

    Entry + stop

    Market entry placed (three bounded attempts), then a stop-market order at entry ± trail distance, snapped to the tick grid.

  5. 5

    Trailing loop — every second

    Stop filled

    The trade is done — state cleaned up, symbol untracked.

    New favorable high

    Orders cancelled and the stop re-placed at the newly trailed price.

    Stop order vanished

    After Binance's "order does not exist", the monitor rediscovers the order ID from open orders and resumes.

Engineering highlights

The details that keep it alive with real money on the line.

Process-per-signal isolation

Each alert executes in its own process — webhook latency stays near zero and one stuck trade can't block another.

Bounded retries everywhere

Every exchange call gets three attempts with backoff and a clean abort path when they exhaust — no infinite loops, no half-states.

Self-healing stops

Lost stop-order IDs are rediscovered from the open-order list instead of crashing the monitor — the trail never silently dies.

Exchange-aware rounding

Per-symbol precision, step size and half-tick stop offsets — orders shaped so the exchange has no reason to reject them.

Under the hood

The stack, and the system in numbers.

Engine
PythonFlaskpython-binancemultiprocessing
Broker
Binance USDT-M Futures
~410
Lines of code
3×
Bounded retries per call
1s
Trailing loop
20
Concurrent bots by design

Need a system like this?

I design and build trading infrastructure end to end — let's talk about yours.