@bitget-ai/bitget-agent-skill 1.2.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/skills/SKILL.md CHANGED
@@ -1,23 +1,32 @@
1
1
  ---
2
2
  name: bitget
3
3
  description: >
4
- Use this skill whenever the user wants to check prices, manage account balances,
5
- place or cancel orders, manage futures or spot positions, set leverage, transfer
6
- funds, check funding rates, use demo/paper trading, or do anything else on the
7
- Bitget exchange. Invoke this skill even when the user doesn't say "Bitget" by name
8
- — action phrases like "check my open orders", "cancel my BTC position", "move USDT
9
- to futures", "what's my P&L", "place a market sell", "how much can I withdraw",
10
- "show my positions", "set leverage to 10x", "what's the funding rate" all require
11
- this skill. Also invoke for Chinese-language trading requests such as "查看我的账户",
12
- "下一个限价单", "查看持仓盈亏", "转账到合约账户", "BTC现在多少钱" — these are Bitget
13
- operations even without the exchange name. Always invoke this skill before attempting
14
- any exchange trading task from scratch.
4
+ Use this skill whenever the user wants to check prices, pull candlesticks / K-line
5
+ (OHLCV) history, the orderbook or other market data, manage account balances,
6
+ place or cancel orders, manage futures/spot/margin positions, set leverage or
7
+ margin/position mode, transfer funds, deposit or withdraw, check funding rates,
8
+ use demo/paper trading, take loans, or do anything else on the Bitget exchange.
9
+ Invoke this skill even when the user doesn't say "Bitget" by name — action phrases
10
+ like "check my open orders", "cancel my BTC position", "move USDT to futures",
11
+ "what's my P&L", "place a market sell", "how much can I withdraw", "show my
12
+ positions", "set leverage to 10x", "what's the funding rate", "show me BTC daily
13
+ candles", "pull the 4h K-line" all require this skill. Also invoke for
14
+ Chinese-language trading requests such as "查看我的账户",
15
+ "下一个限价单", "查看持仓盈亏", "转账到合约账户", "BTC现在多少钱", "看下K线", "查历史K线",
16
+ "设置杠杆", "提币" —
17
+ these are Bitget operations even without the exchange name. Always invoke this
18
+ skill before attempting any exchange trading task from scratch.
15
19
  ---
16
20
 
17
- # Bitget Skill
21
+ # Bitget Skill (Unified Trading Account / v3)
18
22
 
19
- You have access to the full Bitget exchange via the `bgc` CLI tool — spot, futures,
20
- account, margin, copy-trading, convert, earn, P2P, and broker operations.
23
+ Drive the Bitget exchange through the `bgc` CLI — one Unified Trading Account (UTA)
24
+ covering spot, margin, and futures, plus funds, sub-accounts, loans, and broker
25
+ operations. The CLI is a thin shell over the Bitget Agent SDK: the SDK owns action
26
+ dispatch, input validation, write-safety, and discovery, so this skill teaches you
27
+ the **grammar** and the **safe workflow**, then points you at the reference docs.
28
+
29
+ Reference docs live in this skill's `references/` directory (alongside this file).
21
30
 
22
31
  ## Step 1: Check prerequisites
23
32
 
@@ -25,148 +34,156 @@ account, margin, copy-trading, convert, earn, P2P, and broker operations.
25
34
  bgc --version
26
35
  ```
27
36
 
28
- If not found → tell the user: `npm install -g bitget-client`
37
+ If not found → tell the user: `npm install -g @bitget-ai/bitget-agent-cli`
29
38
 
30
- For private endpoints (account info, trading, transfers): credentials must be set.
31
- See `~/.claude/skills/bitget-skill/references/auth-setup.md`.
39
+ Public market data needs no credentials. Everything else (account, trading,
40
+ transfers, withdrawals) needs API credentials as environment variables. See
41
+ `references/auth-setup.md`.
32
42
 
33
- ## Step 2: Run the command
43
+ ## Step 2: The grammar (this replaced the old v2 grammar)
34
44
 
35
- ```bash
36
- bgc <module> <tool_name> [--param value ...]
45
+ ```
46
+ bgc <tool> [--action <name>] [--<param> <value> ...] [global flags]
37
47
  ```
38
48
 
