DEV Community

Cover image for No exchange order fires on a candle close, so I put the rule on my glasses
Edy Cu
Edy Cu

Posted on Edited on Originally published at github.com

No exchange order fires on a candle close, so I put the rule on my glasses

A price stop on the exchange is durable, but it sells the wick. Plenty of futures traders run a different rule in their heads: "if the 1H candle closes below my line, I'm out." That rule survives the wick. The catch is that you have to be at a screen at the close, and the close often lands mid-meeting or mid-commute.

I checked whether Binance could hold the rule for me. It can't. Every USDⓈ-M conditional order triggers on a price touch (workingType is MARK_PRICE or CONTRACT_PRICE). There is no close trigger. So I built Close Call for the Even Realities "Heads Up" hackathon (Exchanges & Stocks track).

What it does

  1. On your phone you arm one rule: a line (prefilled with your last line, else the last closed 1H low/high), a side and an interval (1H / 4H / 1D, plus a labelled 1m demo mode).
  2. In the last 60 s of the armed bar, Even G2 shows three lines: 1H closes 0:13, price vs line, and a draining bar with tap = skip.
  3. One tap vetoes this bar's close. The next bar decides again.
  4. Do nothing, and if the bar closes past your line (kline k.x = true), the server sends a reduce-only MARKET close 1,000 ms after the boundary, so a late tap still lands.
  5. Underneath, the whole time, a disaster stop rests on Binance itself. A dead server, phone or pair of glasses doesn't leave the position unprotected, and arming is refused unless Binance accepted that stop.

Two layers, stated plainly: your line decides at the close. The wider disaster stop (default 1.5 % beyond the line) is an ordinary Binance price stop and can fire on a deep wick. Close Call never claims to be "wick-proof".

Does the close rule actually matter?

I replayed 500 testnet 1H BTCUSDT bars. A plain stop at the previous bar's low would have fired 259 times. The close rule fired 152 times. 107 (41.3 %) of the plain-stop fires were wick-only breaches that closed back over the line.

This is a descriptive replay, not P&L and not a stop-out rate, and testnet wicks are likely more frequent than mainnet's.

How it's built

Layer Technology Why
Glasses Even Hub SDK 0.0.16 (text containers, touchpad click) three short lines read at a glance on 576×288; one tap is the whole interaction
Backend Node/TypeScript, Binance USDⓈ-M Futures Testnet REST + kline WebSocket the rule has to live on a server that outlives the phone
Pairing single-use code, 128-bit bearer token the backend moves money; an open port must not obey strangers
Tests Vitest 149 server + 45 lens tests passing

The close signal is the kline stream's k.x flag. The disaster stop goes through POST /fapi/v1/algoOrder, and fills are read back with a signed GET /fapi/v1/order.

Three things testnet taught me

  • STOP_MARKET on the classic endpoint is refused on testnet (-4120, "please use the Algo Order API endpoints"). The disaster stop therefore uses the algo-order endpoint, which has its own params plus separate cancel and query paths.
  • A REST kline row for a just-closed bar isn't final yet. Read 3 s after the boundary, it disagreed with the settled candle on 5 of 12 bars in one run (max 14.4 USDT; 2 of 12 in a repeat), while the stream's k.x close matched 12 of 12. The REST fallback therefore uses the last aggTrade.
  • G2 has no font-size control, so the countdown has to read as plain text: three lines with ASCII separators.

Safety rails on the money path

  • The order client refuses non-testnet hosts.
  • Auto-disarm removes the disaster stop only after two consecutive flat position reads.
  • A bar decided more than 67 s late is never sent.
  • A veto must target the active bar.

Proof, not promises

The demo is one continuous live session in the Even Hub simulator against Binance Futures testnet. On bar 1, one tap: vetoed, no order. On bar 2, no tap: k.x at +718 ms, close decided at +1,003 ms, reduce-only order sent at +1,189 ms, filled at 59,463.8 at +1,231 ms exchange time. Then the server is SIGKILLed while armed, and Binance still lists the disaster stop. An evidence gate checks every order file in the repo.

Limits (honest list)

Simulator only (no G2 hardware was available). Testnet candles. One symbol (BTCUSDT) and one rule. No hosted backend: you run it with your own testnet key. The countdown needs the lens awake, but the server still closes and the stop stays on Binance either way. The full list is in the README.

Testnet only, reduce-only, no custody, not financial advice.

Code: https://github.com/edycutjong/closecall · Site and deck: https://closecall.edycu.dev

Top comments (0)