@aicoin/aicoin-mcp 1.1.0 → 1.1.1
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/build/index.js +14 -5
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -514,10 +514,13 @@ function registerTradeTools(server2) {
|
|
|
514
514
|
const ex = getExchange(exchange, market_type);
|
|
515
515
|
const bal = await ex.fetchBalance();
|
|
516
516
|
const summary = {};
|
|
517
|
+
const stablecoins = ["USDT", "USDC", "BUSD", "DAI", "TUSD", "FDUSD"];
|
|
517
518
|
for (const [ccy, amt] of Object.entries(bal.total || {})) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
519
|
+
const total = Number(amt);
|
|
520
|
+
if (total <= 0) continue;
|
|
521
|
+
if (stablecoins.includes(ccy) && total < 0.01) continue;
|
|
522
|
+
if (!stablecoins.includes(ccy) && total < 1e-7) continue;
|
|
523
|
+
summary[ccy] = { free: bal.free?.[ccy], used: bal.used?.[ccy], total: bal.total?.[ccy] };
|
|
521
524
|
}
|
|
522
525
|
if (exchange?.toLowerCase() === "okx") {
|
|
523
526
|
summary._note = "OKX\u7EDF\u4E00\u8D26\u6237\uFF1A\u73B0\u8D27\u548C\u5408\u7EA6\u5171\u7528\u540C\u4E00\u4F59\u989D\uFF0C\u65E0\u9700\u5212\u8F6C\u3002";
|
|
@@ -597,7 +600,7 @@ function registerTradeTools(server2) {
|
|
|
597
600
|
);
|
|
598
601
|
server2.tool(
|
|
599
602
|
"create_order",
|
|
600
|
-
"Place a new order (market or limit)",
|
|
603
|
+
"Place a new order (market or limit). For conditional SL/TP orders, use stop_loss_price or take_profit_price with type=market.",
|
|
601
604
|
{
|
|
602
605
|
exchange: z2.string().describe("Exchange ID"),
|
|
603
606
|
symbol: z2.string().describe("Trading pair, e.g. BTC/USDT"),
|
|
@@ -607,9 +610,12 @@ function registerTradeTools(server2) {
|
|
|
607
610
|
price: z2.number().positive().optional().describe("Limit price (required for limit orders)"),
|
|
608
611
|
pos_side: z2.enum(["long", "short"]).optional().describe("Position side for hedge mode: long/short"),
|
|
609
612
|
margin_mode: z2.enum(["cross", "isolated"]).optional().describe("Margin mode for derivatives: cross/isolated"),
|
|
613
|
+
stop_loss_price: z2.number().positive().optional().describe("Stop-loss trigger price (creates conditional market order)"),
|
|
614
|
+
take_profit_price: z2.number().positive().optional().describe("Take-profit trigger price (creates conditional market order)"),
|
|
615
|
+
reduce_only: z2.boolean().optional().describe("Reduce-only flag for closing positions (SL/TP orders)"),
|
|
610
616
|
market_type: marketTypePrivateSchema
|
|
611
617
|
},
|
|
612
|
-
async ({ exchange, symbol, type, side, amount, price, pos_side, margin_mode, market_type }) => {
|
|
618
|
+
async ({ exchange, symbol, type, side, amount, price, pos_side, margin_mode, stop_loss_price, take_profit_price, reduce_only, market_type }) => {
|
|
613
619
|
try {
|
|
614
620
|
if (type === "limit" && price == null) {
|
|
615
621
|
return err("price is required for limit orders");
|
|
@@ -629,6 +635,9 @@ function registerTradeTools(server2) {
|
|
|
629
635
|
params.tdMode = margin_mode;
|
|
630
636
|
}
|
|
631
637
|
}
|
|
638
|
+
if (stop_loss_price) params.stopLossPrice = stop_loss_price;
|
|
639
|
+
if (take_profit_price) params.takeProfitPrice = take_profit_price;
|
|
640
|
+
if (reduce_only) params.reduceOnly = true;
|
|
632
641
|
const order = await ex.createOrder(symbol, type, side, amount, price, params);
|
|
633
642
|
if (market_type && market_type !== "spot") {
|
|
634
643
|
try {
|