39
- All output is JSON. The response always has:
40
- - `data` — the actual result
41
- - `endpoint` — which API was called
42
- - `requestTime` — request timestamp
43
-
44
- For the full list of tools and parameters, read:
45
- `~/.claude/skills/bitget-skill/references/commands.md`
46
-
47
- It has a table of contents — go directly to the relevant module section.
48
-
49
- For trading interfaces, detailed reference docs with full parameter descriptions, use cases, and examples are in:
50
- `~/.claude/skills/bitget-skill/references/trading/`
49
+ - **One verb per call.** There are 14 intent verbs (e.g. `market`, `order`,
50
+ `position`, `account_overview`, `transfer_funds`, `withdraw`).
51
+ - **`--action`** picks the intent for an action-routed verb
52
+ (`bgc order --action place`, `bgc position --action closeAll`).
53
+ A few verbs take no action (e.g. `account_overview` is a single-shot snapshot).
54
+ - **Values coerce by shape:** `true`/`false` → boolean, a value starting with `[`
55
+ or `{` → JSON (e.g. `--orders '[{...}]'`), everything else stays a string.
51
56
 
52
- | File | Covers |
53
- |------|--------|
54
- | `trading/spot-place-order.md` | Spot limit/market/batch orders, TP/SL presets |
55
- | `trading/spot-cancel-orders.md` | Cancel single, batch, or all spot orders |
56
- | `trading/spot-modify-order.md` | Modify (cancel-and-replace) a spot order |
57
- | `trading/spot-get-orders.md` | Query open/history spot orders |
58
- | `trading/spot-plan-orders.md` | Spot trigger/plan orders (stop-loss, breakout) |
59
- | `trading/futures-place-order.md` | Futures orders, one-way/hedge mode, TP/SL |
60
- | `trading/futures-modify-order.md` | Modify pending futures order: adjust TP/SL, price, size |
61
- | `trading/futures-cancel-orders.md` | Cancel futures orders |
62
- | `trading/futures-get-orders.md` | Query futures orders and fills |
63
- | `trading/futures-positions.md` | Current/history positions, PnL, liquidation price |
64
- | `trading/futures-leverage-config.md` | Set leverage, margin mode, position mode |
57
+ > The old v2 form `bgc <module> <tool_name>` (e.g. `bgc spot spot_get_ticker`) is
58
+ > **gone**. There are no separate spot/futures modules — one `--category` param
59
+ > (`SPOT`, `MARGIN`, `USDT-FUTURES`, `COIN-FUTURES`, `USDC-FUTURES`) selects the market.
65
60
 
66
- **Always read the relevant trading reference before constructing a trading command.**
61
+ ## Step 3: Discover before you assemble a call
67
62
 
68
- ## Futures: Close Position & TP/SL Quick Rules
63
+ Don't guess parameters. The CLI introspects its own live surface:
69
64
 
70
- Before placing ANY futures close or TP/SL order, check the position first:
71
65
  ```bash
72
- bgc futures futures_get_positions --productType USDT-FUTURES --symbol BTCUSDT
66
+ bgc discover # list domains + verb counts
67
+ bgc discover --domain trade # verbs in a domain
68
+ bgc discover --tool order # one verb: actions + full schema
69
+ bgc discover --tool order --action place # exact required/optional contract
70
+ bgc discover --search "funding rate" # keyword-search the whole surface
73
71
  ```
74
- Note: `holdSide` (long/short) and `posMode` (one_way_mode/hedge_mode).
75
-
76
- ### Close direction rules (most common mistake)
77
- | Position | `side` to close | Extra param |
78
- |----------|----------------|-------------|
79
- | Long (one-way mode) | `sell` | `reduceOnly: "YES"` |
80
- | Short (one-way mode) | `buy` | `reduceOnly: "YES"` |
81
- | Long (hedge mode) | `sell` | `tradeSide: "close"` |
82
- | Short (hedge mode) | `buy` | `tradeSide: "close"` |
83
-
84
- > **Selling to close a short is WRONG — it opens more short.**
85
-
86
- ### TP/SL options
87
- 1. **Preset at entry**: `presetStopSurplusPrice` / `presetStopLossPrice` on the opening order
88
- 2. **Add/modify after entry**: `futures_modify_order` with `newPresetStopSurplusPrice` / `newPresetStopLossPrice` — does NOT cancel the order; pass `"0"` to delete a preset
89
- 3. **Manual limit + reduceOnly**: place a separate limit close order at target price (use as fallback)
90
-
91
- Read `trading/futures-modify-order.md` before using `futures_modify_order`.
92
-
93
- ## Module quick-reference
94
-
95
- | Module | Use for |
96
- |--------|---------|
97
- | `spot` | Spot prices, orderbook, candles, spot orders |
98
- | `futures` | Perpetuals prices, positions, futures orders, leverage |
99
- | `account` | Balances, deposits, withdrawals, transfers, subaccounts |
100
- | `margin` | Margin assets, borrow/repay, margin orders |
101
- | `copytrading` | Follow traders, copy positions. **Note:** Copy positions are separate from regular futures — use `copy_get_positions` and `copy_close_position`, NOT `futures_place_order`, to manage them |
102
- | `convert` | Convert one coin to another. **Two-step flow required:** call `convert_get_quote` first (returns a quote ID + rate, valid ~10s), then `convert_execute`. Always show the quoted rate to user before executing |
103
- | `earn` | Savings/staking products, subscribe/redeem |
104
- | `p2p` | P2P merchants and orders |
105
- | `broker` | Broker subaccounts and API keys |
106
-
107
- ## Write operations: always confirm first
108
-
109
- Before running any command marked **Write operation: Yes**, summarize what it will do
110
- and ask the user to confirm. This includes: placing orders, cancelling orders, transfers,
111
- withdrawals, setting leverage, borrowing, redeeming earn products.
112
72
 
