@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/CHANGELOG.md +23 -0
- package/README.md +189 -57
- package/VERSION +1 -1
- package/package.json +5 -3
- package/references/auth-setup.md +37 -9
- package/references/commands.md +1903 -774
- package/references/demo-trading.md +31 -28
- package/references/discover-guide.md +112 -0
- package/references/error-codes.md +111 -46
- package/references/trading-safety.md +163 -0
- package/scripts/gen-references.js +241 -45
- package/scripts/install.js +8 -1
- package/skills/SKILL.md +156 -139
- package/references/trading/README.md +0 -36
- package/references/trading/futures-cancel-orders.md +0 -113
- package/references/trading/futures-get-orders.md +0 -155
- package/references/trading/futures-leverage-config.md +0 -184
- package/references/trading/futures-modify-order.md +0 -173
- package/references/trading/futures-place-order.md +0 -429
- package/references/trading/futures-positions.md +0 -154
- package/references/trading/spot-cancel-orders.md +0 -87
- package/references/trading/spot-get-orders.md +0 -120
- package/references/trading/spot-modify-order.md +0 -95
- package/references/trading/spot-place-order.md +0 -166
- package/references/trading/spot-plan-orders.md +0 -160
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
# spot_get_orders — Spot Query Orders
|
|
2
|
-
|
|
3
|
-
## Official Description
|
|
4
|
-
Query spot order details: a single order by ID, current open orders, or historical filled/cancelled orders. Supports time-range filtering and cursor-based pagination.
|
|
5
|
-
|
|
6
|
-
**Endpoints:**
|
|
7
|
-
- Single order: `GET /api/v2/spot/trade/orderInfo`
|
|
8
|
-
- Open orders: `GET /api/v2/spot/trade/unfilled-orders`
|
|
9
|
-
- History orders: `GET /api/v2/spot/trade/history-orders`
|
|
10
|
-
|
|
11
|
-
**Auth required:** Yes
|
|
12
|
-
**Rate limit:** 10 req/s per UID
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## bgc CLI Usage
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
bgc spot spot_get_orders [--orderId <id>] [--symbol <SYMBOL>] [--status open|history] [--startTime <ms>] [--endTime <ms>] [--limit <n>] [--idLessThan <id>]
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Parameters
|
|
25
|
-
|
|
26
|
-
| Parameter | Type | Required | Allowed Values | Description |
|
|
27
|
-
|-----------|------|----------|----------------|-------------|
|
|
28
|
-
| `orderId` | string | No | e.g. `"1234567890"` | Fetch a specific order. Returns single result |
|
|
29
|
-
| `symbol` | string | No | e.g. `BTCUSDT` | Filter by trading pair |
|
|
30
|
-
| `status` | string | No | `open` (default), `history` | `open` = unfilled orders; `history` = filled/cancelled |
|
|
31
|
-
| `startTime` | string | No | Unix ms, e.g. `"1700000000000"` | Start of time range (history only) |
|
|
32
|
-
| `endTime` | string | No | Unix ms | End of time range (history only) |
|
|
33
|
-
| `limit` | number | No | 1–100, default 100 | Number of results to return |
|
|
34
|
-
| `idLessThan` | string | No | orderId cursor | Pagination: return orders with ID less than this value |
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## Key Response Fields
|
|
39
|
-
|
|
40
|
-
| Field | Type | Description |
|
|
41
|
-
|-------|------|-------------|
|
|
42
|
-
| `orderId` | string | Exchange order ID |
|
|
43
|
-
| `clientOid` | string | Your custom order ID |
|
|
44
|
-
| `symbol` | string | Trading pair |
|
|
45
|
-
| `side` | string | `buy` or `sell` |
|
|
46
|
-
| `orderType` | string | `limit` or `market` |
|
|
47
|
-
| `status` | string | `live`, `partially_filled`, `filled`, `cancelled` |
|
|
48
|
-
| `price` | string | Limit price |
|
|
49
|
-
| `priceAvg` | string | Average fill price |
|
|
50
|
-
| `size` | string | Original order size |
|
|
51
|
-
| `fillSize` | string | Amount filled so far |
|
|
52
|
-
| `fillAmount` | string | Quote amount filled |
|
|
53
|
-
| `fee` | string | Transaction fee paid |
|
|
54
|
-
| `force` | string | `gtc`, `ioc`, `fok`, `post_only` |
|
|
55
|
-
| `cTime` | string | Created timestamp (ms) |
|
|
56
|
-
| `uTime` | string | Last updated timestamp (ms) |
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Usage Cases
|
|
61
|
-
|
|
62
|
-
### Case 1: View all open orders
|
|
63
|
-
```bash
|
|
64
|
-
bgc spot spot_get_orders --status open
|
|
65
|
-
```
|
|
66
|
-
> Show all currently open orders across all symbols.
|
|
67
|
-
|
|
68
|
-
### Case 2: Open orders for a specific symbol
|
|
69
|
-
```bash
|
|
70
|
-
bgc spot spot_get_orders --symbol BTCUSDT --status open
|
|
71
|
-
```
|
|
72
|
-
> Show only BTCUSDT open orders.
|
|
73
|
-
|
|
74
|
-
### Case 3: Fetch a specific order by ID
|
|
75
|
-
```bash
|
|
76
|
-
bgc spot spot_get_orders --orderId "1234567890"
|
|
77
|
-
```
|
|
78
|
-
> Get full details of one order — useful to check fill status after placing.
|
|
79
|
-
|
|
80
|
-
### Case 4: Recent trade history for a symbol
|
|
81
|
-
```bash
|
|
82
|
-
bgc spot spot_get_orders --symbol ETHUSDT --status history --limit 20
|
|
83
|
-
```
|
|
84
|
-
> Show last 20 completed/cancelled orders for ETHUSDT.
|
|
85
|
-
|
|
86
|
-
### Case 5: History within a time range
|
|
87
|
-
```bash
|
|
88
|
-
bgc spot spot_get_orders \
|
|
89
|
-
--symbol BTCUSDT \
|
|
90
|
-
--status history \
|
|
91
|
-
--startTime "1700000000000" \
|
|
92
|
-
--endTime "1700086400000"
|
|
93
|
-
```
|
|
94
|
-
> Fetch orders executed within a specific date range. Convert dates to Unix ms timestamps.
|
|
95
|
-
|
|
96
|
-
### Case 6: Paginate through large history
|
|
97
|
-
```bash
|
|
98
|
-
# First page
|
|
99
|
-
bgc spot spot_get_orders --symbol BTCUSDT --status history --limit 100
|
|
100
|
-
|
|
101
|
-
# Next page — use the smallest orderId from previous response
|
|
102
|
-
bgc spot spot_get_orders --symbol BTCUSDT --status history --limit 100 --idLessThan "1234500000"
|
|
103
|
-
```
|
|
104
|
-
> Use `idLessThan` cursor to paginate backwards through history.
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## Important Notes
|
|
109
|
-
|
|
110
|
-
- Default `status` is `open` — always specify `--status history` for filled/cancelled orders
|
|
111
|
-
- `startTime`/`endTime` only apply to `status=history`
|
|
112
|
-
- For fill details (price per fill, fee per fill): use `spot_get_fills` instead
|
|
113
|
-
- To get Unix ms for a date: `date -d "2024-01-01" +%s000` (Linux) or use an online converter
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## Official Docs
|
|
118
|
-
- Unfilled Orders: https://www.bitget.com/api-doc/spot/trade/Get-Unfilled-Orders
|
|
119
|
-
- History Orders: https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
|
|
120
|
-
- Order Detail: https://www.bitget.com/api-doc/spot/trade/Get-Order-Details
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# spot_modify_order — Spot Modify Order
|
|
2
|
-
|
|
3
|
-
## Official Description
|
|
4
|
-
Atomically cancel an existing open spot order and replace it with a new one (modify price and/or size). This is a cancel-and-replace operation — the original order is cancelled and a new order ID is returned.
|
|
5
|
-
|
|
6
|
-
**Endpoint:** `POST /api/v2/spot/trade/modify-order`
|
|
7
|
-
**Auth required:** Yes
|
|
8
|
-
**Rate limit:** 10 req/s per UID
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## bgc CLI Usage
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
bgc spot spot_modify_order --symbol <SYMBOL> --orderId <id> [--newPrice <price>] [--newSize <size>] [--newClientOid <id>]
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Parameters
|
|
21
|
-
|
|
22
|
-
| Parameter | Type | Required | Description |
|
|
23
|
-
|-----------|------|----------|-------------|
|
|
24
|
-
| `symbol` | string | Yes | Trading pair, e.g. `BTCUSDT` |
|
|
25
|
-
| `orderId` | string | Yes | Original order ID to modify |
|
|
26
|
-
| `newPrice` | string | No | New limit price. Omit to keep original price |
|
|
27
|
-
| `newSize` | string | No | New order quantity. Omit to keep original size |
|
|
28
|
-
| `newClientOid` | string | No | New custom order ID for the replacement order |
|
|
29
|
-
|
|
30
|
-
> At least one of `newPrice` or `newSize` should be provided, otherwise the operation has no effect.
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## Response Fields
|
|
35
|
-
|
|
36
|
-
| Field | Type | Description |
|
|
37
|
-
|-------|------|-------------|
|
|
38
|
-
| `orderId` | string | New order ID (the replacement order) |
|
|
39
|
-
| `clientOid` | string | New custom order ID (echoed back) |
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Usage Cases
|
|
44
|
-
|
|
45
|
-
### Case 1: Chase the market — update price only
|
|
46
|
-
```bash
|
|
47
|
-
bgc spot spot_modify_order \
|
|
48
|
-
--symbol BTCUSDT \
|
|
49
|
-
--orderId "1234567890" \
|
|
50
|
-
--newPrice "64800"
|
|
51
|
-
```
|
|
52
|
-
> Move your limit buy closer to current price without losing queue priority advantage vs. a manual cancel+repost.
|
|
53
|
-
|
|
54
|
-
### Case 2: Adjust order size only
|
|
55
|
-
```bash
|
|
56
|
-
bgc spot spot_modify_order \
|
|
57
|
-
--symbol BTCUSDT \
|
|
58
|
-
--orderId "1234567890" \
|
|
59
|
-
--newSize "0.02"
|
|
60
|
-
```
|
|
61
|
-
> Increase or decrease the quantity of an existing limit order.
|
|
62
|
-
|
|
63
|
-
### Case 3: Modify both price and size
|
|
64
|
-
```bash
|
|
65
|
-
bgc spot spot_modify_order \
|
|
66
|
-
--symbol ETHUSDT \
|
|
67
|
-
--orderId "9876543210" \
|
|
68
|
-
--newPrice "3150" \
|
|
69
|
-
--newSize "2"
|
|
70
|
-
```
|
|
71
|
-
> Fully reprice and resize in one atomic call.
|
|
72
|
-
|
|
73
|
-
### Case 4: Reassign clientOid on the replacement
|
|
74
|
-
```bash
|
|
75
|
-
bgc spot spot_modify_order \
|
|
76
|
-
--symbol BTCUSDT \
|
|
77
|
-
--orderId "1234567890" \
|
|
78
|
-
--newPrice "64900" \
|
|
79
|
-
--newClientOid "my-strategy-v2-001"
|
|
80
|
-
```
|
|
81
|
-
> Update your own tracking ID along with the price adjustment.
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## Important Notes
|
|
86
|
-
|
|
87
|
-
- This is a **cancel-and-replace** — the original `orderId` is invalidated; save the new `orderId` from the response
|
|
88
|
-
- Only works on **open (unfilled) limit orders** — market orders cannot be modified
|
|
89
|
-
- If the order fills between your modify request and server processing, the operation may fail
|
|
90
|
-
- Query current orders first to confirm the order is still open: `bgc spot spot_get_orders --symbol BTCUSDT --status open`
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
## Official Docs
|
|
95
|
-
- Modify Order: https://www.bitget.com/api-doc/spot/trade/Modify-Order
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
# spot_place_order — Spot Place Order
|
|
2
|
-
|
|
3
|
-
## Official Description
|
|
4
|
-
Place one or more spot orders. Executes real trades against the live order book.
|
|
5
|
-
|
|
6
|
-
**Endpoint:** `POST /api/v2/spot/trade/place-order` (single) | `POST /api/v2/spot/trade/batch-orders` (batch)
|
|
7
|
-
**Auth required:** Yes
|
|
8
|
-
**Rate limit:** 10 req/s per UID (1 req/s for copy-trading traders); batch: 5 req/s
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## bgc CLI Usage
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
bgc spot spot_place_order --orders '<JSON array>'
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
The `--orders` parameter always takes a **JSON array**, even for a single order.
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## Order Object Parameters
|
|
23
|
-
|
|
24
|
-
| Parameter | Type | Required | Allowed Values | Description |
|
|
25
|
-
|-----------|------|----------|----------------|-------------|
|
|
26
|
-
| `symbol` | string | Yes | e.g. `BTCUSDT` | Trading pair (uppercase) |
|
|
27
|
-
| `side` | string | Yes | `buy`, `sell` | Order direction |
|
|
28
|
-
| `orderType` | string | Yes | `limit`, `market` | Order type |
|
|
29
|
-
| `force` | string | Yes* | `gtc`, `post_only`, `fok`, `ioc` | Time-in-force. *Ignored for market orders |
|
|
30
|
-
| `price` | string | Conditional | e.g. `"65000"` | Required for limit orders |
|
|
31
|
-
| `size` | string | Yes | e.g. `"0.01"` | **Limit/market-sell**: base coin qty. **Market-buy**: quote coin qty |
|
|
32
|
-
| `clientOid` | string | No | e.g. `"my-order-001"` | Custom order ID for deduplication/tracking |
|
|
33
|
-
| `tpslType` | string | No | `normal` (default), `tpsl` | TP/SL mode. `tpsl` makes a standalone TP/SL order |
|
|
34
|
-
| `triggerPrice` | string | Conditional | e.g. `"66000"` | Required only when `tpslType=tpsl` |
|
|
35
|
-
| `presetTakeProfitPrice` | string | No | e.g. `"70000"` | TP trigger price (incompatible with `tpslType=tpsl`) |
|
|
36
|
-
| `executeTakeProfitPrice` | string | No | e.g. `"69900"` | TP execution price (incompatible with `tpslType=tpsl`) |
|
|
37
|
-
| `presetStopLossPrice` | string | No | e.g. `"60000"` | SL trigger price (incompatible with `tpslType=tpsl`) |
|
|
38
|
-
| `executeStopLossPrice` | string | No | e.g. `"59900"` | SL execution price (incompatible with `tpslType=tpsl`) |
|
|
39
|
-
| `stpMode` | string | No | `none`, `cancel_taker`, `cancel_maker`, `cancel_both` | Self-trade prevention |
|
|
40
|
-
|
|
41
|
-
### `force` Values Explained
|
|
42
|
-
| Value | Behavior |
|
|
43
|
-
|-------|----------|
|
|
44
|
-
| `gtc` | Good Till Cancelled — stays open until filled or manually cancelled |
|
|
45
|
-
| `post_only` | Maker-only — rejected if it would match immediately |
|
|
46
|
-
| `fok` | Fill or Kill — must fill entirely at once, or cancelled |
|
|
47
|
-
| `ioc` | Immediate or Cancel — fills what it can instantly, cancels remainder |
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## Response Fields
|
|
52
|
-
|
|
53
|
-
| Field | Type | Description |
|
|
54
|
-
|-------|------|-------------|
|
|
55
|
-
| `orderId` | string | Exchange-assigned order ID |
|
|
56
|
-
| `clientOid` | string | Your custom ID (echoed back) |
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Usage Cases
|
|
61
|
-
|
|
62
|
-
### Case 1: Simple limit buy
|
|
63
|
-
```bash
|
|
64
|
-
bgc spot spot_place_order --orders '[{
|
|
65
|
-
"symbol": "BTCUSDT",
|
|
66
|
-
"side": "buy",
|
|
67
|
-
"orderType": "limit",
|
|
68
|
-
"force": "gtc",
|
|
69
|
-
"price": "65000",
|
|
70
|
-
"size": "0.01"
|
|
71
|
-
}]'
|
|
72
|
-
```
|
|
73
|
-
> Buy 0.01 BTC at $65,000. Order stays open until filled or cancelled.
|
|
74
|
-
|
|
75
|
-
### Case 2: Market buy (quote amount)
|
|
76
|
-
```bash
|
|
77
|
-
bgc spot spot_place_order --orders '[{
|
|
78
|
-
"symbol": "BTCUSDT",
|
|
79
|
-
"side": "buy",
|
|
80
|
-
"orderType": "market",
|
|
81
|
-
"force": "gtc",
|
|
82
|
-
"size": "100"
|
|
83
|
-
}]'
|
|
84
|
-
```
|
|
85
|
-
> Spend exactly 100 USDT to buy BTC at market price. `size` is in quote coin (USDT) for market buys.
|
|
86
|
-
|
|
87
|
-
### Case 3: Market sell (base amount)
|
|
88
|
-
```bash
|
|
89
|
-
bgc spot spot_place_order --orders '[{
|
|
90
|
-
"symbol": "BTCUSDT",
|
|
91
|
-
"side": "sell",
|
|
92
|
-
"orderType": "market",
|
|
93
|
-
"force": "gtc",
|
|
94
|
-
"size": "0.005"
|
|
95
|
-
}]'
|
|
96
|
-
```
|
|
97
|
-
> Sell 0.005 BTC at market price. `size` is in base coin (BTC) for sells.
|
|
98
|
-
|
|
99
|
-
### Case 4: Limit order with preset TP/SL
|
|
100
|
-
```bash
|
|
101
|
-
bgc spot spot_place_order --orders '[{
|
|
102
|
-
"symbol": "ETHUSDT",
|
|
103
|
-
"side": "buy",
|
|
104
|
-
"orderType": "limit",
|
|
105
|
-
"force": "gtc",
|
|
106
|
-
"price": "3200",
|
|
107
|
-
"size": "1",
|
|
108
|
-
"presetTakeProfitPrice": "3800",
|
|
109
|
-
"presetStopLossPrice": "2900"
|
|
110
|
-
}]'
|
|
111
|
-
```
|
|
112
|
-
> Buy 1 ETH at $3,200 with automatic TP at $3,800 and SL at $2,900.
|
|
113
|
-
|
|
114
|
-
### Case 5: Post-only maker order
|
|
115
|
-
```bash
|
|
116
|
-
bgc spot spot_place_order --orders '[{
|
|
117
|
-
"symbol": "BTCUSDT",
|
|
118
|
-
"side": "buy",
|
|
119
|
-
"orderType": "limit",
|
|
120
|
-
"force": "post_only",
|
|
121
|
-
"price": "64500",
|
|
122
|
-
"size": "0.01"
|
|
123
|
-
}]'
|
|
124
|
-
```
|
|
125
|
-
> Ensures you only pay maker fees. Rejected if the price would match immediately.
|
|
126
|
-
|
|
127
|
-
### Case 6: Batch — multiple orders at once
|
|
128
|
-
```bash
|
|
129
|
-
bgc spot spot_place_order --orders '[
|
|
130
|
-
{"symbol":"BTCUSDT","side":"buy","orderType":"limit","force":"gtc","price":"64000","size":"0.01"},
|
|
131
|
-
{"symbol":"BTCUSDT","side":"buy","orderType":"limit","force":"gtc","price":"63000","size":"0.02"},
|
|
132
|
-
{"symbol":"ETHUSDT","side":"buy","orderType":"limit","force":"gtc","price":"3100","size":"0.5"}
|
|
133
|
-
]'
|
|
134
|
-
```
|
|
135
|
-
> Place a DCA ladder of buy orders in one call. Max 50 orders per batch.
|
|
136
|
-
|
|
137
|
-
### Case 7: Custom client order ID (deduplication)
|
|
138
|
-
```bash
|
|
139
|
-
bgc spot spot_place_order --orders '[{
|
|
140
|
-
"symbol": "BTCUSDT",
|
|
141
|
-
"side": "buy",
|
|
142
|
-
"orderType": "limit",
|
|
143
|
-
"force": "gtc",
|
|
144
|
-
"price": "65000",
|
|
145
|
-
"size": "0.01",
|
|
146
|
-
"clientOid": "my-strategy-001"
|
|
147
|
-
}]'
|
|
148
|
-
```
|
|
149
|
-
> Use `clientOid` to track orders by your own ID and prevent duplicate submissions.
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## Important Notes
|
|
154
|
-
|
|
155
|
-
- **`size` semantics flip** by order type and side:
|
|
156
|
-
- Limit buy/sell, market sell → `size` = base coin (e.g., BTC)
|
|
157
|
-
- Market buy → `size` = quote coin (e.g., USDT)
|
|
158
|
-
- **`tpslType=tpsl`** creates a standalone TP/SL order; cannot use `presetTakeProfitPrice` etc. simultaneously
|
|
159
|
-
- Get decimal precision (minSize, priceScale) via: `bgc spot spot_get_symbols --symbol BTCUSDT`
|
|
160
|
-
- Batch responses include both `successList` and `failureList` — partial success is possible
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## Official Docs
|
|
165
|
-
- Spot Place Order: https://www.bitget.com/api-doc/spot/trade/Place-Order
|
|
166
|
-
- Spot Batch Orders: https://www.bitget.com/api-doc/spot/trade/Batch-Place-Orders
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# spot_place_plan_order / spot_get_plan_orders / spot_cancel_plan_orders — Spot Trigger Orders
|
|
2
|
-
|
|
3
|
-
## Official Description
|
|
4
|
-
Spot trigger (plan) orders are conditional orders that activate when the market price reaches a specified trigger price. Once triggered, the system places either a limit or market order on your behalf.
|
|
5
|
-
|
|
6
|
-
**Endpoints:**
|
|
7
|
-
- Place: `POST /api/v2/spot/trade/place-plan-order`
|
|
8
|
-
- Modify: `POST /api/v2/spot/trade/modify-plan-order`
|
|
9
|
-
- Cancel: `POST /api/v2/spot/trade/cancel-plan-order`
|
|
10
|
-
- Get current: `GET /api/v2/spot/trade/current-plan-order`
|
|
11
|
-
- Get history: `GET /api/v2/spot/trade/history-plan-order`
|
|
12
|
-
|
|
13
|
-
**Auth required:** Yes
|
|
14
|
-
**Rate limit:** Place/modify: 20 req/s per UID
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Place Plan Order Parameters
|
|
19
|
-
|
|
20
|
-
| Parameter | Type | Required | Allowed Values | Description |
|
|
21
|
-
|-----------|------|----------|----------------|-------------|
|
|
22
|
-
| `symbol` | string | Yes | e.g. `BTCUSDT` | Trading pair |
|
|
23
|
-
| `side` | string | Yes | `buy`, `sell` | Order direction |
|
|
24
|
-
| `triggerPrice` | string | Yes | e.g. `"68000"` | Price that activates this order |
|
|
25
|
-
| `triggerType` | string | Yes | `fill_price`, `mark_price` | Which price feed to watch |
|
|
26
|
-
| `orderType` | string | Yes | `limit`, `market` | Execution order type once triggered |
|
|
27
|
-
| `price` | string | Conditional | e.g. `"68100"` | Execution price. Required when `orderType=limit` |
|
|
28
|
-
| `size` | string | Yes | e.g. `"0.01"` | Order quantity |
|
|
29
|
-
| `planType` | string | No | `amount` (default), `total` | `amount` = base coin; `total` = quote coin |
|
|
30
|
-
| `clientOid` | string | No | e.g. `"trigger-001"` | Custom ID for tracking |
|
|
31
|
-
| `stpMode` | string | No | `none`, `cancel_taker`, `cancel_maker`, `cancel_both` | Self-trade prevention |
|
|
32
|
-
|
|
33
|
-
### `triggerType` Values
|
|
34
|
-
| Value | Description |
|
|
35
|
-
|-------|-------------|
|
|
36
|
-
| `fill_price` | Triggers based on last traded price |
|
|
37
|
-
| `mark_price` | Triggers based on mark price (more resistant to manipulation) |
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Get Plan Orders Parameters
|
|
42
|
-
|
|
43
|
-
| Parameter | Type | Required | Description |
|
|
44
|
-
|-----------|------|----------|-------------|
|
|
45
|
-
| `symbol` | string | Yes | Trading pair |
|
|
46
|
-
| `status` | string | No | `current` (default) = pending triggers; `history` = triggered/cancelled |
|
|
47
|
-
| `startTime` | string | No | Unix ms (history only) |
|
|
48
|
-
| `endTime` | string | No | Unix ms (history only) |
|
|
49
|
-
| `limit` | number | No | Default 100 |
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## Cancel Plan Orders Parameters
|
|
54
|
-
|
|
55
|
-
| Parameter | Type | Required | Description |
|
|
56
|
-
|-----------|------|----------|-------------|
|
|
57
|
-
| `orderId` | string | No | Cancel single plan order |
|
|
58
|
-
| `orderIds` | array | No | Cancel multiple plan orders |
|
|
59
|
-
| `symbol` | string | No | Cancel ALL plan orders for symbol |
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## Usage Cases
|
|
64
|
-
|
|
65
|
-
### Case 1: Breakout buy — buy when price breaks above resistance
|
|
66
|
-
```bash
|
|
67
|
-
bgc spot spot_place_plan_order \
|
|
68
|
-
--triggerPrice "70000" \
|
|
69
|
-
--symbol BTCUSDT \
|
|
70
|
-
--side buy \
|
|
71
|
-
--triggerType fill_price \
|
|
72
|
-
--orderType limit \
|
|
73
|
-
--price "70100" \
|
|
74
|
-
--size "0.01"
|
|
75
|
-
```
|
|
76
|
-
> Triggers when BTC hits $70,000. Places a limit buy at $70,100 (slight buffer to ensure fill).
|
|
77
|
-
|
|
78
|
-
### Case 2: Stop-loss — sell if price drops below support
|
|
79
|
-
```bash
|
|
80
|
-
bgc spot spot_place_plan_order \
|
|
81
|
-
--triggerPrice "60000" \
|
|
82
|
-
--symbol BTCUSDT \
|
|
83
|
-
--side sell \
|
|
84
|
-
--triggerType fill_price \
|
|
85
|
-
--orderType market \
|
|
86
|
-
--size "0.01"
|
|
87
|
-
```
|
|
88
|
-
> If BTC falls to $60,000, immediately market-sell 0.01 BTC to cut losses.
|
|
89
|
-
|
|
90
|
-
### Case 3: Take-profit limit sell
|
|
91
|
-
```bash
|
|
92
|
-
bgc spot spot_place_plan_order \
|
|
93
|
-
--triggerPrice "75000" \
|
|
94
|
-
--symbol BTCUSDT \
|
|
95
|
-
--side sell \
|
|
96
|
-
--triggerType fill_price \
|
|
97
|
-
--orderType limit \
|
|
98
|
-
--price "74900" \
|
|
99
|
-
--size "0.01"
|
|
100
|
-
```
|
|
101
|
-
> When BTC reaches $75,000, place a limit sell at $74,900.
|
|
102
|
-
|
|
103
|
-
### Case 4: Buy the dip — conditional buy at lower price
|
|
104
|
-
```bash
|
|
105
|
-
bgc spot spot_place_plan_order \
|
|
106
|
-
--triggerPrice "58000" \
|
|
107
|
-
--symbol BTCUSDT \
|
|
108
|
-
--side buy \
|
|
109
|
-
--triggerType fill_price \
|
|
110
|
-
--orderType limit \
|
|
111
|
-
--price "57900" \
|
|
112
|
-
--size "0.02"
|
|
113
|
-
```
|
|
114
|
-
> Wait for a dip to $58,000, then buy at $57,900.
|
|
115
|
-
|
|
116
|
-
### Case 5: View all pending trigger orders
|
|
117
|
-
```bash
|
|
118
|
-
bgc spot spot_get_plan_orders --symbol BTCUSDT --status current
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Case 6: Cancel a specific plan order
|
|
122
|
-
```bash
|
|
123
|
-
bgc spot spot_cancel_plan_orders --orderId "plan-order-id-here"
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Case 7: Cancel all plan orders for a symbol
|
|
127
|
-
```bash
|
|
128
|
-
bgc spot spot_cancel_plan_orders --symbol BTCUSDT
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Case 8: Modify an existing plan order
|
|
132
|
-
```bash
|
|
133
|
-
# Use spot_place_plan_order with --orderId to modify
|
|
134
|
-
bgc spot spot_place_plan_order \
|
|
135
|
-
--orderId "existing-plan-order-id" \
|
|
136
|
-
--triggerPrice "71000" \
|
|
137
|
-
--symbol BTCUSDT \
|
|
138
|
-
--side buy \
|
|
139
|
-
--triggerType fill_price \
|
|
140
|
-
--orderType limit \
|
|
141
|
-
--price "71100" \
|
|
142
|
-
--size "0.01"
|
|
143
|
-
```
|
|
144
|
-
> Pass `--orderId` to modify an existing plan order instead of creating a new one.
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
## Important Notes
|
|
149
|
-
|
|
150
|
-
- Plan orders are **pending** until triggered — they show under `status=current`
|
|
151
|
-
- After triggering, they move to `status=history` (with execution result)
|
|
152
|
-
- `mark_price` triggers are harder to manipulate via wash trading — prefer for stop-losses
|
|
153
|
-
- `planType=total` lets you specify spend amount in quote coin (e.g., spend 1000 USDT)
|
|
154
|
-
- Plan orders do **not** reserve margin/balance — ensure funds are available at trigger time
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## Official Docs
|
|
159
|
-
- Place Plan Order: https://www.bitget.com/api-doc/spot/plan/Place-Plan-Order
|
|
160
|
-
- Current Plan Orders: https://www.bitget.com/api-doc/spot/plan/Get-Current-Plan-Orders
|