Upstream risk infrastructure for private trading bots
Your bot decides what to trade. UseBullion decides whether it should — using real-time macro bias, central-bank stance, COT positioning, and news blackouts. One HTTP call, HMAC-signed decisions, full audit trail. No such layer exists elsewhere.
Quickstart
- Sign in and mint a key in the Developer portal.
- Store it as
USEBULLION_KEYin your bot's secret manager. - On every entry signal your bot generates, POST to
/api/public/v1/risk/precheck. - If
decision !== "approved", drop the trade — UseBullion has blocked it for a reason.
curl -X POST https://usebullion.com/api/public/v1/risk/precheck \
-H "Authorization: Bearer ub_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{ "symbol": "XAUUSD", "side": "buy", "volume": 0.10, "requestId": "trade-abc-123" }'Endpoints
/api/public/v1/risk/precheckPre-trade decision
{ symbol?, side, volume?, requestId? }. Returns approved or blocked with reason code, macro factors, and audit metadata./api/public/v1/risk/killswitchAm I allowed to trade right now?
{ allowed, reasons[] } combining trial gate + news blackout./api/public/v1/risk/streamLive SSE feed (killswitch + decisions)
hello, killswitch (every 5s), and decisionframes as new precheck rows land. Every frame is HMAC-signed inside the payload. Auth viaAuthorization header or ?token= query param (for EventSource)./api/public/v1/macro/biasCurrent composite bias
bias (long / short / flat), score, confidence, and per-source factor breakdown./api/public/v1/positionsDeclare an open position
{ externalId?, symbol, side, volume, entryPrice?, sl?, tp?, status? }. Upserted by(user, externalId). Used to enforce net-exposure limits across your bots./api/public/v1/positionsList open positions
/api/public/v1/decisions?since=ISO&limit=NSigned audit trail
Authentication
Send your key in the Authorization header:
Authorization: Bearer ub_live_XXXXXXXX…
Keys are hashed at rest (SHA-256). UseBullion only ever shows the plaintext at creation time. Revoke instantly from the developer portal. Default rate limit: 60 requests per minute per key.
Verifying signed responses
Every response includes X-UseBullion-Signature: sha256=… and X-UseBullion-Timestamp. Verify with the shared signing secret UseBullion issues on request (contact support to enable outbound verification).
import crypto from "node:crypto";
function verify(body: string, signatureHeader: string, timestampHeader: string, secret: string) {
const expected = "sha256=" + crypto
.createHmac("sha256", secret)
.update(`${timestampHeader}.${body}`)
.digest("hex");
// constant-time compare
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signatureHeader));
}Error codes
| HTTP | code | Meaning |
|---|---|---|
| 400 | invalid_input | Missing or malformed field (e.g. side must be buy or sell). |
| 401 | unauthorized / invalid_key / revoked | Bearer token missing, unknown, or revoked. |
| 402 | upgrade_required | Free-plan 7-day private-bot trial expired. Upgrade to continue. |
| 403 | insufficient_scope | Key lacks the scope for this endpoint. |
| 423 | news_blackout / macro_bias | Risk engine actively blocked the trade. |
| 429 | rate_limited | Rate limit exceeded — back off and retry. |
| 500 | server_error / db_error | UseBullion side error. Fail-closed: do not trade. |
Ready to give your bot an institutional-grade risk layer? Mint your first key →