113
- Example confirmation:
114
- > "This will place a limit buy order for 0.01 BTC at $70,000 on BTCUSDT. Confirm?"
115
-
116
- Never silently execute a write operation.
117
-
118
- **Withdrawal safety:** Always show the chain name and destination address in the confirmation prompt. Wrong chain selection is irreversible — if the user hasn't specified a chain, list available chains and ask them to confirm before proceeding.
119
-
120
- **Market buy size:** For spot market buys, `size` is in quote coin (USDT), not base coin. Confirm the user's intent before constructing market buy orders to avoid near-zero silent executes.
121
-
122
- ## Handling errors
123
-
124
- If `bgc` returns `"ok": false`, read `error.suggestion` for the recovery action.
125
- Common fixes: `~/.claude/skills/bitget-skill/references/error-codes.md`
126
-
127
- When credentials are missing (`AUTH_MISSING`), show the user exactly which env vars to set.
73
+ `bgc discover --tool <verb> --action <name>` is the authoritative, always-current
74
+ parameter contract. **Read it before constructing any non-trivial command**, especially
75
+ for trading. Full guide: `references/discover-guide.md`.
76
+
77
+ A complete **static** catalog of every verb, action, and parameter is in
78
+ `references/commands.md` (auto-generated from the SDK — navigate by its domain TOC).
79
+
80
+ ## Output contract
81
+
82
+ All output is JSON.
83
+
84
+ - **Success** → stdout, exit 0: `{ endpoint, requestTime, data }` — `data` is the result.
85
+ - **Error** → stderr, exit 1: `{ ok: false, error: { type, category, message, suggestion, retryable }, timestamp }`.
86
+ - **`--dry-run`** → stdout, exit 0: `{ dryRun: true, operationId, wouldSend, ... }` — the would-send request, nothing sent.
87
+ - **Confirmation gate** → stdout, exit 0: `{ confirmationRequired: true, operationId, hint, ... }` — a high-risk write that was NOT executed because `--confirm` was absent. This is a **normal result, not an error.**
88
+
89
+ On error, branch on `error.category`: `auth`/`param` → fix the request and resend;
90
+ `balance`/`risk` → surface to the user (cannot self-heal); `rate`/`network` → back
91
+ off and retry; `config` → check account mode / credentials. See `references/error-codes.md`.
92
+
93
+ ## The 14 verbs
94
+
95
+ | Domain | Verb | Use for |
96
+ |--------|------|---------|
97
+ | market | `market` | Tickers, orderbook, candles, instruments, funding rate, open interest (public) |
98
+ | trade | `order` | Place/cancel/modify orders (single or batch), open/history/fills, max-openable |
99
+ | trade | `position` | Current/history positions, ADL rank, **close** (one, by symbol) / **closeAll** |
100
+ | trade | `strategy_order` | Trigger/plan orders: place/cancel/modify/open/history |
101
+ | account | `account_overview` | One-call snapshot: assets, settings, funding assets, (opt.) positions + fee rate |
102
+ | account | `account_config` | Account settings: leverage, position/holding mode (one-way/hedge), account mode (basic/advanced) |
103
+ | account | `repayment` | Repay liabilities |
104
+ | funds | `transfer_funds` | Transfer between accounts / sub-accounts |
105
+ | funds | `deposit` | Deposit address & records |
106
+ | funds | `withdraw` | **Withdraw** (high-risk) & records |
107
+ | funds | `funds_records` | Funding/transfer/deposit/withdraw history |
108
+ | subaccount | `subaccount` | Create/list sub-accounts, manage their API keys & assets |
109
+ | loan | `loan` | Crypto loans: borrow, repay, orders, collateral |
110
+ | tax | `tax` | Tax/transaction records |
111
+
112
+ Use `discover` for the actions and exact params of any verb.
113
+
114
+ ## Write safety: two different "confirms" — don't conflate them
115
+
116
+ Operations are graded **read < write < high**. There are TWO separate confirmation
117
+ concepts here, and mixing them up is the single biggest source of trading mistakes:
118
+
119
+ 1. **Confirm with the USER — for every write.** Before running ANY write (placing or
120
+ cancelling orders, transfers, withdrawals, setting leverage, borrowing, repaying),
121
+ summarize what it will do and get the user's go-ahead. This is your *behavior*, not
122
+ a CLI flag. Never silently execute a write.
123
+ > Example: "This places a limit BUY of 0.01 BTC at $70,000 on BTCUSDT (SPOT). OK to send?"
124
+
125
+ 2. **The `--confirm` flag — for high-risk ops only.** This is a CLI gate that ONLY four
126
+ operations require: `closeAllPositions`, `cancelAllOrders`, `withdrawal`,
127
+ `brokerSubaccountWithdrawal`. Without `--confirm` they return
128
+ `{ confirmationRequired: true }` and send nothing (a normal result, not an error).
129
+
130
+ **Ordinary writes do NOT take `--confirm`.** A plain `order --action place`, a single
131
+ `cancel`, a `transfer_funds`, a leverage change — these execute **live** the moment you
132
+ omit `--dry-run`. `--confirm` is not their gate and adding it changes nothing; the
133
+ user's go-ahead (concept 1) is what authorizes them.
134
+
135
+ **Don't guess which kind an action is — read its contract.**
136
+ `bgc discover --tool <verb> --action <name>` reports `riskLevel` (`read`|`write`|`high`)
137
+ and `requiresConfirm` (`true` only for the four high-risk ops).
138
+
139
+ Safety flags:
140
+ - `--dry-run` — preview the would-send request without sending it (great for showing the user exactly what will happen).
141
+ - `--confirm` — execute a **high-risk** operation. No effect on an ordinary write or a read.
142
+ - `--read-only` — block all writes for the session.
143
+ - `--paper-trading` — route writes to the Bitget demo environment (see below).
144
+
145
+ **Recommended patterns:**
146
+ - *Ordinary write:* preview with `--dry-run` (or just summarize the effect), get the user's OK, then run it — no `--confirm`.
147
+ - *High-risk write:* `--dry-run` to preview → show the user the `wouldSend` payload → on their OK, re-run with `--confirm`.
148
+
149
+ ## Trading specifics — read before trading
150
+
151
+ Before constructing futures close / TP-SL / withdrawal commands, read
152
+ `references/trading-safety.md`. Critical rules:
153
+
154
+ - **Close ONE position at market: `position --action close --symbol <PAIR>`.** High-risk →
155
+ needs `--confirm`; in hedge mode add `--posSide long|short`. It hard-requires `--symbol`, so it
156
+ can never flatten the whole category by omission.
157
+ - **Close EVERYTHING in a category: `position --action closeAll --category <CAT>`** (optionally
158
+ narrowed by `--symbol`) — also high-risk, needs `--confirm`.
159
+ - **Close at YOUR price instead of market:** `order --action place` with the OPPOSITE side — one-way
160
+ mode add `--reduceOnly yes`; hedge mode set `--posSide` to the side you're closing. (Selling to
161
+ "close" a short actually opens more short — check `position --action info` first.)
162
+ - **Limit orders require `--price`** (market orders take none); in hedge mode `--posSide` is required
163
+ too. `discover --tool order --action place` reports these under `conditionalRequired`.
164
+ - **TP/SL:** preset `--takeProfit` / `--stopLoss` on the opening order, or manage after entry via `strategy_order`.
165
+ - **Spot market BUY `qty` is in quote coin (USDT), not base coin** — confirm intent to avoid mis-sized orders.
166
+ - **Withdrawals:** always show the chain and destination address in the confirmation; wrong chain is irreversible.
167
+
168
+ ## Demo / paper trading
169
+
170
+ When the user wants to practice or says "demo"/"paper"/"simulated", add `--paper-trading`
171
+ to writes (needs separate demo credentials; mutually exclusive with `--read-only`). Keep
172
+ the whole session in one mode — never mix live and demo. See `references/demo-trading.md`.
128
173
 
