Binance Trade Mirror
A master → follower futures mirror in under 200 lines — proportional sizing, drift cleanup and a Telegram audit trail.
Client engagement — source code stays private. Shown: architecture and flows.
Binance Trade Mirror keeps one USDT-margined futures account mirrored onto another in near real time. A one-second poll watches the master account; the moment a new position appears, the follower opens a scaled copy — sized by a configured proportion of the master's notional, divided by leverage — and a dedicated monitor thread takes over that symbol.
Mirroring is the easy half; staying in sync is the real job. The monitors copy partial reductions proportionally — clamped so the follower can never sell more than it actually holds — copy additions, and ignore dust: changes under a $5 notional dead-band don't churn orders. When the master exits, any residual on the follower is closed too, so drift never accumulates. Stop-loss and take-profit changes on the master are broadcast to Telegram for the human in the loop.
It's a deliberately small tool — one process, two accounts, in-memory state — where the value is in the edge handling, not the line count.
System architecture
The modules that make it up, and how data flows between them.
Reads master positions every 1s
Scales notional · mirrors order
Thread per position · size / exits
Signal + private feeds
Hover a module to trace what it feeds.
Mirror flow
One master position, end to end — from detection to drift-free exit.
- 1
Boot
Both account clients initialize and per-symbol quantity precisions are cached from exchange metadata.
- 2
Poll
The master's open positions are fetched every second.
- 3
Position triage
New positionSide inferred, size scaled (notional × proportion ÷ leverage), market order placed on the follower, monitor thread spawned, Telegram notified.
Known positionAlready mirrored — its monitor thread handles everything from here.
- 4
Monitor decisions — every tick
Master exitedAny residual follower notional is market-closed, state cleared, thread ends — drift can't survive an exit.
Size changedReductions and additions beyond the $5 dead-band are copied proportionally, with reductions clamped to what the follower actually holds.
Stops changedNew stop-loss or take-profit prices on the master are broadcast to Telegram.
Engineering highlights
The details that keep it alive with real money on the line.
Dead-band against churn
A $5 notional threshold filters dust-level changes, so the follower isn't paying fees to mirror noise.
Clamped reductions
A computed reduction larger than the follower's actual holding closes the position cleanly instead of overselling.
Residual cleanup
Master exits always sweep the follower's leftover notional — proportional rounding errors never compound across trades.
Precision from metadata
Quantity rounding comes from the exchange's own per-symbol rules, cached at startup.
Under the hood
The stack, and the system in numbers.