A crypto trading bot built by a Chinese team meets two kinds of failure in production: the venue refuses requests under its own rules, and the connection between bot and venue breaks. Both are usually traceable to how the API layer was designed rather than to the strategy itself. This article catalogs the common failure modes, their symptoms, the engineering fix each requires, and the contract term that makes the vendor accountable for the fix. Buyers should note that venue rate limiting is enforced per account and per endpoint, varies across venues, and can change without notice; building around it is an engineering requirement, not a tuning exercise. Automated crypto trading may be restricted or prohibited in some jurisdictions, and local legal advice should be obtained before any deployment. The following is technical information and a risk disclaimer for buyers, not investment advice; no profit, yield, or return figure is stated or implied.
How venue limits are actually enforced
Most major venues enforce limits as a weight budget rather than a flat request count. Each endpoint carries a weight value, weight refills over a rolling window, and certain actions such as placing orders, cancelling orders in bulk, or pulling large order books consume more weight than a simple balance query. Limits are tracked separately for REST and for WebSocket streams, and some venues also cap message rate on private streams. A bot that sends a high-frequency polling loop against a heavy endpoint can exhaust the budget within seconds, even if its raw request count looks modest on a server dashboard. Vendors new to venue integration often discover this only in production, because testnet environments typically apply looser limits than live ones.
Limit responses are also uneven across venues. Some return a standard 429 with a retry-after header; others return 403 or 418 with a body describing the blocked period; a few quietly queue requests or throttle silently, which makes the bot appear slow rather than rejected. A robust integration parses the venue’s actual response codes and headers, applies a backoff that matches the refill window, and tracks consumed weight locally so the bot can stay under the budget before the venue enforces it. Local tracking is what separates a bot that manages its own rate limiting from one that reacts after each rejection.
The failure catalogue, symptom by symptom
| Failure mode | Symptom in operation | Engineering fix | Contract term to require |
|---|---|---|---|
| Weight bucket exhausted by polling | Intermittent 429s; orders delayed; some queries missing from logs | Replace polling with WebSocket streams where available; cache lightweight data locally; spread requests across the refill window | Vendor delivers a documented per-endpoint weight map and proves the bot stays under the live budget for the observation window |
| Bulk cancel or batch order spike | Short burst of rejections after a restart or rebalance; missing cancellations | Throttle batch operations to the venue’s per-second allowance; sequence cancellations with acknowledgement before the next batch | Acceptance case that fires a bulk cancel under load and verifies every resting order is accounted for |
| Signature or timestamp rejection | Requests return authentication errors even when the key is valid; reconnect loops | Synchronize server clock with a reliable time source; build the signed payload in the same order the venue expects; reject and re-sign requests outside the venue’s time window | Test case that deliberately skews the clock and confirms the bot handles rejection without duplicate orders |
| WebSocket drop without close frame | Bot believes it is still subscribed; local state goes stale; no fills arrive for minutes | Heartbeat or ping-pong watchdog; forced reconnect after a silence threshold; resubscribe to streams on reconnect | Runbook describing reconnect timing, resubscription order, and what alerts fire on stream silence |
| Unknown order state after disconnect | Bot cannot tell whether an order filled, rests, or was cancelled; duplicate risk appears | On reconnect, query the venue’s order status before acting; reconcile local state against the exchange record; surface discrepancies for review | State reconciliation flow documented in the repository, with a log entry per reconciled order |
| Ban or restriction from repeated errors | Account-level access blocked for a fixed period; recovery requires manual intervention | Circuit breaker that stops sending after repeated errors; alert to the buyer; backoff that grows with consecutive failures | Limit policy aligned to the venue’s written rules, with the breaker threshold stated in configuration the buyer can read |
The catalogue repeats across venues because the underlying mechanisms are shared: weight budgets, signed requests, stateless REST, stateful streams, and order state that lives on the venue side. What changes between venues is the code and the numbers, not the list of failures. A vendor who claims its bot works across venues without per-venue adaptation has usually not looked at the per-venue rules closely.
Signature and timestamp failures that look like key problems
Authentication failures are the most misdiagnosed category. A timestamp skewed beyond the venue’s accepted window, a payload whose parameters are sorted differently than the venue expects, a secret copied with a trailing character, or a base64 step applied to the wrong field can all produce a valid-looking request that the venue rejects. The symptom is usually a persistent auth error from the first request onward, rather than intermittent failure, which distinguishes it from a rate-limit problem. The fix belongs in a dedicated signing module that builds the string, signs it, and exposes the exact payload for debugging; when every request passes through one module, the buyer can review the signing logic once instead of searching it across the codebase.
Server time deserves its own line. A bot running on a host whose clock drifts several seconds will begin failing authentication under venues with tight windows, and the failure can look random if the drift moves in and out of tolerance. The deployment should keep system time synchronized through the host’s time service, and the signing module should include the current timestamp in every request rather than reusing one captured at startup. Buyers should ask the vendor how clock drift is detected and corrected, because a host that has lost its time source will not recover by itself. A related trap is reusing a timestamp after a failed attempt: if the first request failed the time check, a retry with the same timestamp fails again, and the bot should generate a fresh timestamp and a fresh signature for each attempt rather than resending the original signed string.
Disconnects, reconnects, and state reconciliation
Network paths between the bot and the venue drop routinely: local routers restart, cloud providers rotate endpoints, streams are closed by intermediaries, and venue-side maintenance windows interrupt private feeds. The bot’s reconnect logic must assume the stream may have died without a close frame. A watchdog measuring time since the last message is more reliable than relying on close events, because silent drops are the common case. On reconnect, the sequence matters: verify the connection, resubscribe to the required streams, reconcile open orders and recent fills against the venue, and only then resume placing new orders. Acting before reconciliation is how duplicate orders appear.
Partial fills complicate the state picture further. An order that rested for an hour may fill in two or three pieces, and each piece arrives as its own update. The bot must aggregate fills against the order’s total filled quantity, report the remaining size accurately, and avoid cancelling an order whose fill status is still catching up in the stream. Reconciliation should compare the bot’s recorded order state with the venue’s order history on each reconnect, and any mismatch should be logged with both versions visible. The permission model that limits what this reconciliation can affect is described in API permission models in China-built trading bots; the two reviews should happen together, because a bot with broad permissions and weak state handling is the worst combination.
What the failure-handling section of the contract should require
Vendors often quote only the happy path: how fast orders place, how the dashboard displays, how the strategy runs in the demo. The contract should instead fix the failure behavior in writing. Require a documented per-endpoint limit map for each target venue, a local weight tracker with a configurable headroom below the venue’s limit, a circuit breaker that halts sending after consecutive failures, and alerting that reaches the buyer’s channel rather than only the vendor’s panel. Require the reconnect and reconciliation sequence in writing, and require acceptance cases that force the failures: kill the stream, skew the clock, fire a bulk cancel, and check that the bot recovers without duplicate orders.
Support responsibility should match the failure catalogue. For the pilot window, the vendor should state who monitors the bot overnight, what response times apply, and what the buyer may do independently while waiting. Buyers running the bot across venues should also confirm whether the vendor’s hosting region gives a stable network path to each venue; latency and routing between the host and the venue are addressed in latency requirements for arbitrage bots built in China. Where the buyer’s own jurisdiction restricts venue access or derivatives, that restriction overrides any technical capability described here; the venue may simply refuse the connection, and legal review precedes deployment. The material in this article describes how API failures surface and how engineering responds to them; it carries no suggestion that any bot behaves predictably under live markets, and it does not advise any trading action.
Leave a Reply