129
174
  ## Output presentation
130
175
 
131
- - For prices/tickers: show symbol, last price, 24h change, volume in a readable summary
132
- - For order lists: table format with orderId, symbol, side, price, size, status
133
- - For balances: list coins with available and frozen amounts; skip dust balances (< 0.0001)
134
- - For futures positions: always show symbol, side (long/short), size, entry price, mark price, unrealized PnL, **liquidation price**, and leverage. Never omit liquidation price
135
- - For funding rates: show current rate, annualized rate, and next settlement time
136
- - For raw data the user didn't ask to see: summarize, don't dump the full JSON
176
+ - **Prices/tickers:** symbol, last price, 24h change, volume — readable summary, not raw JSON.
177
+ - **Order lists:** table with orderId, symbol, side, price, qty, status.
178
+ - **Balances:** coin, available, frozen; skip dust (< 0.0001).
179
+ - **Positions:** symbol, side (long/short), size, entry, mark, unrealized PnL, **liquidation price**, leverage. Never omit liquidation price.
180
+ - **Funding rates:** current rate, annualized, next settlement time.
181
+ - For raw data the user didn't ask to see: summarize, don't dump full JSON. Use `--view summary` (default) and `--fields` to trim large payloads.
137
182
 
138
- ## Usage examples
183
+ ## Escape hatch
139
184
 
