n8n-nodes-bitget-f-close
v1.1.1
Published
n8n custom node for Bitget Futures — Flash Close All (positions + orders + TP/SL)
Downloads
304
Maintainers
Readme
n8n-nodes-bitget-futures
A custom n8n community node for Bitget Futures trading — featuring a Flash Close All operation that closes every open position and cancels every order (including TP/SL) in a single node execution, just like Bitget's own "Flash Close" button.
📦 Installation
Option A — n8n Community Nodes (Recommended)
- In n8n, go to Settings → Community Nodes
- Click Install
- Enter package name:
n8n-nodes-bitget-futures - Click Install
Option B — Manual (this ZIP)
Copy this folder to your n8n custom extensions directory:
~/.n8n/custom/So the path becomes:
~/.n8n/custom/n8n-nodes-bitget-futures/Restart n8n. The Bitget Futures node will appear in the node palette.
Option C — Docker
Mount the folder as a volume and set the env var:
environment:
- N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/custom
volumes:
- ./n8n-nodes-bitget-futures:/home/node/.n8n/custom/n8n-nodes-bitget-futures🔑 Credentials Setup
- In n8n go to Credentials → New Credential → Bitget Futures API
- Fill in:
- API Key — from Bitget API management page
- Secret Key — your API secret
- Passphrase — the passphrase you set when creating the key
- Trading Environment — choose
Demo(safe) orLive(real money)
⚠️ Always test with Demo first! Live trading uses real funds.
API Key Permissions Required
- ✅ Trade — required for all order/position operations
- ✅ Read — required for fetching positions
⚙️ Operations
⚡ Flash Close All — Positions + Orders + TP/SL (Main Feature)
Executes a full account nuke in 3 sequential steps:
| Step | API Endpoint | What it does |
|------|-------------|--------------|
| 1 | POST /api/v2/mix/order/cancel-all-orders | Cancels ALL regular open limit/market orders |
| 2 | POST /api/v2/mix/order/cancel-plan-order | Cancels ALL TP/SL plan orders (per-symbol, auto-detected from positions) |
| 3 | POST /api/v2/mix/order/close-positions | Flash-closes ALL open positions at market price |
Parameters:
Product Type— USDT-FUTURES / COIN-FUTURES / USDC-FUTURESMargin Coin— USDT, USDC, or base coinSymbol(optional) — restrict to one trading pair (e.g.BTCUSDT), empty = ALLHold Side(hedge mode) — Both / Long only / Short onlyContinue on Partial Failure— if true, continues even if one step errors
Returns:
{
"environment": "DEMO",
"productType": "SUSDT-FUTURES",
"symbol": "ALL",
"overallStatus": "success",
"cancelAllOrders": { "status": "success", "data": {...} },
"cancelTpslOrders": { "status": "success", "data": [...] },
"flashClosePositions": { "status": "success", "data": {...} },
"timestamp": "2024-01-15T10:30:00.000Z"
}Flash Close Positions Only
Closes all open positions at market price without touching pending orders.
- Endpoint:
POST /api/v2/mix/order/close-positions
Cancel All Open Orders
Cancels all regular limit/market orders (not plan/TP/SL orders).
- Endpoint:
POST /api/v2/mix/order/cancel-all-orders
Cancel All TP/SL Plan Orders
Cancels all take-profit and stop-loss plan orders.
- Endpoint:
POST /api/v2/mix/order/cancel-plan-order - Auto-fetches open positions to determine which symbols to target
Get All Open Positions
Returns a full list of currently open futures positions.
- Endpoint:
GET /api/v2/mix/position/all-position
🌍 Demo vs Live Environment
The environment can be set in two places:
- Credential level — set a default in the API credential
- Node level — per-node override via
Trading Environmentdropdown
The node-level setting wins over the credential setting (unless set to "Use Credential Setting").
How Demo Works
Bitget uses separate product type prefixes for demo accounts:
| Live | Demo |
|------------------|-------------------|
| USDT-FUTURES | SUSDT-FUTURES |
| COIN-FUTURES | SCOIN-FUTURES |
| USDC-FUTURES | SUSDC-FUTURES |
The node automatically maps product types when demo mode is active — you always select the "live" name and it converts internally.
🔐 Authentication (Technical)
Bitget uses HMAC-SHA256 signed requests:
Signature = Base64(HMAC-SHA256(timestamp + METHOD + path + body, secretKey))Headers required on every request:
ACCESS-KEY— your API keyACCESS-SIGN— computed signatureACCESS-TIMESTAMP— Unix ms timestampACCESS-PASSPHRASE— your API passphraseContent-Type: application/json
All signing is handled automatically by the node.
📁 File Structure
n8n-nodes-bitget-futures/
├── package.json # npm package manifest + n8n registration
├── tsconfig.json # TypeScript config
├── README.md # This file
├── src/ # TypeScript source
│ ├── index.ts
│ ├── credentials/
│ │ └── BitgetFuturesApi.credentials.ts
│ └── nodes/
│ └── BitgetFutures/
│ ├── BitgetFutures.node.ts # Main node logic
│ ├── bitgetApi.ts # API signing + request helper
│ └── bitget.svg # Node icon
└── dist/ # Pre-compiled JavaScript (ready to use)
├── index.js
├── credentials/
│ └── BitgetFuturesApi.credentials.js
└── nodes/
└── BitgetFutures/
├── BitgetFutures.node.js
├── bitgetApi.js
└── bitget.svg🔧 Building from Source (Optional)
If you want to modify the TypeScript source and rebuild:
npm install
npm run buildRequires Node.js 18+ and TypeScript 5+.
⚠️ Disclaimer
This node is provided as-is for automation purposes. Futures trading involves significant financial risk. Always test with the Demo environment before using with real funds. The authors are not responsible for any trading losses.
