@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,154 @@
|
|
|
1
|
+
# futures_get_positions — Futures Positions
|
|
2
|
+
|
|
3
|
+
## Official Description
|
|
4
|
+
Get current open positions or position history for futures contracts. Returns full position details including size, entry price, leverage, unrealized PnL, liquidation price, and margin.
|
|
5
|
+
|
|
6
|
+
**Endpoints:**
|
|
7
|
+
- Current positions: `GET /api/v2/mix/position/single-position` (single) | `GET /api/v2/mix/position/all-position` (all)
|
|
8
|
+
- Position history: `GET /api/v2/mix/position/history-position`
|
|
9
|
+
|
|
10
|
+
**Auth required:** Yes
|
|
11
|
+
**Rate limit:** 10 req/s per UID
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## bgc CLI Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bgc futures futures_get_positions \
|
|
19
|
+
--productType <PRODUCT_TYPE> \
|
|
20
|
+
[--symbol <SYMBOL>] \
|
|
21
|
+
[--marginCoin <coin>] \
|
|
22
|
+
[--history true]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Parameters
|
|
28
|
+
|
|
29
|
+
| Parameter | Type | Required | Allowed Values | Description |
|
|
30
|
+
|-----------|------|----------|----------------|-------------|
|
|
31
|
+
| `productType` | string | Yes | `USDT-FUTURES`, `COIN-FUTURES`, `USDC-FUTURES` | Contract type |
|
|
32
|
+
| `symbol` | string | No | e.g. `BTCUSDT` | Filter to one contract |
|
|
33
|
+
| `marginCoin` | string | No | e.g. `USDT` | Filter by margin coin |
|
|
34
|
+
| `history` | boolean | No | `true` | Get closed position history instead of open |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Key Response Fields (Current Positions)
|
|
39
|
+
|
|
40
|
+
| Field | Type | Description |
|
|
41
|
+
|-------|------|-------------|
|
|
42
|
+
| `symbol` | string | Contract pair |
|
|
43
|
+
| `holdSide` | string | `long` or `short` |
|
|
44
|
+
| `marginMode` | string | `isolated` or `crossed` |
|
|
45
|
+
| `marginCoin` | string | Collateral coin |
|
|
46
|
+
| `margin` | string | Margin allocated to this position |
|
|
47
|
+
| `available` | string | Closeable size |
|
|
48
|
+
| `total` | string | Total position size |
|
|
49
|
+
| `openPriceAvg` | string | Average entry price |
|
|
50
|
+
| `leverage` | string | Current leverage |
|
|
51
|
+
| `unrealizedPL` | string | Unrealized profit/loss |
|
|
52
|
+
| `liquidationPrice` | string | Liquidation price |
|
|
53
|
+
| `keepMarginRate` | string | Maintenance margin rate |
|
|
54
|
+
| `achievedProfits` | string | Realized PnL (partial closes) |
|
|
55
|
+
| `marketPrice` | string | Current mark price |
|
|
56
|
+
| `autoMargin` | string | Auto-margin status: `on` or `off` |
|
|
57
|
+
| `cTime` | string | Position opened timestamp (ms) |
|
|
58
|
+
| `uTime` | string | Last updated timestamp (ms) |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Before Closing a Position — Read This First
|
|
63
|
+
|
|
64
|
+
Always run this before placing a close order:
|
|
65
|
+
```bash
|
|
66
|
+
bgc futures futures_get_positions --productType USDT-FUTURES --symbol BTCUSDT
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
From the response, note:
|
|
70
|
+
- **`holdSide`**: `long` or `short` — determines which `side` to use for closing
|
|
71
|
+
- **`posMode`**: `one_way_mode` or `hedge_mode` — determines which close method to use
|
|
72
|
+
- **`available`**: closeable size — use this as max `size` in your close order
|
|
73
|
+
- **`total`**: total size (may differ from `available` if reduce-only orders already exist)
|
|
74
|
+
|
|
75
|
+
### Closing cheatsheet based on what you see
|
|
76
|
+
|
|
77
|
+
| `holdSide` | `posMode` | Close order `side` | 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
|
+
**Common mistake**: Using `sell` to close a `short` — this opens MORE short, it does not close it.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Usage Cases
|
|
89
|
+
|
|
90
|
+
### Case 1: View all open positions (USDT futures)
|
|
91
|
+
```bash
|
|
92
|
+
bgc futures futures_get_positions --productType USDT-FUTURES
|
|
93
|
+
```
|
|
94
|
+
> Shows all open longs and shorts across all USDT-margined contracts.
|
|
95
|
+
|
|
96
|
+
### Case 2: Check position for a specific contract
|
|
97
|
+
```bash
|
|
98
|
+
bgc futures futures_get_positions --productType USDT-FUTURES --symbol BTCUSDT
|
|
99
|
+
```
|
|
100
|
+
> Check size, entry price, unrealized PnL, and liquidation price for your BTC position.
|
|
101
|
+
|
|
102
|
+
### Case 3: Check COIN-margined positions
|
|
103
|
+
```bash
|
|
104
|
+
bgc futures futures_get_positions --productType COIN-FUTURES --marginCoin BTC
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Case 4: View position history (closed positions)
|
|
108
|
+
```bash
|
|
109
|
+
bgc futures futures_get_positions --productType USDT-FUTURES --history true
|
|
110
|
+
```
|
|
111
|
+
> Shows recently closed positions with realized PnL.
|
|
112
|
+
|
|
113
|
+
### Case 5: Assess liquidation risk
|
|
114
|
+
```bash
|
|
115
|
+
bgc futures futures_get_positions --productType USDT-FUTURES --symbol BTCUSDT
|
|
116
|
+
# Check "liquidationPrice" vs current market price
|
|
117
|
+
# Check "keepMarginRate" — higher means closer to liquidation
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Case 6: Check available size before placing close order
|
|
121
|
+
```bash
|
|
122
|
+
bgc futures futures_get_positions --productType USDT-FUTURES --symbol BTCUSDT
|
|
123
|
+
# Use "available" field as max size for close order
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Case 7: Monitor unrealized PnL across all positions
|
|
127
|
+
```bash
|
|
128
|
+
bgc futures futures_get_positions --productType USDT-FUTURES
|
|
129
|
+
# Sum "unrealizedPL" fields across all positions
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Hedge Mode vs One-Way Mode
|
|
135
|
+
|
|
136
|
+
In **hedge mode**, you may have both a long and short position on the same symbol simultaneously. Each appears as a separate position with `holdSide` of `long` or `short`.
|
|
137
|
+
|
|
138
|
+
In **one-way mode**, there is at most one position per symbol, with `holdSide` reflecting the current direction.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Important Notes
|
|
143
|
+
|
|
144
|
+
- Positions with `total=0` are closed — they may briefly appear before being removed
|
|
145
|
+
- `available` may be less than `total` if you have open close orders occupying the position
|
|
146
|
+
- `liquidationPrice` is approximate — it changes as funding is applied
|
|
147
|
+
- For COIN-FUTURES, `margin` and PnL are denominated in the base coin (e.g., BTC), not USDT
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Official Docs
|
|
152
|
+
- All Positions: https://www.bitget.com/api-doc/contract/position/Get-All-Position
|
|
153
|
+
- Single Position: https://www.bitget.com/api-doc/contract/position/Get-Single-Position
|
|
154
|
+
- History Positions: https://www.bitget.com/api-doc/contract/position/Get-History-Position
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# spot_cancel_orders — Spot Cancel Orders
|
|
2
|
+
|
|
3
|
+
## Official Description
|
|
4
|
+
Cancel one or more open spot orders by order ID, batch of IDs, or cancel all open orders for a symbol.
|
|
5
|
+
|
|
6
|
+
**Endpoint:** `POST /api/v2/spot/trade/cancel-order` (single) | `POST /api/v2/spot/trade/batch-cancel-order` (batch) | `POST /api/v2/spot/trade/cancel-symbol-order` (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 spot spot_cancel_orders --symbol <SYMBOL> [--orderId <id> | --orderIds '[...]' | --cancelAll true]
|
|
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 | No | Cancel a single order by exchange order ID |
|
|
26
|
+
| `orderIds` | array | No | Cancel up to 50 orders by ID list |
|
|
27
|
+
| `cancelAll` | boolean | No | If `true`, cancel ALL open orders for the symbol |
|
|
28
|
+
|
|
29
|
+
> Exactly one of `orderId`, `orderIds`, or `cancelAll` should be used per call.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Response Fields
|
|
34
|
+
|
|
35
|
+
| Field | Type | Description |
|
|
36
|
+
|-------|------|-------------|
|
|
37
|
+
| `orderId` | string | Cancelled order ID |
|
|
38
|
+
| `clientOid` | string | Custom order ID if set |
|
|
39
|
+
|
|
40
|
+
For batch cancels, response includes `successList` and `failureList`.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Usage Cases
|
|
45
|
+
|
|
46
|
+
### Case 1: Cancel a single order
|
|
47
|
+
```bash
|
|
48
|
+
bgc spot spot_cancel_orders --symbol BTCUSDT --orderId "1234567890"
|
|
49
|
+
```
|
|
50
|
+
> Cancel one specific open order.
|
|
51
|
+
|
|
52
|
+
### Case 2: Cancel multiple specific orders
|
|
53
|
+
```bash
|
|
54
|
+
bgc spot spot_cancel_orders --symbol BTCUSDT --orderIds '["1234567890","9876543210","1122334455"]'
|
|
55
|
+
```
|
|
56
|
+
> Cancel up to 50 orders in one API call. Useful for clearing a DCA ladder.
|
|
57
|
+
|
|
58
|
+
### Case 3: Cancel ALL open orders for a symbol
|
|
59
|
+
```bash
|
|
60
|
+
bgc spot spot_cancel_orders --symbol BTCUSDT --cancelAll true
|
|
61
|
+
```
|
|
62
|
+
> Wipe all open orders on BTCUSDT at once. Use before a major position change or in emergency exit.
|
|
63
|
+
|
|
64
|
+
### Case 4: Cancel by clientOid (look up orderId first)
|
|
65
|
+
```bash
|
|
66
|
+
# Step 1: find the orderId
|
|
67
|
+
bgc spot spot_get_orders --symbol BTCUSDT --status open
|
|
68
|
+
|
|
69
|
+
# Step 2: cancel it
|
|
70
|
+
bgc spot spot_cancel_orders --symbol BTCUSDT --orderId "<found-orderId>"
|
|
71
|
+
```
|
|
72
|
+
> The cancel endpoint requires the exchange `orderId`. If you only have `clientOid`, query orders first.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Important Notes
|
|
77
|
+
|
|
78
|
+
- Cancelling an already-filled or cancelled order returns an error — check order status first if unsure
|
|
79
|
+
- `cancelAll` is the fastest way to exit all open orders on a symbol in a single call
|
|
80
|
+
- Batch cancel response includes `failureList` — partial cancellations are possible
|
|
81
|
+
- For plan/trigger orders use `spot_cancel_plan_orders` instead
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Official Docs
|
|
86
|
+
- Cancel Order: https://www.bitget.com/api-doc/spot/trade/Cancel-Order
|
|
87
|
+
- Batch Cancel: https://www.bitget.com/api-doc/spot/trade/Batch-Cancel-Orders
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
|
@@ -0,0 +1,166 @@
|
|
|
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
|