140
- ```bash
141
- # Public market data (no credentials needed)
142
- bgc spot spot_get_ticker --symbol BTCUSDT
143
- bgc futures futures_get_ticker --productType USDT-FUTURES --symbol BTCUSDT
144
- bgc futures futures_get_funding_rate --productType USDT-FUTURES --symbol BTCUSDT
145
-
146
- # Account queries (requires credentials)
147
- bgc account get_account_assets
148
- bgc spot spot_get_orders --status open
149
- bgc futures futures_get_positions --productType USDT-FUTURES
150
-
151
- # Write operations (confirm before running)
152
- bgc spot spot_place_order --orders '[{"symbol":"BTCUSDT","side":"buy","orderType":"limit","price":"70000","size":"0.01"}]'
153
- bgc futures futures_set_leverage --productType USDT-FUTURES --symbol BTCUSDT --marginCoin USDT --leverage 10
154
- bgc account transfer --fromAccountType spot --toAccountType futures_usdt --coin USDT --amount 100
155
- ```
156
-
157
- ## Demo Trading Mode
158
-
159
- Use demo mode when the user wants to practice trading, test strategies, or explicitly asks for "demo", "paper trading", or "simulated trading".
185
+ If no verb fronts the operation you need, reach any catalog operation by id:
160
186
 
161
- **Setup:** The user needs a Bitget Demo API Key. See `~/.claude/skills/bitget-skill/references/demo-trading.md` for full setup steps.
162
-
163
- **For bgc CLI:** Add `--paper-trading` as the FIRST flag after `bgc`:
164
187
  ```bash
165
- bgc --paper-trading spot spot_get_ticker --symbol BTCUSDT
166
- bgc --paper-trading futures futures_get_positions --productType USDT-FUTURES
167
- bgc --paper-trading account get_account_assets
188
+ bgc raw --operationId <id> --args '{"category":"SPOT","symbol":"BTCUSDT"}'
168
189
  ```
