polycopy 0.2.4 → 0.2.5
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 +24 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -746,13 +746,11 @@ class ClobClientWrapper {
|
|
|
746
746
|
clobClient.OrderType.GTC
|
|
747
747
|
);
|
|
748
748
|
if (response.success) {
|
|
749
|
-
logger.success(`买单已提交: ${response.orderID}`);
|
|
750
749
|
return {
|
|
751
750
|
success: true,
|
|
752
751
|
orderId: response.orderID
|
|
753
752
|
};
|
|
754
753
|
} else {
|
|
755
|
-
logger.error(`买单提交失败: ${response.errorMsg}`);
|
|
756
754
|
return {
|
|
757
755
|
success: false,
|
|
758
756
|
orderId: "",
|
|
@@ -761,7 +759,6 @@ class ClobClientWrapper {
|
|
|
761
759
|
}
|
|
762
760
|
} catch (error) {
|
|
763
761
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
764
|
-
logger.error(`买单提交失败: ${errorMsg}`);
|
|
765
762
|
return {
|
|
766
763
|
success: false,
|
|
767
764
|
orderId: "",
|
|
@@ -823,12 +820,17 @@ class ClobClientWrapper {
|
|
|
823
820
|
const client = this.ensureInitialized();
|
|
824
821
|
try {
|
|
825
822
|
await client.cancelOrder({ orderID: orderId });
|
|
826
|
-
|
|
827
|
-
|
|
823
|
+
return {
|
|
824
|
+
success: true,
|
|
825
|
+
orderId
|
|
826
|
+
};
|
|
828
827
|
} catch (error) {
|
|
829
828
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
830
|
-
|
|
831
|
-
|
|
829
|
+
return {
|
|
830
|
+
success: false,
|
|
831
|
+
orderId,
|
|
832
|
+
errorMsg
|
|
833
|
+
};
|
|
832
834
|
}
|
|
833
835
|
}
|
|
834
836
|
/**
|
|
@@ -1249,33 +1251,33 @@ class Redeemer {
|
|
|
1249
1251
|
if (messages.length > 0) {
|
|
1250
1252
|
telegramService.info(messages.join("\n"));
|
|
1251
1253
|
}
|
|
1252
|
-
const logLines = [
|
|
1254
|
+
const logLines = [];
|
|
1253
1255
|
if (execRedeems.length > 0) {
|
|
1254
1256
|
logLines.push(
|
|
1255
1257
|
`redeem 本轮执行(待确认): ${execRedeems.length} 个`,
|
|
1256
1258
|
...this.toMessages(execRedeems),
|
|
1257
|
-
"
|
|
1259
|
+
""
|
|
1258
1260
|
);
|
|
1259
1261
|
}
|
|
1260
1262
|
if (pendingRedeems.length > 0) {
|
|
1261
1263
|
logLines.push(
|
|
1262
1264
|
`redeem 本轮未执行(等待下轮): ${pendingRedeems.length} 个`,
|
|
1263
1265
|
...this.toMessages(pendingRedeems),
|
|
1264
|
-
"
|
|
1266
|
+
""
|
|
1265
1267
|
);
|
|
1266
1268
|
}
|
|
1267
1269
|
if (successRedeem.length > 0) {
|
|
1268
1270
|
logLines.push(
|
|
1269
1271
|
`🟢 redeem 成功确认: ${successRedeem.length} 个`,
|
|
1270
1272
|
...this.toMessages(successRedeem),
|
|
1271
|
-
"
|
|
1273
|
+
""
|
|
1272
1274
|
);
|
|
1273
1275
|
}
|
|
1274
1276
|
if (failedRedeems.length > 0) {
|
|
1275
1277
|
logLines.push(
|
|
1276
1278
|
`🔴 redeem 失败已放弃(重试超限): ${failedRedeems.length} 个`,
|
|
1277
1279
|
...this.toMessages(failedRedeems),
|
|
1278
|
-
"
|
|
1280
|
+
""
|
|
1279
1281
|
);
|
|
1280
1282
|
}
|
|
1281
1283
|
logLines.push(`redeem 待确认总数: ${this.records.size} 个`);
|
|
@@ -1412,8 +1414,10 @@ class Trader {
|
|
|
1412
1414
|
logger.info(`下单价格: ${buyPrice}`);
|
|
1413
1415
|
logger.info(`下单数量: ${size.toFixed(4)}`);
|
|
1414
1416
|
const buyResult = await this.client.createBuyOrder(assetId, buyPrice, size);
|
|
1415
|
-
if (
|
|
1416
|
-
logger.
|
|
1417
|
+
if (buyResult.success) {
|
|
1418
|
+
logger.success(`买单已提交: ${buyResult.orderId}`);
|
|
1419
|
+
} else {
|
|
1420
|
+
logger.error(`买单提交失败: ${buyResult.errorMsg}`);
|
|
1417
1421
|
telegramService.error(
|
|
1418
1422
|
"买单失败",
|
|
1419
1423
|
`事件: ${metadata.eventId}
|
|
@@ -1486,7 +1490,12 @@ class Trader {
|
|
|
1486
1490
|
break;
|
|
1487
1491
|
case "TIMEOUT":
|
|
1488
1492
|
logger.warning("订单超时,尝试取消");
|
|
1489
|
-
await this.client.cancelOrder(orderId);
|
|
1493
|
+
const cancelResult = await this.client.cancelOrder(orderId);
|
|
1494
|
+
if (cancelResult.success) {
|
|
1495
|
+
logger.info(`订单已取消: ${orderId}`);
|
|
1496
|
+
} else {
|
|
1497
|
+
logger.error(`取消订单失败: ${cancelResult.errorMsg}`);
|
|
1498
|
+
}
|
|
1490
1499
|
break;
|
|
1491
1500
|
}
|
|
1492
1501
|
}
|