@pionex/pionex-ai-kit 0.2.36 → 0.2.38
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/dist/index.js +27 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { createInterface } from "readline";
|
|
5
5
|
import { basename } from "path";
|
|
6
|
+
import { createRequire } from "module";
|
|
6
7
|
|
|
7
8
|
// ../core/dist/index.js
|
|
8
9
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
@@ -1522,7 +1523,7 @@ function registerOrdersTools() {
|
|
|
1522
1523
|
},
|
|
1523
1524
|
async handler(args, { client, config }) {
|
|
1524
1525
|
if (config.readOnly) {
|
|
1525
|
-
throw new Error("Server is running in --read-only mode;
|
|
1526
|
+
throw new Error("Server is running in --read-only mode; cancel_all is disabled.");
|
|
1526
1527
|
}
|
|
1527
1528
|
const symbol = String(args.symbol);
|
|
1528
1529
|
return (await client.signedDelete("/api/v1/trade/allOrders", { symbol })).data;
|
|
@@ -2373,6 +2374,8 @@ function createToolRunner(client, config) {
|
|
|
2373
2374
|
}
|
|
2374
2375
|
|
|
2375
2376
|
// src/index.ts
|
|
2377
|
+
var _require = createRequire(import.meta.url);
|
|
2378
|
+
var { version } = _require("../package.json");
|
|
2376
2379
|
var DEFAULT_PROFILE_NAME = "pionx-prod";
|
|
2377
2380
|
var DEFAULT_BASE_URL = "https://api.pionex.com";
|
|
2378
2381
|
function ask(rl, question, defaultValue = "") {
|
|
@@ -2381,7 +2384,9 @@ function ask(rl, question, defaultValue = "") {
|
|
|
2381
2384
|
}
|
|
2382
2385
|
async function cmdOnboard() {
|
|
2383
2386
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
2384
|
-
process.stdout.write(
|
|
2387
|
+
process.stdout.write(`
|
|
2388
|
+
pionex-ai-kit v${version}
|
|
2389
|
+
`);
|
|
2385
2390
|
process.stdout.write(" \u26A0\uFE0F Security Tips: NEVER send API keys in agent chat. Create a dedicated API Key for your agent. Please test thoroughly before connecting to large real-money accounts.\n");
|
|
2386
2391
|
process.stdout.write(" \u26A0\uFE0F \u5B89\u5168\u63D0\u793A\uFF1A\u5207\u52FF\u5728 Agent \u5BF9\u8BDD\u4E2D\u53D1\u9001 API Key\u3002\u8BF7\u4E3A Agent \u521B\u5EFA\u4E13\u7528API Key\u63A5\u5165\uFF0C\u5148\u7528\u5C0F\u91D1\u989D\u5145\u5206\u9A8C\u8BC1\u540E\u518D\u63A5\u5165\u5B9E\u76D8\u3002\n\n");
|
|
2387
2392
|
process.stdout.write("Pionex CLI \u2014 Configuration Wizard\n\n");
|
|
@@ -2580,6 +2585,11 @@ function parseJsonFlag(raw, flagName) {
|
|
|
2580
2585
|
}
|
|
2581
2586
|
}
|
|
2582
2587
|
async function runPionexCommand(argv) {
|
|
2588
|
+
const firstArg = argv[0];
|
|
2589
|
+
if (firstArg === "-v" || firstArg === "--version") {
|
|
2590
|
+
process.stdout.write(version + "\n");
|
|
2591
|
+
return;
|
|
2592
|
+
}
|
|
2583
2593
|
const { positionals, flags } = parseFlags(argv);
|
|
2584
2594
|
const group = positionals[0];
|
|
2585
2595
|
const command = group === "bot" || group === "earn" ? positionals[2] : positionals[1];
|
|
@@ -2727,7 +2737,7 @@ async function runPionexCommand(argv) {
|
|
|
2727
2737
|
process.stdout.write(JSON.stringify(out.data, null, 2) + "\n");
|
|
2728
2738
|
return;
|
|
2729
2739
|
}
|
|
2730
|
-
if (command === "
|
|
2740
|
+
if (command === "cancel_all") {
|
|
2731
2741
|
const symbol = typeof flags.symbol === "string" ? flags.symbol : void 0;
|
|
2732
2742
|
if (!symbol) throw new Error("Missing required flag: --symbol");
|
|
2733
2743
|
const payload = { symbol };
|
|
@@ -2825,7 +2835,7 @@ async function runPionexCommand(argv) {
|
|
|
2825
2835
|
if (!earnRoute || earnRoute !== "dual") {
|
|
2826
2836
|
throw new Error(
|
|
2827
2837
|
`Missing or unknown earn route: ${earnRoute ?? "(none)"}. Use: pionex-trade-cli earn dual <command>
|
|
2828
|
-
Commands: symbols,
|
|
2838
|
+
Commands: symbols, open_products, prices, index, delivery_prices, balances, get_invests, records, invest, revoke_invest, collect`
|
|
2829
2839
|
);
|
|
2830
2840
|
}
|
|
2831
2841
|
if (!command || command === "help" || flags.help === true || flags.h === true) {
|
|
@@ -2834,22 +2844,22 @@ Usage: pionex-trade-cli earn dual <command> [--flags]
|
|
|
2834
2844
|
|
|
2835
2845
|
Public commands (no API key required):
|
|
2836
2846
|
symbols List supported trading pairs [--base BTC]
|
|
2837
|
-
|
|
2847
|
+
open_products List open products --base BTC --quote USDXO --type DUAL_BASE|DUAL_CURRENCY [--currency USDT]
|
|
2838
2848
|
(BTC/ETH: --quote USDXO; others: --quote USDT)
|
|
2839
2849
|
Product ID format: {BASE}-{QUOTE}-{YYMMDD}-{STRIKE}-{C|P}-{CURRENCY} (C=DUAL_BASE, P=DUAL_CURRENCY)
|
|
2840
2850
|
prices Get yield rates --base BTC --quote USDXO --product-ids id1,id2
|
|
2841
2851
|
(All three flags required. Always call before invest \u2014 profit value must be passed unchanged.)
|
|
2842
2852
|
index Get index price --base BTC --quote USDXO
|
|
2843
|
-
|
|
2853
|
+
delivery_prices Get delivery prices --base BTC [--quote USDXO] [--start-time ms] [--end-time ms]
|
|
2844
2854
|
|
|
2845
|
-
Auth commands (
|
|
2855
|
+
Auth commands (Enable reading permission):
|
|
2846
2856
|
balances Get Dual Investment balances [--merge]
|
|
2847
2857
|
records Get investment history --base BTC --end-time ms [--quote USDT] [--limit 20] [--start-time ms]
|
|
2848
|
-
|
|
2858
|
+
get_invests Batch query orders [--base BTC] --client-dual-ids id1,id2
|
|
2849
2859
|
|
|
2850
2860
|
Auth commands (Earn permission, write):
|
|
2851
2861
|
invest Create investment --base BTC --product-id <id> (--base-amount N | --currency-amount N) --profit N [--client-dual-id id] [--dry-run]
|
|
2852
|
-
|
|
2862
|
+
revoke_invest Revoke pending order --base BTC --product-id <id> --client-dual-id <id> [--dry-run]
|
|
2853
2863
|
collect Collect settled earnings --base BTC --client-dual-id <id> --product-id <id> [--dry-run]
|
|
2854
2864
|
|
|
2855
2865
|
Note: For BTC/ETH: --quote USDXO --currency USDT|USDC. For other bases: --quote USDT --currency USDT.
|
|
@@ -2862,7 +2872,7 @@ Note: For BTC/ETH: --quote USDXO --currency USDT|USDC. For other bases: --quote
|
|
|
2862
2872
|
process.stdout.write(JSON.stringify(out.data, null, 2) + "\n");
|
|
2863
2873
|
return;
|
|
2864
2874
|
}
|
|
2865
|
-
if (command === "
|
|
2875
|
+
if (command === "open_products" || command === "openProducts") {
|
|
2866
2876
|
const base = typeof flags.base === "string" ? flags.base : void 0;
|
|
2867
2877
|
const quote = typeof flags.quote === "string" ? flags.quote : void 0;
|
|
2868
2878
|
const type = typeof flags.type === "string" ? flags.type : void 0;
|
|
@@ -2890,7 +2900,7 @@ Note: For BTC/ETH: --quote USDXO --currency USDT|USDC. For other bases: --quote
|
|
|
2890
2900
|
process.stdout.write(JSON.stringify(out.data, null, 2) + "\n");
|
|
2891
2901
|
return;
|
|
2892
2902
|
}
|
|
2893
|
-
if (command === "
|
|
2903
|
+
if (command === "delivery_prices" || command === "deliveryPrices") {
|
|
2894
2904
|
const base = typeof flags.base === "string" ? flags.base : void 0;
|
|
2895
2905
|
if (!base) throw new Error("Missing required flag: --base");
|
|
2896
2906
|
const quote = typeof flags.quote === "string" ? flags.quote : void 0;
|
|
@@ -2906,7 +2916,7 @@ Note: For BTC/ETH: --quote USDXO --currency USDT|USDC. For other bases: --quote
|
|
|
2906
2916
|
process.stdout.write(JSON.stringify(out.data, null, 2) + "\n");
|
|
2907
2917
|
return;
|
|
2908
2918
|
}
|
|
2909
|
-
if (command === "
|
|
2919
|
+
if (command === "get_invests" || command === "getInvests") {
|
|
2910
2920
|
const base = typeof flags.base === "string" ? flags.base : void 0;
|
|
2911
2921
|
const clientDualIdsRaw = typeof flags["client-dual-ids"] === "string" ? flags["client-dual-ids"] : typeof flags.clientDualIds === "string" ? flags.clientDualIds : void 0;
|
|
2912
2922
|
const clientDualIds = clientDualIdsRaw ? clientDualIdsRaw.split(",").map((s) => s.trim()) : void 0;
|
|
@@ -2944,7 +2954,7 @@ Note: For BTC/ETH: --quote USDXO --currency USDT|USDC. For other bases: --quote
|
|
|
2944
2954
|
process.stdout.write(JSON.stringify(out.data, null, 2) + "\n");
|
|
2945
2955
|
return;
|
|
2946
2956
|
}
|
|
2947
|
-
if (command === "
|
|
2957
|
+
if (command === "revoke_invest" || command === "revokeInvest") {
|
|
2948
2958
|
const base = typeof flags.base === "string" ? flags.base : void 0;
|
|
2949
2959
|
const clientDualId = typeof flags["client-dual-id"] === "string" ? flags["client-dual-id"] : typeof flags.clientDualId === "string" ? flags.clientDualId : void 0;
|
|
2950
2960
|
const productId = typeof flags["product-id"] === "string" ? flags["product-id"] : typeof flags.productId === "string" ? flags.productId : void 0;
|
|
@@ -2980,6 +2990,10 @@ function main() {
|
|
|
2980
2990
|
const invokedAs = basename(process.argv[1] || "");
|
|
2981
2991
|
const cmd = process.argv[2];
|
|
2982
2992
|
if (invokedAs.includes("pionex-ai-kit")) {
|
|
2993
|
+
if (cmd === "-v" || cmd === "--version") {
|
|
2994
|
+
process.stdout.write(version + "\n");
|
|
2995
|
+
return;
|
|
2996
|
+
}
|
|
2983
2997
|
if (cmd === "onboard") {
|
|
2984
2998
|
cmdOnboard().catch((e) => {
|
|
2985
2999
|
process.stderr.write(String(e) + "\n");
|