169
-
170
- **For MCP tools:** The MCP server must be started with `--paper-trading`. If the user is asking to use demo mode via MCP but the server wasn't started with that flag, inform them they need to restart with `--paper-trading`.
171
-
172
- **Key rule:** In demo mode, add `--paper-trading` to EVERY bgc command in the session. Never mix demo and live commands in the same session.
@@ -1,36 +0,0 @@
1
- # Trading Reference Index
2
-
3
- Detailed documentation for each trading interface — parameters, use cases, and examples.
4
-
5
- ## Spot Trading
6
-
7
- | File | Commands Covered |
8
- |------|-----------------|
9
- | [spot-place-order.md](spot-place-order.md) | `spot_place_order` — limit, market, batch, TP/SL presets |
10
- | [spot-cancel-orders.md](spot-cancel-orders.md) | `spot_cancel_orders` — single, batch, cancel-all |
11
- | [spot-modify-order.md](spot-modify-order.md) | `spot_modify_order` — cancel-and-replace |
12
- | [spot-get-orders.md](spot-get-orders.md) | `spot_get_orders` — open, history, single lookup, pagination |
13
- | [spot-plan-orders.md](spot-plan-orders.md) | `spot_place_plan_order`, `spot_get_plan_orders`, `spot_cancel_plan_orders` — trigger orders |
14
-
15
- ## Futures Trading
16
-
17
- | File | Commands Covered |
18
- |------|-----------------|
19
- | [futures-place-order.md](futures-place-order.md) | `futures_place_order` — one-way/hedge mode, TP/SL, COIN-FUTURES |
20
- | [futures-cancel-orders.md](futures-cancel-orders.md) | `futures_cancel_orders` — single, batch, cancel-all |
21
- | [futures-get-orders.md](futures-get-orders.md) | `futures_get_orders`, `futures_get_fills` — open, history, detail |
22
- | [futures-positions.md](futures-positions.md) | `futures_get_positions` — current, history, PnL, liquidation |
23
- | [futures-leverage-config.md](futures-leverage-config.md) | `futures_set_leverage`, `futures_update_config` — leverage, margin mode, position mode |
24
-
25
- ## Quick Scenario Guide
26
-
27
- | Scenario | Files to Read |
28
- |----------|--------------|
29
- | Place my first spot order | spot-place-order.md |
30
- | Set up a stop-loss for spot | spot-plan-orders.md |
31
- | Open a leveraged long | futures-leverage-config.md → futures-place-order.md |
32
- | Close a futures position | futures-place-order.md (Case 4/6) |
33
- | Check my unrealized PnL | futures-positions.md |
34
- | Cancel all orders (emergency) | spot-cancel-orders.md (Case 3) or futures-cancel-orders.md (Case 3) |
35
- | Set up TP/SL on a futures trade | futures-place-order.md (Case 3, Case 8) |
36
- | DCA ladder of buy orders | spot-place-order.md (Case 6) |
@@ -1,113 +0,0 @@
1
- # futures_cancel_orders — Futures Cancel Orders
2
-
3
- ## Official Description
4
- Cancel one or more open futures orders by order ID, batch of IDs, or cancel all open orders for a contract.
5
-
6
- **Endpoint:** `POST /api/v2/mix/order/cancel-order` (single) | `POST /api/v2/mix/order/batch-cancel-orders` (batch) | `POST /api/v2/mix/order/cancel-all-orders` (cancel-all)
7
- **Auth required:** Yes
8
- **Rate limit:** 10 req/s per UID
9
-
10
- ---
11
-
12
- ## bgc CLI Usage
13
-
14
- ```bash
15
- bgc futures futures_cancel_orders \
16
- --productType <PRODUCT_TYPE> \
17
- --symbol <SYMBOL> \
18
- [--orderId <id> | --orderIds '[...]' | --cancelAll true] \
19
- [--marginCoin <coin>]
20
- ```
21
-
22
- ---
23
-
24
- ## Parameters
25
-
26
- | Parameter | Type | Required | Allowed Values | Description |
27
- |-----------|------|----------|----------------|-------------|
28
- | `productType` | string | Yes | `USDT-FUTURES`, `COIN-FUTURES`, `USDC-FUTURES` | Contract type |
29
- | `symbol` | string | Yes | e.g. `BTCUSDT` | Contract symbol |
30
- | `orderId` | string | No | e.g. `"1234567890"` | Cancel a single order |
31
- | `orderIds` | array | No | e.g. `["id1","id2"]` | Cancel up to 50 orders |
32
- | `cancelAll` | boolean | No | `true` | Cancel ALL open orders for the symbol |
33
- | `marginCoin` | string | No | e.g. `USDT` | Required for cancel-all on COIN-FUTURES |
34
-
35
- ---
36
-
37
- ## Response Fields
38
-
39
- | Field | Type | Description |
40
- |-------|------|-------------|
41
- | `orderId` | string | Cancelled order ID |
42
- | `clientOid` | string | Custom order ID if set |
43
-
44
- Batch responses include `successList` and `failureList`.
45
-
46
- ---
47
-
48
- ## Usage Cases
49
-
50
- ### Case 1: Cancel a single futures order
51
- ```bash
52
- bgc futures futures_cancel_orders \
53
- --productType USDT-FUTURES \
54
- --symbol BTCUSDT \
55
- --orderId "1234567890"
56
- ```
57
-
58
- ### Case 2: Cancel multiple specific orders
59
- ```bash
60
- bgc futures futures_cancel_orders \
61
- --productType USDT-FUTURES \
62
- --symbol BTCUSDT \
63
- --orderIds '["1234567890","9876543210"]'
64
- ```
65
-
66
- ### Case 3: Cancel all open orders for a contract
67
- ```bash
68
- bgc futures futures_cancel_orders \
69
- --productType USDT-FUTURES \
70
- --symbol BTCUSDT \
71
- --cancelAll true
72
- ```
73
- > Emergency exit from all open limit orders on BTCUSDT futures.
74
-
75
- ### Case 4: Cancel all orders before modifying leverage
76
- ```bash
77
- # Step 1: cancel all open orders (required before leverage change if orders exist)
78
- bgc futures futures_cancel_orders \
79
- --productType USDT-FUTURES \
80
- --symbol BTCUSDT \
81
- --cancelAll true
82
-
83
- # Step 2: update leverage
84
- bgc futures futures_set_leverage \
85
- --productType USDT-FUTURES \
86
- --symbol BTCUSDT \
87
- --marginCoin USDT \
88
- --leverage 20
89
- ```
90
-
91
- ### Case 5: Cancel COIN-FUTURES orders
92
- ```bash
93
- bgc futures futures_cancel_orders \
94
- --productType COIN-FUTURES \
95
- --symbol BTCUSD \
96
- --marginCoin BTC \
97
- --cancelAll true
98
- ```
99
-
100
- ---
101
-
102
- ## Important Notes
103
-
104
- - Cancelling an already-filled or expired order will return an error
105
- - For TP/SL orders (TPSL type): use a dedicated TPSL cancel endpoint — regular cancel may not work
106
- - `marginCoin` is required when using `cancelAll` on COIN-FUTURES contracts
107
- - After cancelling orders, verify with: `bgc futures futures_get_orders --productType USDT-FUTURES --status open`
108
-
109
- ---
110
-
111
- ## Official Docs
112
- - Cancel Order: https://www.bitget.com/api-doc/contract/trade/Cancel-Order
113
- - Batch Cancel: https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
@@ -1,155 +0,0 @@
1
- # futures_get_orders — Futures Query Orders
2
-
3
- ## Official Description
4
- Query futures orders: a specific order by ID, all open (unfilled) orders, or historical orders. Also supports querying fill records.
5
-
6
- **Endpoints:**
7
- - Order detail: `GET /api/v2/mix/order/detail`
8
- - Open orders: `GET /api/v2/mix/order/orders-pending`
9
- - History orders: `GET /api/v2/mix/order/orders-history`
10
- - Fills: `GET /api/v2/mix/order/fill-history`
11
-
12
- **Auth required:** Yes
13
- **Rate limit:** 10 req/s per UID
14
-
15
- ---
16
-
17
- ## bgc CLI Usage
18
-
19
- ```bash
20
- bgc futures futures_get_orders \
21
- --productType <PRODUCT_TYPE> \
22
- [--orderId <id>] \
23
- [--symbol <SYMBOL>] \
24
- [--status open|history] \
25
- [--startTime <ms>] \
26
- [--endTime <ms>] \
27
- [--limit <n>]
28
- ```
29
-
30
- ---
31
-
32
- ## Parameters
33
-
34
- | Parameter | Type | Required | Allowed Values | Description |
35
- |-----------|------|----------|----------------|-------------|
36
- | `productType` | string | Yes | `USDT-FUTURES`, `COIN-FUTURES`, `USDC-FUTURES` | Contract type (required always) |
37
- | `orderId` | string | No | e.g. `"1234567890"` | Fetch a specific order by exchange ID |
38
- | `symbol` | string | No | e.g. `BTCUSDT` | Filter by contract symbol |
39
- | `status` | string | No | `open` (default), `history` | `open` = pending; `history` = filled/cancelled |
40
- | `startTime` | string | No | Unix ms | History start time |
41
- | `endTime` | string | No | Unix ms | History end time |
42
- | `limit` | number | No | 1–100, default 100 | Number of results |
43
-
44
- ---
45
-
46
- ## Key Response Fields
47
-
48
- | Field | Type | Description |
49
- |-------|------|-------------|
50
- | `orderId` | string | Exchange order ID |
51
- | `clientOid` | string | Custom order ID |
52
- | `symbol` | string | Contract pair |
53
- | `side` | string | `buy` or `sell` |
54
- | `tradeSide` | string | `open`, `close`, `burst_close_long`, etc. |
55
- | `orderType` | string | `limit` or `market` |
56
- | `state` | string | `live`, `partially_filled`, `filled`, `canceled` |
57
- | `price` | string | Order price |
58
- | `priceAvg` | string | Average execution price |
59
- | `size` | string | Order size (base coin) |
60
- | `baseVolume` | string | Filled amount in base coin |
61
- | `quoteVolume` | string | Filled amount in quote coin |
62
- | `leverage` | string | Leverage at order time |
63
- | `marginMode` | string | `isolated` or `crossed` |
64
- | `marginCoin` | string | Collateral coin |
65
- | `posSide` | string | `long`, `short`, or `net` |
66
- | `posMode` | string | `one_way_mode` or `hedge_mode` |
67
- | `reduceOnly` | string | `YES` or `NO` |
68
- | `totalProfits` | string | Realized PnL |
69
- | `fee` | string | Fee charged |
70
- | `presetStopSurplusPrice` | string | TP trigger price |
71
- | `presetStopLossPrice` | string | SL trigger price |
72
- | `cancelReason` | string | `normal_cancel` or `stp_cancel` |
73
- | `cTime` | string | Created timestamp (ms) |
74
- | `uTime` | string | Last updated timestamp (ms) |
75
-
76
- ---
77
-
78
- ## Usage Cases
79
-
80
- ### Case 1: All open futures orders across all symbols
81
- ```bash
82
- bgc futures futures_get_orders --productType USDT-FUTURES --status open
83
- ```
84
-
85
- ### Case 2: Open orders for a specific contract
86
- ```bash
87
- bgc futures futures_get_orders --productType USDT-FUTURES --symbol BTCUSDT --status open
88
- ```
89
-
90
- ### Case 3: Fetch specific order details
91
- ```bash
92
- bgc futures futures_get_orders --productType USDT-FUTURES --orderId "1234567890"
93
- ```
94
- > Verify fill status, executed price, and PnL after placing an order.
95
-
96
- ### Case 4: View recent trade history
97
- ```bash
98
- bgc futures futures_get_orders \
99
- --productType USDT-FUTURES \
100
- --symbol BTCUSDT \
101
- --status history \
102
- --limit 20
103
- ```
104
-
105
- ### Case 5: History in a time range (e.g., today)
106
- ```bash
107
- bgc futures futures_get_orders \
108
- --productType USDT-FUTURES \
109
- --symbol BTCUSDT \
110
- --status history \
111
- --startTime "1700000000000" \
112
- --endTime "1700086400000"
113
- ```
114
-
115
- ### Case 6: Check order was filled before acting on it
116
- ```bash
117
- bgc futures futures_get_orders --productType USDT-FUTURES --orderId "1234567890"
118
- # Check "state": "filled" in response before proceeding
119
- ```
120
-
121
- ### Case 7: Get fill details (execution prices per fill)
122
- ```bash
123
- bgc futures futures_get_fills --productType USDT-FUTURES --symbol BTCUSDT --orderId "1234567890"
124
- ```
125
- > For individual fill records with exact execution prices, use `futures_get_fills`.
126
-
127
- ---
128
-
129
- ## tradeSide Values Reference
130
-
131
- | Value | Description |
132
- |-------|-------------|
133
- | `open` | Opening a position |
134
- | `close` | Closing a position |
135
- | `burst_close_long` | Liquidation of long |
136
- | `burst_close_short` | Liquidation of short |
137
- | `delivery_close_long` | Delivery settlement long |
138
- | `delivery_close_short` | Delivery settlement short |
139
-
140
- ---
141
-
142
- ## Important Notes
143
-
144
- - `productType` is **always required** even for single-order lookup
145
- - `startTime`/`endTime` only apply to `status=history`
146
- - `state=partially_filled` means the order is still open with partial fill
147
- - For TP/SL order history, check `orderSource` field for `profit_limit` type orders
148
- - PnL in `totalProfits` is for closed/partially-closed orders only
149
-
150
- ---
151
-
152
- ## Official Docs
153
- - Order Detail: https://www.bitget.com/api-doc/contract/trade/Get-Order-Details
154
- - Open Orders: https://www.bitget.com/api-doc/contract/trade/Get-Unfilled-Orders
155
- - History Orders: https://www.bitget.com/api-doc/contract/trade/Get-History-Orders