@bitget-ai/bitget-agent-skill 1.2.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/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +123 -0
- package/VERSION +1 -0
- package/package.json +47 -0
- package/references/auth-setup.md +26 -0
- package/references/commands.md +1258 -0
- package/references/demo-trading.md +55 -0
- package/references/error-codes.md +53 -0
- package/references/trading/README.md +36 -0
- package/references/trading/futures-cancel-orders.md +113 -0
- package/references/trading/futures-get-orders.md +155 -0
- package/references/trading/futures-leverage-config.md +184 -0
- package/references/trading/futures-modify-order.md +173 -0
- package/references/trading/futures-place-order.md +429 -0
- package/references/trading/futures-positions.md +154 -0
- package/references/trading/spot-cancel-orders.md +87 -0
- package/references/trading/spot-get-orders.md +120 -0
- package/references/trading/spot-modify-order.md +95 -0
- package/references/trading/spot-place-order.md +166 -0
- package/references/trading/spot-plan-orders.md +160 -0
- package/scripts/gen-references.js +70 -0
- package/scripts/install.js +177 -0
- package/skills/SKILL.md +172 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# futures_modify_order — Futures Modify Order
|
|
2
|
+
|
|
3
|
+
## Official Description
|
|
4
|
+
Modify a pending futures order. Can update TP/SL trigger prices, limit price, and size.
|
|
5
|
+
|
|
6
|
+
**Key behavior difference:**
|
|
7
|
+
- Modifying **only TP/SL** (`newPresetStopSurplusPrice` / `newPresetStopLossPrice`): **does NOT cancel the original order** — in-place update
|
|
8
|
+
- Modifying **size/price** (`newSize` + `newPrice`): **cancels and recreates** the order with a new `orderId`
|
|
9
|
+
|
|
10
|
+
**Endpoint:** `POST /api/v2/mix/order/modify-order`
|
|
11
|
+
**Auth required:** Yes
|
|
12
|
+
**Rate limit:** 10 req/s per UID
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## bgc CLI Usage
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bgc futures futures_modify_order \
|
|
20
|
+
--symbol BTCUSDT \
|
|
21
|
+
--productType USDT-FUTURES \
|
|
22
|
+
--marginCoin USDT \
|
|
23
|
+
--orderId <id> \
|
|
24
|
+
--newClientOid <new-client-id> \
|
|
25
|
+
[--newPresetStopSurplusPrice <price>] \
|
|
26
|
+
[--newPresetStopLossPrice <price>] \
|
|
27
|
+
[--newSize <size> --newPrice <price>]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Parameters
|
|
33
|
+
|
|
34
|
+
| Parameter | Type | Required | Description |
|
|
35
|
+
|-----------|------|----------|-------------|
|
|
36
|
+
| `symbol` | string | Yes | Trading pair, e.g. `BTCUSDT` |
|
|
37
|
+
| `productType` | string | Yes | `USDT-FUTURES`, `COIN-FUTURES`, or `USDC-FUTURES` |
|
|
38
|
+
| `marginCoin` | string | Yes | Margin asset, e.g. `USDT` |
|
|
39
|
+
| `orderId` | string | Conditional* | Exchange order ID |
|
|
40
|
+
| `clientOid` | string | Conditional* | Custom order ID. `orderId` takes priority if both given |
|
|
41
|
+
| `newClientOid` | string | Yes | New custom order ID for the modified order |
|
|
42
|
+
| `newSize` | string | No | New order quantity. **Must be provided with `newPrice`** |
|
|
43
|
+
| `newPrice` | string | No | New limit price. **Must be provided with `newSize`** |
|
|
44
|
+
| `newPresetStopSurplusPrice` | string | No | New take-profit trigger price. Pass `"0"` to delete |
|
|
45
|
+
| `newPresetStopLossPrice` | string | No | New stop-loss trigger price. Pass `"0"` to delete |
|
|
46
|
+
|
|
47
|
+
*One of `orderId` or `clientOid` must be provided.
|
|
48
|
+
At least one modification field must be present.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Response Fields
|
|
53
|
+
|
|
54
|
+
| Field | Type | Description |
|
|
55
|
+
|-------|------|-------------|
|
|
56
|
+
| `orderId` | string | New order ID (only changes when size/price modified) |
|
|
57
|
+
| `clientOid` | string | New custom order ID |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Usage Cases
|
|
62
|
+
|
|
63
|
+
### Case 1: Add TP/SL to an existing pending order
|
|
64
|
+
|
|
65
|
+
You placed a limit order without TP/SL. Now you want to add them without cancelling the order:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
bgc futures futures_modify_order \
|
|
69
|
+
--symbol BTCUSDT \
|
|
70
|
+
--productType USDT-FUTURES \
|
|
71
|
+
--marginCoin USDT \
|
|
72
|
+
--orderId "1234567890" \
|
|
73
|
+
--newClientOid "my-order-v2" \
|
|
74
|
+
--newPresetStopSurplusPrice "72000" \
|
|
75
|
+
--newPresetStopLossPrice "61000"
|
|
76
|
+
```
|
|
77
|
+
> The original order stays active. Only the TP/SL triggers are updated.
|
|
78
|
+
|
|
79
|
+
### Case 2: Adjust existing TP price only
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
bgc futures futures_modify_order \
|
|
83
|
+
--symbol BTCUSDT \
|
|
84
|
+
--productType USDT-FUTURES \
|
|
85
|
+
--marginCoin USDT \
|
|
86
|
+
--orderId "1234567890" \
|
|
87
|
+
--newClientOid "my-order-v3" \
|
|
88
|
+
--newPresetStopSurplusPrice "75000"
|
|
89
|
+
```
|
|
90
|
+
> Move TP target without touching SL or the order itself.
|
|
91
|
+
|
|
92
|
+
### Case 3: Delete TP/SL (pass "0")
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
bgc futures futures_modify_order \
|
|
96
|
+
--symbol BTCUSDT \
|
|
97
|
+
--productType USDT-FUTURES \
|
|
98
|
+
--marginCoin USDT \
|
|
99
|
+
--orderId "1234567890" \
|
|
100
|
+
--newClientOid "my-order-v4" \
|
|
101
|
+
--newPresetStopSurplusPrice "0" \
|
|
102
|
+
--newPresetStopLossPrice "0"
|
|
103
|
+
```
|
|
104
|
+
> Removes both TP and SL presets from the order.
|
|
105
|
+
|
|
106
|
+
### Case 4: Reprice a limit order (cancel-and-replace)
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
bgc futures futures_modify_order \
|
|
110
|
+
--symbol BTCUSDT \
|
|
111
|
+
--productType USDT-FUTURES \
|
|
112
|
+
--marginCoin USDT \
|
|
113
|
+
--orderId "1234567890" \
|
|
114
|
+
--newClientOid "my-order-v5" \
|
|
115
|
+
--newPrice "64500" \
|
|
116
|
+
--newSize "0.01"
|
|
117
|
+
```
|
|
118
|
+
> ⚠️ This cancels the original order and creates a new one. Save the new `orderId` from response.
|
|
119
|
+
|
|
120
|
+
### Case 5: Reprice and update TP/SL together
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
bgc futures futures_modify_order \
|
|
124
|
+
--symbol BTCUSDT \
|
|
125
|
+
--productType USDT-FUTURES \
|
|
126
|
+
--marginCoin USDT \
|
|
127
|
+
--orderId "1234567890" \
|
|
128
|
+
--newClientOid "my-order-v6" \
|
|
129
|
+
--newPrice "64500" \
|
|
130
|
+
--newSize "0.01" \
|
|
131
|
+
--newPresetStopSurplusPrice "71000" \
|
|
132
|
+
--newPresetStopLossPrice "60000"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Important Notes
|
|
138
|
+
|
|
139
|
+
- Only **pending limit orders** can be modified — filled or partially filled orders cannot
|
|
140
|
+
- `newSize` and `newPrice` must always be provided **together** — you cannot change only one
|
|
141
|
+
- TP/SL-only modifications do **not** change the `orderId`; size/price changes produce a **new `orderId`**
|
|
142
|
+
- TP/SL trigger prices are evaluated against **mark price**, not last trade price
|
|
143
|
+
- After a size/price modification, the original `orderId` is invalidated — update any references
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Workflow: Open order + set TP/SL after the fact
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Step 1: Place a limit buy
|
|
151
|
+
bgc futures futures_place_order --orders '[{
|
|
152
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
153
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
154
|
+
"side": "buy", "orderType": "limit", "force": "gtc",
|
|
155
|
+
"price": "65000", "size": "0.01"
|
|
156
|
+
}]'
|
|
157
|
+
# → save the returned orderId, e.g. "1234567890"
|
|
158
|
+
|
|
159
|
+
# Step 2: Add TP/SL without cancelling the order
|
|
160
|
+
bgc futures futures_modify_order \
|
|
161
|
+
--symbol BTCUSDT \
|
|
162
|
+
--productType USDT-FUTURES \
|
|
163
|
+
--marginCoin USDT \
|
|
164
|
+
--orderId "1234567890" \
|
|
165
|
+
--newClientOid "my-entry-v2" \
|
|
166
|
+
--newPresetStopSurplusPrice "72000" \
|
|
167
|
+
--newPresetStopLossPrice "61000"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Official Docs
|
|
173
|
+
- Modify Order: https://www.bitget.com/api-doc/contract/trade/Modify-Order
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
# futures_place_order — Futures Place Order
|
|
2
|
+
|
|
3
|
+
## Official Description
|
|
4
|
+
Place one or more futures perpetual contract orders with optional take-profit/stop-loss presets. Supports both one-way and hedge position modes.
|
|
5
|
+
|
|
6
|
+
**Endpoint:** `POST /api/v2/mix/order/place-order` (single) | `POST /api/v2/mix/order/batch-place-order` (batch)
|
|
7
|
+
**Auth required:** Yes
|
|
8
|
+
**Rate limit:** 10 req/s per UID; batch: 5 req/s
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ⚠️ CRITICAL: How to Close a Position
|
|
13
|
+
|
|
14
|
+
**The most common mistake is using the wrong `side` when closing.** The rule is:
|
|
15
|
+
|
|
16
|
+
| To close... | Use `side` | Why |
|
|
17
|
+
|-------------|------------|-----|
|
|
18
|
+
| Close a **long** | `sell` | You bought to open, you sell to close |
|
|
19
|
+
| Close a **short** | `buy` | You sold to open, you buy to close |
|
|
20
|
+
|
|
21
|
+
**Never use `sell` to close a short — that opens MORE short, it does not close it.**
|
|
22
|
+
|
|
23
|
+
### One-Way Mode Close (use `reduceOnly`)
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Close LONG: side=sell + reduceOnly=YES
|
|
27
|
+
bgc futures futures_place_order --orders '[{
|
|
28
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
29
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
30
|
+
"side": "sell", "orderType": "market", "force": "gtc",
|
|
31
|
+
"size": "0.01", "reduceOnly": "YES"
|
|
32
|
+
}]'
|
|
33
|
+
|
|
34
|
+
# Close SHORT: side=buy + reduceOnly=YES
|
|
35
|
+
bgc futures futures_place_order --orders '[{
|
|
36
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
37
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
38
|
+
"side": "buy", "orderType": "market", "force": "gtc",
|
|
39
|
+
"size": "0.01", "reduceOnly": "YES"
|
|
40
|
+
}]'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> `reduceOnly=YES` is essential — it prevents the order from accidentally flipping into an opposite position if the size exceeds what you hold.
|
|
44
|
+
|
|
45
|
+
### Hedge Mode Close (use `tradeSide=close`)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Close LONG in hedge mode: side=sell + tradeSide=close
|
|
49
|
+
bgc futures futures_place_order --orders '[{
|
|
50
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
51
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
52
|
+
"side": "sell", "tradeSide": "close",
|
|
53
|
+
"orderType": "market", "force": "gtc", "size": "0.01"
|
|
54
|
+
}]'
|
|
55
|
+
|
|
56
|
+
# Close SHORT in hedge mode: side=buy + tradeSide=close
|
|
57
|
+
bgc futures futures_place_order --orders '[{
|
|
58
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
59
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
60
|
+
"side": "buy", "tradeSide": "close",
|
|
61
|
+
"orderType": "market", "force": "gtc", "size": "0.01"
|
|
62
|
+
}]'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## ⚠️ CRITICAL: TP/SL Without Plan Orders
|
|
68
|
+
|
|
69
|
+
**There is no `futures_place_plan_order` in the bgc CLI.** The options are:
|
|
70
|
+
|
|
71
|
+
1. **Preset TP/SL on the entry order** — `presetStopSurplusPrice` / `presetStopLossPrice` set at order placement
|
|
72
|
+
2. **Add/modify TP/SL after placement** — `futures_modify_order` with `newPresetStopSurplusPrice` / `newPresetStopLossPrice`; does **not** cancel the order; pass `"0"` to delete
|
|
73
|
+
3. **Manual limit order with `reduceOnly=YES`** — place a separate limit close order at your target price
|
|
74
|
+
|
|
75
|
+
### TP/SL Preset (set when opening position)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Open long with TP at 72000 and SL at 61000
|
|
79
|
+
bgc futures futures_place_order --orders '[{
|
|
80
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
81
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
82
|
+
"side": "buy", "orderType": "limit", "force": "gtc",
|
|
83
|
+
"price": "65000", "size": "0.01",
|
|
84
|
+
"presetStopSurplusPrice": "72000",
|
|
85
|
+
"presetStopLossPrice": "61000"
|
|
86
|
+
}]'
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
> Presets are trigger prices. The position closes at market once the mark price hits the trigger.
|
|
90
|
+
|
|
91
|
+
### Manual TP: Limit Close Order with reduceOnly
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Already holding a long. Place a take-profit limit sell at 72000.
|
|
95
|
+
bgc futures futures_place_order --orders '[{
|
|
96
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
97
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
98
|
+
"side": "sell", "orderType": "limit", "force": "gtc",
|
|
99
|
+
"price": "72000", "size": "0.01",
|
|
100
|
+
"reduceOnly": "YES"
|
|
101
|
+
}]'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
> This rests as a pending limit order in the book. When price hits 72000, it fills and closes the long.
|
|
105
|
+
|
|
106
|
+
### Manual SL: Limit Close Order with reduceOnly
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Already holding a long. Place a stop-loss limit sell at 61000.
|
|
110
|
+
bgc futures futures_place_order --orders '[{
|
|
111
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
112
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
113
|
+
"side": "sell", "orderType": "limit", "force": "gtc",
|
|
114
|
+
"price": "61000", "size": "0.01",
|
|
115
|
+
"reduceOnly": "YES"
|
|
116
|
+
}]'
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
> ⚠️ A limit SL may not fill in a fast-moving market — it can be skipped if price gaps through. For hard stops, prefer the `presetStopLossPrice` preset (market execution on trigger).
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## bgc CLI Usage
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
bgc futures futures_place_order --orders '<JSON array>'
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Order Object Parameters
|
|
132
|
+
|
|
133
|
+
| Parameter | Type | Required | Allowed Values | Description |
|
|
134
|
+
|-----------|------|----------|----------------|-------------|
|
|
135
|
+
| `symbol` | string | Yes | e.g. `BTCUSDT` | Contract symbol (uppercase) |
|
|
136
|
+
| `productType` | string | Yes | `USDT-FUTURES`, `COIN-FUTURES`, `USDC-FUTURES` | Contract product type |
|
|
137
|
+
| `marginMode` | string | Yes | `isolated`, `crossed` | Margin mode for this order |
|
|
138
|
+
| `marginCoin` | string | Yes | e.g. `USDT`, `BTC` | Collateral coin (must match productType) |
|
|
139
|
+
| `size` | string | Yes | e.g. `"0.01"` | Order size in base coin |
|
|
140
|
+
| `price` | string | Conditional | e.g. `"65000"` | Required for limit orders |
|
|
141
|
+
| `side` | string | Yes | `buy`, `sell` | Order direction (see close table above) |
|
|
142
|
+
| `tradeSide` | string | Conditional | `open`, `close` | **Hedge mode only** — omit in one-way mode |
|
|
143
|
+
| `orderType` | string | Yes | `limit`, `market` | Order type |
|
|
144
|
+
| `force` | string | Conditional | `gtc`, `ioc`, `fok`, `post_only` | Required for limit orders; default `gtc` |
|
|
145
|
+
| `clientOid` | string | No | e.g. `"fut-001"` | Custom order ID |
|
|
146
|
+
| `reduceOnly` | string | No | `YES`, `NO` (default) | **One-way mode only**: ensures order only reduces/closes position |
|
|
147
|
+
| `presetStopSurplusPrice` | string | No | e.g. `"70000"` | Take-profit trigger price (mark price) |
|
|
148
|
+
| `presetStopSurplusExecutePrice` | string | No | e.g. `"69900"` | TP execution price (limit); omit for market TP |
|
|
149
|
+
| `presetStopLossPrice` | string | No | e.g. `"60000"` | Stop-loss trigger price (mark price) |
|
|
150
|
+
| `presetStopLossExecutePrice` | string | No | e.g. `"59900"` | SL execution price (limit); omit for market SL |
|
|
151
|
+
| `stpMode` | string | No | `none`, `cancel_taker`, `cancel_maker`, `cancel_both` | Self-trade prevention |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Position Mode Logic
|
|
156
|
+
|
|
157
|
+
### One-Way Mode (default for most accounts)
|
|
158
|
+
|
|
159
|
+
`tradeSide` is **NOT used** in one-way mode — omit it entirely. Use `side` + `reduceOnly`:
|
|
160
|
+
|
|
161
|
+
| Action | `side` | `reduceOnly` |
|
|
162
|
+
|--------|--------|--------------|
|
|
163
|
+
| Open long | `buy` | `NO` (or omit) |
|
|
164
|
+
| Open short | `sell` | `NO` (or omit) |
|
|
165
|
+
| Close long | `sell` | `YES` |
|
|
166
|
+
| Close short | `buy` | `YES` |
|
|
167
|
+
|
|
168
|
+
### Hedge Mode
|
|
169
|
+
|
|
170
|
+
`tradeSide` is **required** in hedge mode. Do NOT use `reduceOnly`:
|
|
171
|
+
|
|
172
|
+
| Action | `side` | `tradeSide` |
|
|
173
|
+
|--------|--------|-------------|
|
|
174
|
+
| Open long | `buy` | `open` |
|
|
175
|
+
| Open short | `sell` | `open` |
|
|
176
|
+
| Close long | `sell` | `close` |
|
|
177
|
+
| Close short | `buy` | `close` |
|
|
178
|
+
|
|
179
|
+
> **How to check your mode:** `bgc futures futures_get_positions --productType USDT-FUTURES --symbol BTCUSDT` — look at `posMode` field: `one_way_mode` or `hedge_mode`.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Common Errors and Fixes
|
|
184
|
+
|
|
185
|
+
| Error | Cause | Fix |
|
|
186
|
+
|-------|-------|-----|
|
|
187
|
+
| "No position to close" / "position not found" | Wrong `side` direction for close, or wrong mode params | Check `holdSide` in positions; use the close table above |
|
|
188
|
+
| "Type mismatch" / parameter error | Using `tradeSide` in one-way mode, or omitting it in hedge mode | Check your `posMode` first; match params to mode |
|
|
189
|
+
| "Insufficient balance" on close order | Order was interpreted as an **open** (not a close), consuming margin | Add `reduceOnly=YES` (one-way) or `tradeSide=close` (hedge) |
|
|
190
|
+
| Close order turns into open | No `reduceOnly` or wrong `tradeSide` | Always add close protection params |
|
|
191
|
+
| TP/SL not triggered | `presetStopSurplusPrice` / `presetStopLossPrice` are trigger prices vs **mark price** | Verify mark price direction matches trigger |
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Response Fields
|
|
196
|
+
|
|
197
|
+
| Field | Type | Description |
|
|
198
|
+
|-------|------|-------------|
|
|
199
|
+
| `orderId` | string | Exchange-assigned order ID |
|
|
200
|
+
| `clientOid` | string | Your custom order ID |
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Usage Cases
|
|
205
|
+
|
|
206
|
+
### Case 1: Open long — limit order (one-way mode)
|
|
207
|
+
```bash
|
|
208
|
+
bgc futures futures_place_order --orders '[{
|
|
209
|
+
"symbol": "BTCUSDT",
|
|
210
|
+
"productType": "USDT-FUTURES",
|
|
211
|
+
"marginMode": "crossed",
|
|
212
|
+
"marginCoin": "USDT",
|
|
213
|
+
"side": "buy",
|
|
214
|
+
"orderType": "limit",
|
|
215
|
+
"force": "gtc",
|
|
216
|
+
"price": "65000",
|
|
217
|
+
"size": "0.01"
|
|
218
|
+
}]'
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Case 2: Open short — limit order (one-way mode)
|
|
222
|
+
```bash
|
|
223
|
+
bgc futures futures_place_order --orders '[{
|
|
224
|
+
"symbol": "BTCUSDT",
|
|
225
|
+
"productType": "USDT-FUTURES",
|
|
226
|
+
"marginMode": "crossed",
|
|
227
|
+
"marginCoin": "USDT",
|
|
228
|
+
"side": "sell",
|
|
229
|
+
"orderType": "limit",
|
|
230
|
+
"force": "gtc",
|
|
231
|
+
"price": "68000",
|
|
232
|
+
"size": "0.01"
|
|
233
|
+
}]'
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Case 3: Open short — with preset TP/SL at entry
|
|
237
|
+
```bash
|
|
238
|
+
bgc futures futures_place_order --orders '[{
|
|
239
|
+
"symbol": "BTCUSDT",
|
|
240
|
+
"productType": "USDT-FUTURES",
|
|
241
|
+
"marginMode": "isolated",
|
|
242
|
+
"marginCoin": "USDT",
|
|
243
|
+
"side": "sell",
|
|
244
|
+
"orderType": "limit",
|
|
245
|
+
"force": "gtc",
|
|
246
|
+
"price": "67000",
|
|
247
|
+
"size": "0.01",
|
|
248
|
+
"presetStopSurplusPrice": "63000",
|
|
249
|
+
"presetStopLossPrice": "70000"
|
|
250
|
+
}]'
|
|
251
|
+
```
|
|
252
|
+
> Short at $67,000. TP at $63,000 (price falls = profit). SL at $70,000 (price rises = loss protected).
|
|
253
|
+
> The close direction (`buy`) is handled automatically by the preset — you do not specify it.
|
|
254
|
+
|
|
255
|
+
### Case 4: Close long — market (one-way mode)
|
|
256
|
+
```bash
|
|
257
|
+
bgc futures futures_place_order --orders '[{
|
|
258
|
+
"symbol": "BTCUSDT",
|
|
259
|
+
"productType": "USDT-FUTURES",
|
|
260
|
+
"marginMode": "crossed",
|
|
261
|
+
"marginCoin": "USDT",
|
|
262
|
+
"side": "sell",
|
|
263
|
+
"orderType": "market",
|
|
264
|
+
"force": "gtc",
|
|
265
|
+
"size": "0.01",
|
|
266
|
+
"reduceOnly": "YES"
|
|
267
|
+
}]'
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Case 5: Close short — market (one-way mode)
|
|
271
|
+
```bash
|
|
272
|
+
bgc futures futures_place_order --orders '[{
|
|
273
|
+
"symbol": "BTCUSDT",
|
|
274
|
+
"productType": "USDT-FUTURES",
|
|
275
|
+
"marginMode": "crossed",
|
|
276
|
+
"marginCoin": "USDT",
|
|
277
|
+
"side": "buy",
|
|
278
|
+
"orderType": "market",
|
|
279
|
+
"force": "gtc",
|
|
280
|
+
"size": "0.01",
|
|
281
|
+
"reduceOnly": "YES"
|
|
282
|
+
}]'
|
|
283
|
+
```
|
|
284
|
+
> **Short = opened with `sell`. To close: `buy` + `reduceOnly=YES`.**
|
|
285
|
+
|
|
286
|
+
### Case 6: Place TP + SL as separate limit orders after opening (one-way mode)
|
|
287
|
+
```bash
|
|
288
|
+
# Assume holding 0.01 BTC long. Place both orders simultaneously.
|
|
289
|
+
|
|
290
|
+
# Take-profit at 72000
|
|
291
|
+
bgc futures futures_place_order --orders '[{
|
|
292
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
293
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
294
|
+
"side": "sell", "orderType": "limit", "force": "gtc",
|
|
295
|
+
"price": "72000", "size": "0.01", "reduceOnly": "YES"
|
|
296
|
+
}]'
|
|
297
|
+
|
|
298
|
+
# Stop-loss at 61000
|
|
299
|
+
bgc futures futures_place_order --orders '[{
|
|
300
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
301
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
302
|
+
"side": "sell", "orderType": "limit", "force": "gtc",
|
|
303
|
+
"price": "61000", "size": "0.01", "reduceOnly": "YES"
|
|
304
|
+
}]'
|
|
305
|
+
```
|
|
306
|
+
> Both orders have `reduceOnly=YES` so they won't add to position. Whichever fills first, the system will auto-cancel the other (if it would exceed available position size).
|
|
307
|
+
|
|
308
|
+
### Case 7: Hedge mode — open long
|
|
309
|
+
```bash
|
|
310
|
+
bgc futures futures_place_order --orders '[{
|
|
311
|
+
"symbol": "ETHUSDT",
|
|
312
|
+
"productType": "USDT-FUTURES",
|
|
313
|
+
"marginMode": "crossed",
|
|
314
|
+
"marginCoin": "USDT",
|
|
315
|
+
"side": "buy",
|
|
316
|
+
"tradeSide": "open",
|
|
317
|
+
"orderType": "limit",
|
|
318
|
+
"force": "gtc",
|
|
319
|
+
"price": "3200",
|
|
320
|
+
"size": "1"
|
|
321
|
+
}]'
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Case 8: Hedge mode — close short
|
|
325
|
+
```bash
|
|
326
|
+
bgc futures futures_place_order --orders '[{
|
|
327
|
+
"symbol": "ETHUSDT",
|
|
328
|
+
"productType": "USDT-FUTURES",
|
|
329
|
+
"marginMode": "crossed",
|
|
330
|
+
"marginCoin": "USDT",
|
|
331
|
+
"side": "buy",
|
|
332
|
+
"tradeSide": "close",
|
|
333
|
+
"orderType": "market",
|
|
334
|
+
"force": "gtc",
|
|
335
|
+
"size": "1"
|
|
336
|
+
}]'
|
|
337
|
+
```
|
|
338
|
+
> Closing a short uses `side=buy` + `tradeSide=close`. Do NOT use `reduceOnly` in hedge mode.
|
|
339
|
+
|
|
340
|
+
### Case 9: COIN-margined (inverse) — open long BTC
|
|
341
|
+
```bash
|
|
342
|
+
bgc futures futures_place_order --orders '[{
|
|
343
|
+
"symbol": "BTCUSD",
|
|
344
|
+
"productType": "COIN-FUTURES",
|
|
345
|
+
"marginMode": "crossed",
|
|
346
|
+
"marginCoin": "BTC",
|
|
347
|
+
"side": "buy",
|
|
348
|
+
"orderType": "market",
|
|
349
|
+
"force": "gtc",
|
|
350
|
+
"size": "1"
|
|
351
|
+
}]'
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Case 10: Full TP/SL preset with execution prices
|
|
355
|
+
```bash
|
|
356
|
+
bgc futures futures_place_order --orders '[{
|
|
357
|
+
"symbol": "BTCUSDT",
|
|
358
|
+
"productType": "USDT-FUTURES",
|
|
359
|
+
"marginMode": "isolated",
|
|
360
|
+
"marginCoin": "USDT",
|
|
361
|
+
"side": "buy",
|
|
362
|
+
"orderType": "limit",
|
|
363
|
+
"force": "gtc",
|
|
364
|
+
"price": "65000",
|
|
365
|
+
"size": "0.01",
|
|
366
|
+
"presetStopSurplusPrice": "72000",
|
|
367
|
+
"presetStopSurplusExecutePrice": "71900",
|
|
368
|
+
"presetStopLossPrice": "61000",
|
|
369
|
+
"presetStopLossExecutePrice": "60900"
|
|
370
|
+
}]'
|
|
371
|
+
```
|
|
372
|
+
> `presetStopSurplusExecutePrice` / `presetStopLossExecutePrice` set execution as limit prices.
|
|
373
|
+
> Omit them to execute at market price when trigger is hit.
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Step-by-Step: Open and Manage a Position (One-Way Mode)
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
# Step 1: Check current position mode
|
|
381
|
+
bgc futures futures_get_positions --productType USDT-FUTURES --symbol BTCUSDT
|
|
382
|
+
# Look for posMode: "one_way_mode"
|
|
383
|
+
|
|
384
|
+
# Step 2: Open long with preset TP/SL
|
|
385
|
+
bgc futures futures_place_order --orders '[{
|
|
386
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
387
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
388
|
+
"side": "buy", "orderType": "limit", "force": "gtc",
|
|
389
|
+
"price": "65000", "size": "0.01",
|
|
390
|
+
"presetStopSurplusPrice": "72000",
|
|
391
|
+
"presetStopLossPrice": "61000"
|
|
392
|
+
}]'
|
|
393
|
+
|
|
394
|
+
# Step 3: (Optional) Add additional TP limit order
|
|
395
|
+
bgc futures futures_place_order --orders '[{
|
|
396
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
397
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
398
|
+
"side": "sell", "orderType": "limit", "force": "gtc",
|
|
399
|
+
"price": "72000", "size": "0.01", "reduceOnly": "YES"
|
|
400
|
+
}]'
|
|
401
|
+
|
|
402
|
+
# Step 4: Emergency close at market
|
|
403
|
+
bgc futures futures_place_order --orders '[{
|
|
404
|
+
"symbol": "BTCUSDT", "productType": "USDT-FUTURES",
|
|
405
|
+
"marginMode": "crossed", "marginCoin": "USDT",
|
|
406
|
+
"side": "sell", "orderType": "market", "force": "gtc",
|
|
407
|
+
"size": "0.01", "reduceOnly": "YES"
|
|
408
|
+
}]'
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## Important Notes
|
|
414
|
+
|
|
415
|
+
- `marginMode` and `marginCoin` must be on every order
|
|
416
|
+
- For `USDT-FUTURES`: `marginCoin=USDT`; for `COIN-FUTURES`: `marginCoin` = base coin (e.g., `BTC`)
|
|
417
|
+
- **Do NOT mix `tradeSide` and `reduceOnly`** — use one or the other depending on position mode
|
|
418
|
+
- `tradeSide` is only valid in hedge mode; using it in one-way mode causes parameter errors
|
|
419
|
+
- `reduceOnly` is only valid in one-way mode; in hedge mode use `tradeSide=close`
|
|
420
|
+
- Preset TP/SL prices trigger against **mark price**, not last trade price
|
|
421
|
+
- There is no `futures_place_plan_order` in bgc — use presets or manual limit orders with `reduceOnly`
|
|
422
|
+
- In one-way mode, multiple `reduceOnly` orders are allowed; they auto-cancel if combined size exceeds position
|
|
423
|
+
- Set leverage before trading: `bgc futures futures_set_leverage ...`
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Official Docs
|
|
428
|
+
- Futures Place Order: https://www.bitget.com/api-doc/contract/trade/Place-Order
|
|
429
|
+
- Futures Batch Orders: https://www.bitget.com/api-doc/contract/trade/Batch-Place-Orders
|