@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,55 @@
|
|
|
1
|
+
# Bitget Demo Trading
|
|
2
|
+
|
|
3
|
+
Demo Trading lets you trade with virtual funds in a real-market environment.
|
|
4
|
+
Use it to test strategies without risking real money.
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
|
|
8
|
+
1. Log in to https://www.bitget.com
|
|
9
|
+
2. Switch to Demo Trading mode (toggle in the top navigation bar)
|
|
10
|
+
3. Go to **Personal Center → API Key Management**
|
|
11
|
+
4. Create a **Demo API Key** with Trade permissions
|
|
12
|
+
5. Note: Demo API Keys are completely separate from live trading keys
|
|
13
|
+
|
|
14
|
+
## Using Demo Mode with bgc CLI
|
|
15
|
+
|
|
16
|
+
Set your Demo API Key credentials as environment variables:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
export BITGET_API_KEY="your-demo-api-key"
|
|
20
|
+
export BITGET_SECRET_KEY="your-demo-secret-key"
|
|
21
|
+
export BITGET_PASSPHRASE="your-demo-passphrase"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Then add `--paper-trading` flag to any bgc command:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Check demo account balance
|
|
28
|
+
bgc --paper-trading account get_account_assets
|
|
29
|
+
|
|
30
|
+
# Place a demo spot order
|
|
31
|
+
bgc --paper-trading spot spot_place_order --orders '[{"symbol":"BTCUSDT","side":"buy","orderType":"market","size":"0.01"}]'
|
|
32
|
+
|
|
33
|
+
# Check demo futures positions
|
|
34
|
+
bgc --paper-trading futures futures_get_positions --productType USDT-FUTURES
|
|
35
|
+
|
|
36
|
+
# Place a demo futures order
|
|
37
|
+
bgc --paper-trading futures futures_place_order --orders '[{"symbol":"BTCUSDT","productType":"USDT-FUTURES","marginCoin":"USDT","size":"0.01","side":"open_long","orderType":"market"}]'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Using Demo Mode with bitget-mcp
|
|
41
|
+
|
|
42
|
+
Start the MCP server with the `--paper-trading` flag:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
bitget-mcp --paper-trading --modules spot,futures,account
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
All tools in that MCP session will operate in demo mode.
|
|
49
|
+
|
|
50
|
+
## Important Caveats
|
|
51
|
+
|
|
52
|
+
- **Demo keys ≠ Live keys**: Never mix them. Demo keys only work with `--paper-trading`.
|
|
53
|
+
- **Virtual funds only**: No real money is involved; balances can be reset manually via the Bitget demo dashboard.
|
|
54
|
+
- **Real market data**: Prices reflect live market conditions.
|
|
55
|
+
- **All modules supported**: Spot, futures, account, etc. all work in demo mode.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Bitget Error Codes
|
|
2
|
+
|
|
3
|
+
## bgc client errors
|
|
4
|
+
|
|
5
|
+
| Code | Meaning | Recovery |
|
|
6
|
+
|------|---------|----------|
|
|
7
|
+
| `AUTH_MISSING` | No API credentials set | Set `BITGET_API_KEY`, `BITGET_SECRET_KEY`, `BITGET_PASSPHRASE` |
|
|
8
|
+
| `RATE_LIMITED` | Too many requests | Wait 1 second and retry |
|
|
9
|
+
| `INVALID_SYMBOL` | Unknown trading pair | Check format: `BTCUSDT` not `BTC/USDT` |
|
|
10
|
+
| `INSUFFICIENT_BALANCE` | Not enough funds | Check balance with `bgc account get_account_assets` |
|
|
11
|
+
| `MODULE_FILTERED` | Module not enabled | Add module with `--modules` flag |
|
|
12
|
+
| `TOOL_NOT_AVAILABLE` | Tool not in current session | Run `bgc <module> --help` |
|
|
13
|
+
| `CONFIG_ERROR` | Invalid configuration | Check env vars and flags |
|
|
14
|
+
|
|
15
|
+
## Bitget API error codes
|
|
16
|
+
|
|
17
|
+
| Code | Meaning | Recovery |
|
|
18
|
+
|------|---------|----------|
|
|
19
|
+
| `00000` | Success | — |
|
|
20
|
+
| `40001` | Access denied | Check API key permissions |
|
|
21
|
+
| `40003` | Invalid signature | Check `BITGET_SECRET_KEY` is correct |
|
|
22
|
+
| `40005` | Invalid timestamp | System clock may be out of sync |
|
|
23
|
+
| `40006` | IP not in whitelist | Add your IP to API key whitelist |
|
|
24
|
+
| `40007` | Request expired | Retry the request |
|
|
25
|
+
| `40009` | Duplicate client order id | Use a unique `clientOid` |
|
|
26
|
+
| `40017` | Invalid API key | Re-check `BITGET_API_KEY` |
|
|
27
|
+
| `40018` | API key permissions insufficient | Enable Trade permission on API key |
|
|
28
|
+
| `40037` | API key does not exist | Verify key is active |
|
|
29
|
+
| `40786` | Insufficient balance | Transfer funds to correct account |
|
|
30
|
+
| `40788` | Price out of range | Adjust order price |
|
|
31
|
+
| `43011` | Invalid parameter | Check required fields in request |
|
|
32
|
+
| `43012` | Symbol does not exist | Verify symbol format (e.g. `BTCUSDT`) |
|
|
33
|
+
| `43025` | Order does not exist | Order may have already been filled or cancelled |
|
|
34
|
+
| `45110` | Minimum order size not met | Increase order size |
|
|
35
|
+
|
|
36
|
+
## Common recovery patterns
|
|
37
|
+
|
|
38
|
+
**Missing credentials:**
|
|
39
|
+
```bash
|
|
40
|
+
export BITGET_API_KEY="your-key"
|
|
41
|
+
export BITGET_SECRET_KEY="your-secret"
|
|
42
|
+
export BITGET_PASSPHRASE="your-passphrase"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Wrong account type for transfer:**
|
|
46
|
+
- Spot account: `spot`
|
|
47
|
+
- USDT futures: `futures_usdt` (not `usdt-futures`)
|
|
48
|
+
- Funding account: `mix_usdt`
|
|
49
|
+
|
|
50
|
+
**Futures productType values:**
|
|
51
|
+
- USDT-margined perpetuals: `USDT-FUTURES`
|
|
52
|
+
- Coin-margined perpetuals: `COIN-FUTURES`
|
|
53
|
+
- USDC-margined perpetuals: `USDC-FUTURES`
|
|
@@ -0,0 +1,36 @@
|
|
|
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) |
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# futures_set_leverage / futures_update_config — Futures Leverage & Configuration
|
|
2
|
+
|
|
3
|
+
## Official Description
|
|
4
|
+
Set leverage for a futures contract, or update position mode (one-way/hedge), margin mode (isolated/crossed), or auto-margin settings.
|
|
5
|
+
|
|
6
|
+
**Endpoints:**
|
|
7
|
+
- Set leverage: `POST /api/v2/mix/account/set-leverage`
|
|
8
|
+
- Update config: `POST /api/v2/mix/account/set-margin-mode` | `POST /api/v2/mix/account/set-position-mode` | `POST /api/v2/mix/account/set-auto-margin`
|
|
9
|
+
|
|
10
|
+
**Auth required:** Yes
|
|
11
|
+
**Rate limit:** 5 req/s per UID
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## futures_set_leverage Parameters
|
|
16
|
+
|
|
17
|
+
| Parameter | Type | Required | Allowed Values | Description |
|
|
18
|
+
|-----------|------|----------|----------------|-------------|
|
|
19
|
+
| `productType` | string | Yes | `USDT-FUTURES`, `COIN-FUTURES`, `USDC-FUTURES` | Contract type |
|
|
20
|
+
| `symbol` | string | Yes | e.g. `BTCUSDT` | Contract symbol |
|
|
21
|
+
| `marginCoin` | string | Yes | e.g. `USDT` | Margin coin (must match productType) |
|
|
22
|
+
| `leverage` | string | Yes | e.g. `"10"`, `"20"`, `"125"` | Target leverage multiplier |
|
|
23
|
+
| `holdSide` | string | No | `long`, `short` | Required only in **hedge mode** to set per-side leverage |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## futures_update_config 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 | Yes | e.g. `BTCUSDT` | Contract symbol |
|
|
33
|
+
| `marginCoin` | string | Yes | e.g. `USDT` | Margin coin |
|
|
34
|
+
| `setting` | string | Yes | `marginMode`, `positionMode`, `autoMargin` | Which setting to change |
|
|
35
|
+
| `value` | string | Yes | (depends on setting) | New value for the setting |
|
|
36
|
+
| `holdSide` | string | No | `long`, `short` | Required for autoMargin setting in hedge mode |
|
|
37
|
+
|
|
38
|
+
### `setting` + `value` Combinations
|
|
39
|
+
|
|
40
|
+
| setting | value options | Description |
|
|
41
|
+
|---------|--------------|-------------|
|
|
42
|
+
| `marginMode` | `isolated`, `crossed` | Isolated = per-position margin; Crossed = shared account margin |
|
|
43
|
+
| `positionMode` | `one_way_mode`, `hedge_mode` | One-way = single position per symbol; Hedge = separate long+short |
|
|
44
|
+
| `autoMargin` | `on`, `off` | Auto top-up margin when approaching liquidation |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Usage Cases
|
|
49
|
+
|
|
50
|
+
### Case 1: Set leverage to 10x (one-way mode)
|
|
51
|
+
```bash
|
|
52
|
+
bgc futures futures_set_leverage \
|
|
53
|
+
--productType USDT-FUTURES \
|
|
54
|
+
--symbol BTCUSDT \
|
|
55
|
+
--marginCoin USDT \
|
|
56
|
+
--leverage 10
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Case 2: Set leverage to 20x (isolated margin)
|
|
60
|
+
```bash
|
|
61
|
+
bgc futures futures_set_leverage \
|
|
62
|
+
--productType USDT-FUTURES \
|
|
63
|
+
--symbol ETHUSDT \
|
|
64
|
+
--marginCoin USDT \
|
|
65
|
+
--leverage 20
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Case 3: Set different leverage for long vs short (hedge mode)
|
|
69
|
+
```bash
|
|
70
|
+
# Set long-side leverage
|
|
71
|
+
bgc futures futures_set_leverage \
|
|
72
|
+
--productType USDT-FUTURES \
|
|
73
|
+
--symbol BTCUSDT \
|
|
74
|
+
--marginCoin USDT \
|
|
75
|
+
--leverage 10 \
|
|
76
|
+
--holdSide long
|
|
77
|
+
|
|
78
|
+
# Set short-side leverage
|
|
79
|
+
bgc futures futures_set_leverage \
|
|
80
|
+
--productType USDT-FUTURES \
|
|
81
|
+
--symbol BTCUSDT \
|
|
82
|
+
--marginCoin USDT \
|
|
83
|
+
--leverage 5 \
|
|
84
|
+
--holdSide short
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Case 4: Switch to isolated margin mode
|
|
88
|
+
```bash
|
|
89
|
+
bgc futures futures_update_config \
|
|
90
|
+
--productType USDT-FUTURES \
|
|
91
|
+
--symbol BTCUSDT \
|
|
92
|
+
--marginCoin USDT \
|
|
93
|
+
--setting marginMode \
|
|
94
|
+
--value isolated
|
|
95
|
+
```
|
|
96
|
+
> Isolated mode limits losses to the margin allocated to this position only.
|
|
97
|
+
|
|
98
|
+
### Case 5: Switch to crossed margin mode
|
|
99
|
+
```bash
|
|
100
|
+
bgc futures futures_update_config \
|
|
101
|
+
--productType USDT-FUTURES \
|
|
102
|
+
--symbol BTCUSDT \
|
|
103
|
+
--marginCoin USDT \
|
|
104
|
+
--setting marginMode \
|
|
105
|
+
--value crossed
|
|
106
|
+
```
|
|
107
|
+
> Crossed mode uses all available USDT as margin — higher liquidation threshold but more capital at risk.
|
|
108
|
+
|
|
109
|
+
### Case 6: Enable hedge mode (hold long + short simultaneously)
|
|
110
|
+
```bash
|
|
111
|
+
bgc futures futures_update_config \
|
|
112
|
+
--productType USDT-FUTURES \
|
|
113
|
+
--symbol BTCUSDT \
|
|
114
|
+
--marginCoin USDT \
|
|
115
|
+
--setting positionMode \
|
|
116
|
+
--value hedge_mode
|
|
117
|
+
```
|
|
118
|
+
> Enables holding both long and short positions on the same symbol at the same time.
|
|
119
|
+
|
|
120
|
+
### Case 7: Switch back to one-way mode
|
|
121
|
+
```bash
|
|
122
|
+
bgc futures futures_update_config \
|
|
123
|
+
--productType USDT-FUTURES \
|
|
124
|
+
--symbol BTCUSDT \
|
|
125
|
+
--marginCoin USDT \
|
|
126
|
+
--setting positionMode \
|
|
127
|
+
--value one_way_mode
|
|
128
|
+
```
|
|
129
|
+
> Note: Cannot switch modes while you have open positions or orders on this symbol.
|
|
130
|
+
|
|
131
|
+
### Case 8: Enable auto-margin (prevent liquidation by auto top-up)
|
|
132
|
+
```bash
|
|
133
|
+
bgc futures futures_update_config \
|
|
134
|
+
--productType USDT-FUTURES \
|
|
135
|
+
--symbol BTCUSDT \
|
|
136
|
+
--marginCoin USDT \
|
|
137
|
+
--setting autoMargin \
|
|
138
|
+
--value on
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Case 9: COIN-FUTURES leverage setup
|
|
142
|
+
```bash
|
|
143
|
+
bgc futures futures_set_leverage \
|
|
144
|
+
--productType COIN-FUTURES \
|
|
145
|
+
--symbol BTCUSD \
|
|
146
|
+
--marginCoin BTC \
|
|
147
|
+
--leverage 10
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Recommended Setup Sequence
|
|
153
|
+
|
|
154
|
+
Before trading a new contract:
|
|
155
|
+
```bash
|
|
156
|
+
# 1. Set position mode (do this first, before any positions)
|
|
157
|
+
bgc futures futures_update_config --productType USDT-FUTURES --symbol BTCUSDT --marginCoin USDT --setting positionMode --value one_way_mode
|
|
158
|
+
|
|
159
|
+
# 2. Set margin mode
|
|
160
|
+
bgc futures futures_update_config --productType USDT-FUTURES --symbol BTCUSDT --marginCoin USDT --setting marginMode --value crossed
|
|
161
|
+
|
|
162
|
+
# 3. Set leverage
|
|
163
|
+
bgc futures futures_set_leverage --productType USDT-FUTURES --symbol BTCUSDT --marginCoin USDT --leverage 10
|
|
164
|
+
|
|
165
|
+
# 4. Verify settings
|
|
166
|
+
bgc futures futures_get_positions --productType USDT-FUTURES --symbol BTCUSDT
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Important Notes
|
|
172
|
+
|
|
173
|
+
- Cannot change `positionMode` while you have open positions or orders on that symbol
|
|
174
|
+
- Cannot change `marginMode` while you have an open position on that symbol
|
|
175
|
+
- Max leverage varies by contract and notional position size — larger positions have lower max leverage
|
|
176
|
+
- `holdSide` for `futures_set_leverage` is only needed in hedge mode; omit in one-way mode
|
|
177
|
+
- `autoMargin=on` draws from your available balance — ensure sufficient USDT to avoid unintended draws
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Official Docs
|
|
182
|
+
- Set Leverage: https://www.bitget.com/api-doc/contract/account/Set-Leverage
|
|
183
|
+
- Set Margin Mode: https://www.bitget.com/api-doc/contract/account/Set-Margin-Mode
|
|
184
|
+
- Set Position Mode: https://www.bitget.com/api-doc/contract/account/Set-Position-Mode
|