@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,160 @@
|
|
|
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
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Generates references/commands.md from @bitget-ai/bitget-agent-sdk tool specs
|
|
3
|
+
import { writeFileSync, mkdirSync } from "node:fs";
|
|
4
|
+
import { join, dirname } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const refsDir = join(__dirname, "..", "references");
|
|
9
|
+
mkdirSync(refsDir, { recursive: true });
|
|
10
|
+
|
|
11
|
+
const { buildTools, loadConfig } = await import("@bitget-ai/bitget-agent-sdk");
|
|
12
|
+
|
|
13
|
+
const config = loadConfig({ modules: "all", readOnly: false });
|
|
14
|
+
const tools = buildTools(config);
|
|
15
|
+
|
|
16
|
+
const lines = [
|
|
17
|
+
"# bgc Command Reference",
|
|
18
|
+
"",
|
|
19
|
+
"Auto-generated from @bitget-ai/bitget-agent-sdk tool definitions.",
|
|
20
|
+
"",
|
|
21
|
+
"## Usage",
|
|
22
|
+
"",
|
|
23
|
+
"```",
|
|
24
|
+
"bgc <module> <tool_name> [--param value ...]",
|
|
25
|
+
"```",
|
|
26
|
+
"",
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const byModule = {};
|
|
30
|
+
for (const tool of tools) {
|
|
31
|
+
if (!byModule[tool.module]) byModule[tool.module] = [];
|
|
32
|
+
byModule[tool.module].push(tool);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (const [module, moduleTools] of Object.entries(byModule)) {
|
|
36
|
+
lines.push(`## Module: ${module}`, "");
|
|
37
|
+
for (const tool of moduleTools) {
|
|
38
|
+
lines.push(`### \`${tool.name}\``);
|
|
39
|
+
lines.push("");
|
|
40
|
+
lines.push(tool.description);
|
|
41
|
+
lines.push("");
|
|
42
|
+
lines.push(`**Write operation:** ${tool.isWrite ? "Yes — requires confirmation" : "No"}`);
|
|
43
|
+
lines.push("");
|
|
44
|
+
|
|
45
|
+
const props = tool.inputSchema?.properties ?? {};
|
|
46
|
+
const required = tool.inputSchema?.required ?? [];
|
|
47
|
+
if (Object.keys(props).length > 0) {
|
|
48
|
+
lines.push("**Parameters:**", "");
|
|
49
|
+
lines.push("| Name | Type | Required | Description |");
|
|
50
|
+
lines.push("|------|------|----------|-------------|");
|
|
51
|
+
for (const [name, schema] of Object.entries(props)) {
|
|
52
|
+
const req = required.includes(name) ? "Yes" : "No";
|
|
53
|
+
const desc = schema.description ?? "";
|
|
54
|
+
lines.push(`| \`${name}\` | ${schema.type ?? "any"} | ${req} | ${desc} |`);
|
|
55
|
+
}
|
|
56
|
+
lines.push("");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
lines.push("**Example:**", "```bash");
|
|
60
|
+
const exampleArgs = Object.entries(props)
|
|
61
|
+
.slice(0, 2)
|
|
62
|
+
.map(([k]) => `--${k} <value>`)
|
|
63
|
+
.join(" ");
|
|
64
|
+
lines.push(`bgc ${module} ${tool.name}${exampleArgs ? " " + exampleArgs : ""}`);
|
|
65
|
+
lines.push("```", "");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
writeFileSync(join(refsDir, "commands.md"), lines.join("\n"), "utf8");
|
|
70
|
+
console.log(`Generated references/commands.md (${tools.length} tools)`);
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Bitget Skill Installer
|
|
4
|
+
*
|
|
5
|
+
* Usage (run explicitly — no postinstall side effects):
|
|
6
|
+
* npx bitget-agent-skill # default: Claude Code only
|
|
7
|
+
* npx bitget-agent-skill --interactive # prompt to choose targets
|
|
8
|
+
* npx bitget-agent-skill --target all # install to all supported tools
|
|
9
|
+
* npx bitget-agent-skill --target claude # Claude Code only
|
|
10
|
+
* npx bitget-agent-skill --target codex # Codex only
|
|
11
|
+
* npx bitget-agent-skill --target openclaw # OpenClaw only
|
|
12
|
+
* npx bitget-agent-skill --target claude,codex # multiple targets
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { copyFileSync, mkdirSync, existsSync, readdirSync } from "node:fs";
|
|
16
|
+
import { join, dirname } from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import { homedir } from "node:os";
|
|
19
|
+
import { createInterface } from "node:readline";
|
|
20
|
+
|
|
21
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const PKG_ROOT = join(__dirname, "..");
|
|
23
|
+
const HOME = homedir();
|
|
24
|
+
|
|
25
|
+
// Skill destinations per AI tool
|
|
26
|
+
const TARGETS = {
|
|
27
|
+
claude: {
|
|
28
|
+
label: "Claude Code",
|
|
29
|
+
skillDir: join(HOME, ".claude", "skills", "bitget-agent-skill"),
|
|
30
|
+
},
|
|
31
|
+
codex: {
|
|
32
|
+
label: "Codex",
|
|
33
|
+
skillDir: join(HOME, ".codex", "skills", "bitget-agent-skill"),
|
|
34
|
+
},
|
|
35
|
+
openclaw: {
|
|
36
|
+
label: "OpenClaw",
|
|
37
|
+
skillDir: join(HOME, ".openclaw", "skills", "bitget-agent-skill"),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const REF_FILES = ["commands.md", "error-codes.md", "auth-setup.md", "demo-trading.md"];
|
|
42
|
+
|
|
43
|
+
function installTo(targetKey) {
|
|
44
|
+
const target = TARGETS[targetKey];
|
|
45
|
+
const refsDir = join(target.skillDir, "references");
|
|
46
|
+
|
|
47
|
+
mkdirSync(target.skillDir, { recursive: true });
|
|
48
|
+
mkdirSync(refsDir, { recursive: true });
|
|
49
|
+
|
|
50
|
+
const skillSrc = join(PKG_ROOT, "skills", "SKILL.md");
|
|
51
|
+
copyFileSync(skillSrc, join(target.skillDir, "SKILL.md"));
|
|
52
|
+
|
|
53
|
+
for (const f of REF_FILES) {
|
|
54
|
+
const src = join(PKG_ROOT, "references", f);
|
|
55
|
+
if (existsSync(src)) {
|
|
56
|
+
copyFileSync(src, join(refsDir, f));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log(` ✓ ${target.label} → ${join(target.skillDir, "SKILL.md")}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function promptTargets() {
|
|
64
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
65
|
+
|
|
66
|
+
console.log("\nBitget Skill — choose installation targets:\n");
|
|
67
|
+
const keys = Object.keys(TARGETS);
|
|
68
|
+
keys.forEach((k, i) => {
|
|
69
|
+
console.log(` ${i + 1}. ${TARGETS[k].label} (${TARGETS[k].skillDir})`);
|
|
70
|
+
});
|
|
71
|
+
console.log(` ${keys.length + 1}. All of the above`);
|
|
72
|
+
console.log();
|
|
73
|
+
|
|
74
|
+
return new Promise((resolve) => {
|
|
75
|
+
rl.question(
|
|
76
|
+
`Enter numbers separated by commas [default: 1]: `,
|
|
77
|
+
(answer) => {
|
|
78
|
+
rl.close();
|
|
79
|
+
const trimmed = answer.trim();
|
|
80
|
+
if (!trimmed || trimmed === "1") {
|
|
81
|
+
resolve(["claude"]);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (trimmed === String(keys.length + 1)) {
|
|
85
|
+
resolve(keys);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const selected = trimmed
|
|
89
|
+
.split(",")
|
|
90
|
+
.map((s) => parseInt(s.trim(), 10) - 1)
|
|
91
|
+
.filter((i) => i >= 0 && i < keys.length)
|
|
92
|
+
.map((i) => keys[i]);
|
|
93
|
+
resolve(selected.length > 0 ? selected : ["claude"]);
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function main() {
|
|
100
|
+
const args = process.argv.slice(2);
|
|
101
|
+
const isInteractive = args.includes("--interactive");
|
|
102
|
+
const targetArg = args.find((a) => a.startsWith("--target=") || a === "--target");
|
|
103
|
+
let targetValue = null;
|
|
104
|
+
if (targetArg) {
|
|
105
|
+
if (targetArg === "--target") {
|
|
106
|
+
targetValue = args[args.indexOf("--target") + 1];
|
|
107
|
+
} else {
|
|
108
|
+
targetValue = targetArg.split("=")[1];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let selectedKeys;
|
|
113
|
+
|
|
114
|
+
if (isInteractive) {
|
|
115
|
+
// Interactive mode — prompt user
|
|
116
|
+
try {
|
|
117
|
+
selectedKeys = await promptTargets();
|
|
118
|
+
} catch {
|
|
119
|
+
selectedKeys = ["claude"];
|
|
120
|
+
}
|
|
121
|
+
} else if (targetValue) {
|
|
122
|
+
// --target flag
|
|
123
|
+
if (targetValue === "all") {
|
|
124
|
+
selectedKeys = Object.keys(TARGETS);
|
|
125
|
+
} else {
|
|
126
|
+
selectedKeys = targetValue
|
|
127
|
+
.split(",")
|
|
128
|
+
.map((s) => s.trim())
|
|
129
|
+
.filter((k) => k in TARGETS);
|
|
130
|
+
if (selectedKeys.length === 0) {
|
|
131
|
+
console.warn(
|
|
132
|
+
`Unknown target(s): ${targetValue}. Valid targets: ${Object.keys(TARGETS).join(", ")}, all`
|
|
133
|
+
);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
// Default postinstall: Claude Code only, silent on failure
|
|
139
|
+
try {
|
|
140
|
+
installTo("claude");
|
|
141
|
+
} catch (err) {
|
|
142
|
+
console.warn("Could not auto-install skill:", err.message);
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
console.log("\nInstalling Bitget skill...");
|
|
148
|
+
let ok = 0;
|
|
149
|
+
for (const key of selectedKeys) {
|
|
150
|
+
try {
|
|
151
|
+
installTo(key);
|
|
152
|
+
ok++;
|
|
153
|
+
} catch (err) {
|
|
154
|
+
console.warn(` ✗ ${TARGETS[key].label}: ${err.message}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
console.log(`\nDone — installed to ${ok} of ${selectedKeys.length} targets.`);
|
|
158
|
+
|
|
159
|
+
if (selectedKeys.includes("claude")) {
|
|
160
|
+
console.log(
|
|
161
|
+
"\nClaude Code: restart Claude Code to pick up the skill, or run:\n" +
|
|
162
|
+
" claude skills list"
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
if (selectedKeys.includes("codex")) {
|
|
166
|
+
console.log(
|
|
167
|
+
"\nCodex: skill will be loaded automatically from ~/.codex/skills/bitget-agent-skill/"
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
if (selectedKeys.includes("openclaw")) {
|
|
171
|
+
console.log(
|
|
172
|
+
"\nOpenClaw: skill will be loaded automatically from ~/.openclaw/skills/bitget-agent-skill/"
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
main();
|
package/skills/SKILL.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bitget
|
|
3
|
+
description: >
|
|
4
|
+
Use this skill whenever the user wants to check prices, manage account balances,
|
|
5
|
+
place or cancel orders, manage futures or spot positions, set leverage, transfer
|
|
6
|
+
funds, check funding rates, use demo/paper trading, or do anything else on the
|
|
7
|
+
Bitget exchange. Invoke this skill even when the user doesn't say "Bitget" by name
|
|
8
|
+
— action phrases like "check my open orders", "cancel my BTC position", "move USDT
|
|
9
|
+
to futures", "what's my P&L", "place a market sell", "how much can I withdraw",
|
|
10
|
+
"show my positions", "set leverage to 10x", "what's the funding rate" all require
|
|
11
|
+
this skill. Also invoke for Chinese-language trading requests such as "查看我的账户",
|
|
12
|
+
"下一个限价单", "查看持仓盈亏", "转账到合约账户", "BTC现在多少钱" — these are Bitget
|
|
13
|
+
operations even without the exchange name. Always invoke this skill before attempting
|
|
14
|
+
any exchange trading task from scratch.
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Bitget Skill
|
|
18
|
+
|
|
19
|
+
You have access to the full Bitget exchange via the `bgc` CLI tool — spot, futures,
|
|
20
|
+
account, margin, copy-trading, convert, earn, P2P, and broker operations.
|
|
21
|
+
|
|
22
|
+
## Step 1: Check prerequisites
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bgc --version
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If not found → tell the user: `npm install -g bitget-client`
|
|
29
|
+
|
|
30
|
+
For private endpoints (account info, trading, transfers): credentials must be set.
|
|
31
|
+
See `~/.claude/skills/bitget-skill/references/auth-setup.md`.
|
|
32
|
+
|
|
33
|
+
## Step 2: Run the command
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bgc <module> <tool_name> [--param value ...]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
All output is JSON. The response always has:
|
|
40
|
+
- `data` — the actual result
|
|
41
|
+
- `endpoint` — which API was called
|
|
42
|
+
- `requestTime` — request timestamp
|
|
43
|
+
|
|
44
|
+
For the full list of tools and parameters, read:
|
|
45
|
+
`~/.claude/skills/bitget-skill/references/commands.md`
|
|
46
|
+
|
|
47
|
+
It has a table of contents — go directly to the relevant module section.
|
|
48
|
+
|
|
49
|
+
For trading interfaces, detailed reference docs with full parameter descriptions, use cases, and examples are in:
|
|
50
|
+
`~/.claude/skills/bitget-skill/references/trading/`
|
|
51
|
+
|
|
52
|
+
| File | Covers |
|
|
53
|
+
|------|--------|
|
|
54
|
+
| `trading/spot-place-order.md` | Spot limit/market/batch orders, TP/SL presets |
|
|
55
|
+
| `trading/spot-cancel-orders.md` | Cancel single, batch, or all spot orders |
|
|
56
|
+
| `trading/spot-modify-order.md` | Modify (cancel-and-replace) a spot order |
|
|
57
|
+
| `trading/spot-get-orders.md` | Query open/history spot orders |
|
|
58
|
+
| `trading/spot-plan-orders.md` | Spot trigger/plan orders (stop-loss, breakout) |
|
|
59
|
+
| `trading/futures-place-order.md` | Futures orders, one-way/hedge mode, TP/SL |
|
|
60
|
+
| `trading/futures-modify-order.md` | Modify pending futures order: adjust TP/SL, price, size |
|
|
61
|
+
| `trading/futures-cancel-orders.md` | Cancel futures orders |
|
|
62
|
+
| `trading/futures-get-orders.md` | Query futures orders and fills |
|
|
63
|
+
| `trading/futures-positions.md` | Current/history positions, PnL, liquidation price |
|
|
64
|
+
| `trading/futures-leverage-config.md` | Set leverage, margin mode, position mode |
|
|
65
|
+
|
|
66
|
+
**Always read the relevant trading reference before constructing a trading command.**
|
|
67
|
+
|
|
68
|
+
## Futures: Close Position & TP/SL Quick Rules
|
|
69
|
+
|
|
70
|
+
Before placing ANY futures close or TP/SL order, check the position first:
|
|
71
|
+
```bash
|
|
72
|
+
bgc futures futures_get_positions --productType USDT-FUTURES --symbol BTCUSDT
|
|
73
|
+
```
|
|
74
|
+
Note: `holdSide` (long/short) and `posMode` (one_way_mode/hedge_mode).
|
|
75
|
+
|
|
76
|
+
### Close direction rules (most common mistake)
|
|
77
|
+
| Position | `side` to close | Extra param |
|
|
78
|
+
|----------|----------------|-------------|
|
|
79
|
+
| Long (one-way mode) | `sell` | `reduceOnly: "YES"` |
|
|
80
|
+
| Short (one-way mode) | `buy` | `reduceOnly: "YES"` |
|
|
81
|
+
| Long (hedge mode) | `sell` | `tradeSide: "close"` |
|
|
82
|
+
| Short (hedge mode) | `buy` | `tradeSide: "close"` |
|
|
83
|
+
|
|
84
|
+
> **Selling to close a short is WRONG — it opens more short.**
|
|
85
|
+
|
|
86
|
+
### TP/SL options
|
|
87
|
+
1. **Preset at entry**: `presetStopSurplusPrice` / `presetStopLossPrice` on the opening order
|
|
88
|
+
2. **Add/modify after entry**: `futures_modify_order` with `newPresetStopSurplusPrice` / `newPresetStopLossPrice` — does NOT cancel the order; pass `"0"` to delete a preset
|
|
89
|
+
3. **Manual limit + reduceOnly**: place a separate limit close order at target price (use as fallback)
|
|
90
|
+
|
|
91
|
+
Read `trading/futures-modify-order.md` before using `futures_modify_order`.
|
|
92
|
+
|
|
93
|
+
## Module quick-reference
|
|
94
|
+
|
|
95
|
+
| Module | Use for |
|
|
96
|
+
|--------|---------|
|
|
97
|
+
| `spot` | Spot prices, orderbook, candles, spot orders |
|
|
98
|
+
| `futures` | Perpetuals prices, positions, futures orders, leverage |
|
|
99
|
+
| `account` | Balances, deposits, withdrawals, transfers, subaccounts |
|
|
100
|
+
| `margin` | Margin assets, borrow/repay, margin orders |
|
|
101
|
+
| `copytrading` | Follow traders, copy positions. **Note:** Copy positions are separate from regular futures — use `copy_get_positions` and `copy_close_position`, NOT `futures_place_order`, to manage them |
|
|
102
|
+
| `convert` | Convert one coin to another. **Two-step flow required:** call `convert_get_quote` first (returns a quote ID + rate, valid ~10s), then `convert_execute`. Always show the quoted rate to user before executing |
|
|
103
|
+
| `earn` | Savings/staking products, subscribe/redeem |
|
|
104
|
+
| `p2p` | P2P merchants and orders |
|
|
105
|
+
| `broker` | Broker subaccounts and API keys |
|
|
106
|
+
|
|
107
|
+
## Write operations: always confirm first
|
|
108
|
+
|
|
109
|
+
Before running any command marked **Write operation: Yes**, summarize what it will do
|
|
110
|
+
and ask the user to confirm. This includes: placing orders, cancelling orders, transfers,
|
|
111
|
+
withdrawals, setting leverage, borrowing, redeeming earn products.
|
|
112
|
+
|
|
113
|
+
Example confirmation:
|
|
114
|
+
> "This will place a limit buy order for 0.01 BTC at $70,000 on BTCUSDT. Confirm?"
|
|
115
|
+
|
|
116
|
+
Never silently execute a write operation.
|
|
117
|
+
|
|
118
|
+
**Withdrawal safety:** Always show the chain name and destination address in the confirmation prompt. Wrong chain selection is irreversible — if the user hasn't specified a chain, list available chains and ask them to confirm before proceeding.
|
|
119
|
+
|
|
120
|
+
**Market buy size:** For spot market buys, `size` is in quote coin (USDT), not base coin. Confirm the user's intent before constructing market buy orders to avoid near-zero silent executes.
|
|
121
|
+
|
|
122
|
+
## Handling errors
|
|
123
|
+
|
|
124
|
+
If `bgc` returns `"ok": false`, read `error.suggestion` for the recovery action.
|
|
125
|
+
Common fixes: `~/.claude/skills/bitget-skill/references/error-codes.md`
|
|
126
|
+
|
|
127
|
+
When credentials are missing (`AUTH_MISSING`), show the user exactly which env vars to set.
|
|
128
|
+
|
|
129
|
+
## Output presentation
|
|
130
|
+
|
|
131
|
+
- For prices/tickers: show symbol, last price, 24h change, volume in a readable summary
|
|
132
|
+
- For order lists: table format with orderId, symbol, side, price, size, status
|
|
133
|
+
- For balances: list coins with available and frozen amounts; skip dust balances (< 0.0001)
|
|
134
|
+
- For futures positions: always show symbol, side (long/short), size, entry price, mark price, unrealized PnL, **liquidation price**, and leverage. Never omit liquidation price
|
|
135
|
+
- For funding rates: show current rate, annualized rate, and next settlement time
|
|
136
|
+
- For raw data the user didn't ask to see: summarize, don't dump the full JSON
|
|
137
|
+
|
|
138
|
+
## Usage examples
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Public market data (no credentials needed)
|
|
142
|
+
bgc spot spot_get_ticker --symbol BTCUSDT
|
|
143
|
+
bgc futures futures_get_ticker --productType USDT-FUTURES --symbol BTCUSDT
|
|
144
|
+
bgc futures futures_get_funding_rate --productType USDT-FUTURES --symbol BTCUSDT
|
|
145
|
+
|
|
146
|
+
# Account queries (requires credentials)
|
|
147
|
+
bgc account get_account_assets
|
|
148
|
+
bgc spot spot_get_orders --status open
|
|
149
|
+
bgc futures futures_get_positions --productType USDT-FUTURES
|
|
150
|
+
|
|
151
|
+
# Write operations (confirm before running)
|
|
152
|
+
bgc spot spot_place_order --orders '[{"symbol":"BTCUSDT","side":"buy","orderType":"limit","price":"70000","size":"0.01"}]'
|
|
153
|
+
bgc futures futures_set_leverage --productType USDT-FUTURES --symbol BTCUSDT --marginCoin USDT --leverage 10
|
|
154
|
+
bgc account transfer --fromAccountType spot --toAccountType futures_usdt --coin USDT --amount 100
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Demo Trading Mode
|
|
158
|
+
|
|
159
|
+
Use demo mode when the user wants to practice trading, test strategies, or explicitly asks for "demo", "paper trading", or "simulated trading".
|
|
160
|
+
|
|
161
|
+
**Setup:** The user needs a Bitget Demo API Key. See `~/.claude/skills/bitget-skill/references/demo-trading.md` for full setup steps.
|
|
162
|
+
|
|
163
|
+
**For bgc CLI:** Add `--paper-trading` as the FIRST flag after `bgc`:
|
|
164
|
+
```bash
|
|
165
|
+
bgc --paper-trading spot spot_get_ticker --symbol BTCUSDT
|
|
166
|
+
bgc --paper-trading futures futures_get_positions --productType USDT-FUTURES
|
|
167
|
+
bgc --paper-trading account get_account_assets
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**For MCP tools:** The MCP server must be started with `--paper-trading`. If the user is asking to use demo mode via MCP but the server wasn't started with that flag, inform them they need to restart with `--paper-trading`.
|
|
171
|
+
|
|
172
|
+
**Key rule:** In demo mode, add `--paper-trading` to EVERY bgc command in the session. Never mix demo and live commands in the same session.
|