@yuants/vendor-aster 0.7.7 → 0.7.8

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.
Files changed (91) hide show
  1. package/dist/api/private-api.js +2 -3
  2. package/dist/api/private-api.js.map +1 -1
  3. package/dist/index.js +1 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/services/accounts/perp.js +1 -1
  6. package/dist/services/accounts/perp.js.map +1 -1
  7. package/dist/services/accounts/profile.js +10 -0
  8. package/dist/services/accounts/profile.js.map +1 -0
  9. package/dist/services/accounts/spot.js +21 -5
  10. package/dist/services/accounts/spot.js.map +1 -1
  11. package/dist/services/exchange.js +63 -0
  12. package/dist/services/exchange.js.map +1 -0
  13. package/dist/services/markets/interest_rate.js +1 -1
  14. package/dist/services/markets/interest_rate.js.map +1 -1
  15. package/dist/services/markets/product.js +5 -4
  16. package/dist/services/markets/product.js.map +1 -1
  17. package/dist/services/markets/quote.js +1 -1
  18. package/dist/services/markets/quote.js.map +1 -1
  19. package/dist/services/orders/cancelOrder.js +4 -7
  20. package/dist/services/orders/cancelOrder.js.map +1 -1
  21. package/dist/services/orders/listOrders.js +21 -12
  22. package/dist/services/orders/listOrders.js.map +1 -1
  23. package/dist/services/orders/submitOrder.js +3 -6
  24. package/dist/services/orders/submitOrder.js.map +1 -1
  25. package/lib/api/private-api.d.ts.map +1 -1
  26. package/lib/api/private-api.js +1 -2
  27. package/lib/api/private-api.js.map +1 -1
  28. package/lib/index.d.ts +1 -3
  29. package/lib/index.d.ts.map +1 -1
  30. package/lib/index.js +1 -3
  31. package/lib/index.js.map +1 -1
  32. package/lib/services/accounts/perp.d.ts +2 -2
  33. package/lib/services/accounts/perp.d.ts.map +1 -1
  34. package/lib/services/accounts/perp.js +1 -1
  35. package/lib/services/accounts/perp.js.map +1 -1
  36. package/lib/services/accounts/profile.d.ts +3 -0
  37. package/lib/services/accounts/profile.d.ts.map +1 -0
  38. package/lib/services/accounts/profile.js +14 -0
  39. package/lib/services/accounts/profile.js.map +1 -0
  40. package/lib/services/accounts/spot.d.ts +2 -2
  41. package/lib/services/accounts/spot.d.ts.map +1 -1
  42. package/lib/services/accounts/spot.js +20 -4
  43. package/lib/services/accounts/spot.js.map +1 -1
  44. package/lib/services/exchange.d.ts +2 -0
  45. package/lib/services/exchange.d.ts.map +1 -0
  46. package/lib/services/exchange.js +65 -0
  47. package/lib/services/exchange.js.map +1 -0
  48. package/lib/services/markets/interest_rate.js +1 -1
  49. package/lib/services/markets/interest_rate.js.map +1 -1
  50. package/lib/services/markets/product.d.ts +2 -0
  51. package/lib/services/markets/product.d.ts.map +1 -1
  52. package/lib/services/markets/product.js +7 -5
  53. package/lib/services/markets/product.js.map +1 -1
  54. package/lib/services/markets/quote.js +1 -1
  55. package/lib/services/markets/quote.js.map +1 -1
  56. package/lib/services/orders/cancelOrder.d.ts.map +1 -1
  57. package/lib/services/orders/cancelOrder.js +4 -7
  58. package/lib/services/orders/cancelOrder.js.map +1 -1
  59. package/lib/services/orders/listOrders.d.ts +7 -3
  60. package/lib/services/orders/listOrders.d.ts.map +1 -1
  61. package/lib/services/orders/listOrders.js +24 -11
  62. package/lib/services/orders/listOrders.js.map +1 -1
  63. package/lib/services/orders/submitOrder.d.ts.map +1 -1
  64. package/lib/services/orders/submitOrder.js +3 -6
  65. package/lib/services/orders/submitOrder.js.map +1 -1
  66. package/package.json +15 -14
  67. package/temp/package-deps.json +30 -31
  68. package/dist/services/account-actions-with-credential.js +0 -34
  69. package/dist/services/account-actions-with-credential.js.map +0 -1
  70. package/dist/services/legacy.js +0 -69
  71. package/dist/services/legacy.js.map +0 -1
  72. package/dist/services/order-actions-with-credential.js +0 -19
  73. package/dist/services/order-actions-with-credential.js.map +0 -1
  74. package/dist/utils.js +0 -9
  75. package/dist/utils.js.map +0 -1
  76. package/lib/services/account-actions-with-credential.d.ts +0 -2
  77. package/lib/services/account-actions-with-credential.d.ts.map +0 -1
  78. package/lib/services/account-actions-with-credential.js +0 -36
  79. package/lib/services/account-actions-with-credential.js.map +0 -1
  80. package/lib/services/legacy.d.ts +0 -2
  81. package/lib/services/legacy.d.ts.map +0 -1
  82. package/lib/services/legacy.js +0 -71
  83. package/lib/services/legacy.js.map +0 -1
  84. package/lib/services/order-actions-with-credential.d.ts +0 -2
  85. package/lib/services/order-actions-with-credential.d.ts.map +0 -1
  86. package/lib/services/order-actions-with-credential.js +0 -21
  87. package/lib/services/order-actions-with-credential.js.map +0 -1
  88. package/lib/utils.d.ts +0 -2
  89. package/lib/utils.d.ts.map +0 -1
  90. package/lib/utils.js +0 -13
  91. package/lib/utils.js.map +0 -1
@@ -14,26 +14,23 @@ const parseProductId = (productId) => {
14
14
  return { category: undefined, symbol: parts[0] };
15
15
  };
16
16
  const handleCancelOrder = async (credential, order) => {
17
- var _a, _b;
18
17
  if (!order.order_id) {
19
18
  throw new Error('order_id is required for CancelOrder');
20
19
  }
21
- const { category, symbol } = parseProductId(order.product_id);
20
+ const [_, instType, symbol] = (0, utils_1.decodePath)(order.product_id); // BITGET/USDT-FUTURES/BTCUSDT
22
21
  if (!symbol) {
23
22
  throw new Error('product_id is required to resolve symbol for CancelOrder');
24
23
  }
25
- const accountId = (_b = (_a = order.account_id) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : order.account_id;
26
- const productType = category === null || category === void 0 ? void 0 : category.toUpperCase();
27
- if ((accountId === null || accountId === void 0 ? void 0 : accountId.includes('/SPOT')) || productType === 'SPOT') {
24
+ if (instType === 'SPOT') {
28
25
  await (0, private_api_1.deleteApiV1Order)(credential, {
29
26
  symbol,
30
27
  orderId: order.order_id,
31
28
  });
32
29
  return;
33
30
  }
34
- if ((accountId === null || accountId === void 0 ? void 0 : accountId.includes('/PERP')) || productType === 'PERPETUAL') {
31
+ if (instType === 'PERP') {
35
32
  await (0, private_api_1.deleteFApiV1Order)(credential, {
36
- symbol,
33
+ symbol: (0, utils_1.decodePath)(order.product_id).slice(2).join('/'),
37
34
  orderId: order.order_id,
38
35
  });
39
36
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"cancelOrder.js","sourceRoot":"","sources":["../../../src/services/orders/cancelOrder.ts"],"names":[],"mappings":";;;AACA,yCAA2C;AAC3C,uDAAyF;AAEzF,MAAM,cAAc,GAAG,CAAC,SAAkB,EAAE,EAAE;IAC5C,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,EAAE,QAAQ,EAAE,SAA+B,EAAE,MAAM,EAAE,SAA+B,EAAE,CAAC;KAC/F;IACD,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;QACrB,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;KACjE;IACD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACnD,CAAC,CAAC;AAEK,MAAM,iBAAiB,GAA6C,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;;IACrG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IAED,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9D,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;KAC7E;IAED,MAAM,SAAS,GAAG,MAAA,MAAA,KAAK,CAAC,UAAU,0CAAE,WAAW,EAAE,mCAAI,KAAK,CAAC,UAAU,CAAC;IACtE,MAAM,WAAW,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,EAAE,CAAC;IAE5C,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,OAAO,CAAC,KAAI,WAAW,KAAK,MAAM,EAAE;QAC1D,MAAM,IAAA,8BAAgB,EAAC,UAAU,EAAE;YACjC,MAAM;YACN,OAAO,EAAE,KAAK,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,OAAO;KACR;IAED,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,OAAO,CAAC,KAAI,WAAW,KAAK,WAAW,EAAE;QAC/D,MAAM,IAAA,+BAAiB,EAAC,UAAU,EAAE;YAClC,MAAM;YACN,OAAO,EAAE,KAAK,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,OAAO;KACR;IAED,MAAM,IAAI,KAAK,CAAC,mDAAmD,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;AACzF,CAAC,CAAC;AA9BW,QAAA,iBAAiB,qBA8B5B","sourcesContent":["import { IActionHandlerOfCancelOrder } from '@yuants/data-order';\nimport { decodePath } from '@yuants/utils';\nimport { deleteApiV1Order, deleteFApiV1Order, ICredential } from '../../api/private-api';\n\nconst parseProductId = (productId?: string) => {\n if (!productId) {\n return { category: undefined as string | undefined, symbol: undefined as string | undefined };\n }\n const parts = decodePath(productId);\n if (parts.length >= 2) {\n return { category: parts[0], symbol: parts.slice(1).join('/') };\n }\n return { category: undefined, symbol: parts[0] };\n};\n\nexport const handleCancelOrder: IActionHandlerOfCancelOrder<ICredential> = async (credential, order) => {\n if (!order.order_id) {\n throw new Error('order_id is required for CancelOrder');\n }\n\n const { category, symbol } = parseProductId(order.product_id);\n if (!symbol) {\n throw new Error('product_id is required to resolve symbol for CancelOrder');\n }\n\n const accountId = order.account_id?.toUpperCase() ?? order.account_id;\n const productType = category?.toUpperCase();\n\n if (accountId?.includes('/SPOT') || productType === 'SPOT') {\n await deleteApiV1Order(credential, {\n symbol,\n orderId: order.order_id,\n });\n return;\n }\n\n if (accountId?.includes('/PERP') || productType === 'PERPETUAL') {\n await deleteFApiV1Order(credential, {\n symbol,\n orderId: order.order_id,\n });\n return;\n }\n\n throw new Error(`Unsupported account_id/product for CancelOrder: ${order.account_id}`);\n};\n"]}
1
+ {"version":3,"file":"cancelOrder.js","sourceRoot":"","sources":["../../../src/services/orders/cancelOrder.ts"],"names":[],"mappings":";;;AACA,yCAA2C;AAC3C,uDAAyF;AAEzF,MAAM,cAAc,GAAG,CAAC,SAAkB,EAAE,EAAE;IAC5C,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,EAAE,QAAQ,EAAE,SAA+B,EAAE,MAAM,EAAE,SAA+B,EAAE,CAAC;KAC/F;IACD,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;QACrB,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;KACjE;IACD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACnD,CAAC,CAAC;AAEK,MAAM,iBAAiB,GAA6C,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;IACrG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IACD,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,8BAA8B;IAC1F,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;KAC7E;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,MAAM,IAAA,8BAAgB,EAAC,UAAU,EAAE;YACjC,MAAM;YACN,OAAO,EAAE,KAAK,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,OAAO;KACR;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,MAAM,IAAA,+BAAiB,EAAC,UAAU,EAAE;YAClC,MAAM,EAAE,IAAA,kBAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACvD,OAAO,EAAE,KAAK,CAAC,QAAQ;SACxB,CAAC,CAAC;QACH,OAAO;KACR;IAED,MAAM,IAAI,KAAK,CAAC,mDAAmD,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;AACzF,CAAC,CAAC;AAxBW,QAAA,iBAAiB,qBAwB5B","sourcesContent":["import { IActionHandlerOfCancelOrder } from '@yuants/data-order';\nimport { decodePath } from '@yuants/utils';\nimport { deleteApiV1Order, deleteFApiV1Order, ICredential } from '../../api/private-api';\n\nconst parseProductId = (productId?: string) => {\n if (!productId) {\n return { category: undefined as string | undefined, symbol: undefined as string | undefined };\n }\n const parts = decodePath(productId);\n if (parts.length >= 2) {\n return { category: parts[0], symbol: parts.slice(1).join('/') };\n }\n return { category: undefined, symbol: parts[0] };\n};\n\nexport const handleCancelOrder: IActionHandlerOfCancelOrder<ICredential> = async (credential, order) => {\n if (!order.order_id) {\n throw new Error('order_id is required for CancelOrder');\n }\n const [_, instType, symbol] = decodePath(order.product_id); // BITGET/USDT-FUTURES/BTCUSDT\n if (!symbol) {\n throw new Error('product_id is required to resolve symbol for CancelOrder');\n }\n if (instType === 'SPOT') {\n await deleteApiV1Order(credential, {\n symbol,\n orderId: order.order_id,\n });\n return;\n }\n if (instType === 'PERP') {\n await deleteFApiV1Order(credential, {\n symbol: decodePath(order.product_id).slice(2).join('/'),\n orderId: order.order_id,\n });\n return;\n }\n\n throw new Error(`Unsupported account_id/product for CancelOrder: ${order.account_id}`);\n};\n"]}
@@ -1,4 +1,8 @@
1
- import { IActionHandlerOfListOrders } from '@yuants/data-order';
2
- import { ICredential } from '../../api/private-api';
3
- export declare const listOrders: IActionHandlerOfListOrders<ICredential>;
1
+ import { IOrder } from '@yuants/data-order';
2
+ import { IAsterFutureOpenOrder, IAsterSpotOpenOrder, ICredential } from '../../api/private-api';
3
+ export declare const mapPerpOrder: (order: IAsterFutureOpenOrder, account_id: string) => IOrder;
4
+ export declare const mapSpotOrder: (order: IAsterSpotOpenOrder, account_id: string) => IOrder;
5
+ export declare const listOrders: (credential: ICredential) => Promise<IOrder[]>;
6
+ export declare const listSpotOrders: (credential: ICredential) => Promise<IOrder[]>;
7
+ export declare const listPrepOrders: (credential: ICredential) => Promise<IOrder[]>;
4
8
  //# sourceMappingURL=listOrders.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"listOrders.d.ts","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAU,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAKL,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAoE/B,eAAO,MAAM,UAAU,EAAE,0BAA0B,CAAC,WAAW,CAQ9D,CAAC"}
1
+ {"version":3,"file":"listOrders.d.ts","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAGL,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAwB/B,eAAO,MAAM,YAAY,UAAW,qBAAqB,cAAc,MAAM,KAAG,MAmB/E,CAAC;AAEF,eAAO,MAAM,YAAY,UAAW,mBAAmB,cAAc,MAAM,KAAG,MAmB7E,CAAC;AAEF,eAAO,MAAM,UAAU,eAAsB,WAAW,sBASvD,CAAC;AAEF,eAAO,MAAM,cAAc,eAAsB,WAAW,sBAG3D,CAAC;AAEF,eAAO,MAAM,cAAc,eAAsB,WAAW,sBAG3D,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listOrders = void 0;
3
+ exports.listPrepOrders = exports.listSpotOrders = exports.listOrders = exports.mapSpotOrder = exports.mapPerpOrder = void 0;
4
4
  const private_api_1 = require("../../api/private-api");
5
5
  const utils_1 = require("@yuants/utils");
6
6
  const resolvePerpOrderDirection = (asterOrder) => {
@@ -27,7 +27,7 @@ const mapPerpOrder = (order, account_id) => {
27
27
  return {
28
28
  order_id: `${order.orderId}`,
29
29
  account_id,
30
- product_id: (0, utils_1.encodePath)('PERPETUAL', order.symbol),
30
+ product_id: (0, utils_1.encodePath)('ASTER', 'PERP', order.symbol),
31
31
  order_type: order.type,
32
32
  order_direction: resolvePerpOrderDirection(order),
33
33
  volume: Number.isFinite(volume) ? volume : 0,
@@ -38,6 +38,7 @@ const mapPerpOrder = (order, account_id) => {
38
38
  order_status: order.status,
39
39
  };
40
40
  };
41
+ exports.mapPerpOrder = mapPerpOrder;
41
42
  const mapSpotOrder = (order, account_id) => {
42
43
  var _a, _b;
43
44
  const volume = Number(order.origQty);
@@ -47,7 +48,7 @@ const mapSpotOrder = (order, account_id) => {
47
48
  return {
48
49
  order_id: `${order.orderId}`,
49
50
  account_id,
50
- product_id: (0, utils_1.encodePath)('SPOT', order.symbol),
51
+ product_id: (0, utils_1.encodePath)('ASTER', 'SPOT', order.symbol),
51
52
  order_type: order.type,
52
53
  order_direction: resolveSpotOrderDirection(order.side),
53
54
  volume: Number.isFinite(volume) ? volume : 0,
@@ -58,14 +59,26 @@ const mapSpotOrder = (order, account_id) => {
58
59
  order_status: order.status,
59
60
  };
60
61
  };
61
- const isSpotAccount = (account_id) => account_id.endsWith('/SPOT');
62
- const listOrders = async (credential, account_id) => {
63
- if (isSpotAccount(account_id)) {
64
- const orders = await (0, private_api_1.getApiV1OpenOrders)(credential, {});
65
- return orders.map((order) => mapSpotOrder(order, account_id));
66
- }
67
- const orders = await (0, private_api_1.getFApiV1OpenOrders)(credential, {});
68
- return orders.map((order) => mapPerpOrder(order, account_id));
62
+ exports.mapSpotOrder = mapSpotOrder;
63
+ const listOrders = async (credential) => {
64
+ const [prepOrders, spotOrders] = await Promise.all([
65
+ (0, private_api_1.getFApiV1OpenOrders)(credential, {}),
66
+ (0, private_api_1.getApiV1OpenOrders)(credential, {}),
67
+ ]);
68
+ return [
69
+ ...prepOrders.map((order) => (0, exports.mapPerpOrder)(order, '')),
70
+ ...spotOrders.map((order) => (0, exports.mapSpotOrder)(order, '')),
71
+ ];
69
72
  };
70
73
  exports.listOrders = listOrders;
74
+ const listSpotOrders = async (credential) => {
75
+ const [spotOrders] = await Promise.all([(0, private_api_1.getApiV1OpenOrders)(credential, {})]);
76
+ return [...spotOrders.map((order) => (0, exports.mapSpotOrder)(order, ''))];
77
+ };
78
+ exports.listSpotOrders = listSpotOrders;
79
+ const listPrepOrders = async (credential) => {
80
+ const [prepOrders] = await Promise.all([(0, private_api_1.getFApiV1OpenOrders)(credential, {})]);
81
+ return [...prepOrders.map((order) => (0, exports.mapPerpOrder)(order, ''))];
82
+ };
83
+ exports.listPrepOrders = listPrepOrders;
71
84
  //# sourceMappingURL=listOrders.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"listOrders.js","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":";;;AACA,uDAM+B;AAC/B,yCAA2C;AAI3C,MAAM,yBAAyB,GAAG,CAAC,UAAiC,EAAkB,EAAE;IACtF,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,aAAa,CAAC;IAErE,IAAI,UAAU,CAAC,YAAY,KAAK,MAAM,EAAE;QACtC,OAAO,UAAU,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;KAC/D;IACD,IAAI,UAAU,CAAC,YAAY,KAAK,OAAO,EAAE;QACvC,O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AC,IAAI;QACzC,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QACvE,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QAC9E,YAAY,EAAE,KAAK,CAAC,MAAM;KAC3B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAEpE,MAAM,UAAU,GAA4C,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE;IAClG,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE;QAC7B,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAkB,EAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;KAC/D;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAmB,EAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC;AARW,QAAA,UAAU,cAQrB","sourcesContent":["import { IActionHandlerOfListOrders, IOrder } from '@yuants/data-order';\nimport {\n getApiV1OpenOrders,\n getFApiV1OpenOrders,\n IAsterFutureOpenOrder,\n IAsterSpotOpenOrder,\n ICredential,\n} from '../../api/private-api';\nimport { encodePath } from '@yuants/utils';\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\nconst resolvePerpOrderDirection = (asterOrder: IAsterFutureOpenOrder): OrderDirection => {\n const reduceOnly = asterOrder.reduceOnly || asterOrder.closePosition;\n\n if (asterOrder.positionSide === 'LONG') {\n return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'CLOSE_LONG';\n }\n if (asterOrder.positionSide === 'SHORT') {\n return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'OPEN_SHORT';\n }\n if (reduceOnly) {\n return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nconst resolveSpotOrderDirection = (side: 'BUY' | 'SELL'): OrderDirection => {\n return side === 'SELL' ? 'CLOSE_LONG' : 'OPEN_LONG';\n};\n\nconst mapPerpOrder = (order: IAsterFutureOpenOrder, account_id: string): IOrder => {\n const volume = Number(order.origQty);\n const tradedVolume = Number(order.executedQty);\n const price = Number(order.price);\n const avgPrice = Number(order.avgPrice);\n\n return {\n order_id: `${order.orderId}`,\n account_id,\n product_id: encodePath('PERPETUAL', order.symbol),\n order_type: order.type,\n order_direction: resolvePerpOrderDirection(order),\n volume: Number.isFinite(volume) ? volume : 0,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.updateTime,\n traded_volume: Number.isFinite(tradedVolume) ? tradedVolume : undefined,\n traded_price: Number.isFinite(avgPrice) && avgPrice > 0 ? avgPrice : undefined,\n order_status: order.status,\n };\n};\n\nconst mapSpotOrder = (order: IAsterSpotOpenOrder, account_id: string): IOrder => {\n const volume = Number(order.origQty);\n const tradedVolume = Number(order.executedQty);\n const price = Number(order.price);\n const avgPrice = Number(order.avgPrice ?? order.price);\n\n return {\n order_id: `${order.orderId}`,\n account_id,\n product_id: encodePath('SPOT', order.symbol),\n order_type: order.type,\n order_direction: resolveSpotOrderDirection(order.side),\n volume: Number.isFinite(volume) ? volume : 0,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.updateTime ?? order.time,\n traded_volume: Number.isFinite(tradedVolume) ? tradedVolume : undefined,\n traded_price: Number.isFinite(avgPrice) && avgPrice > 0 ? avgPrice : undefined,\n order_status: order.status,\n };\n};\n\nconst isSpotAccount = (account_id: string) => account_id.endsWith('/SPOT');\n\nexport const listOrders: IActionHandlerOfListOrders<ICredential> = async (credential, account_id) => {\n if (isSpotAccount(account_id)) {\n const orders = await getApiV1OpenOrders(credential, {});\n return orders.map((order) => mapSpotOrder(order, account_id));\n }\n\n const orders = await getFApiV1OpenOrders(credential, {});\n return orders.map((order) => mapPerpOrder(order, account_id));\n};\n"]}
1
+ {"version":3,"file":"listOrders.js","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":";;;AACA,uDAM+B;AAC/B,yCAA2C;AAI3C,MAAM,yBAAyB,GAAG,CAAC,UAAiC,EAAkB,EAAE;IACtF,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,aAAa,CAAC;IAErE,IAAI,UAAU,CAAC,YAAY,KAAK,MAAM,EAAE;QACtC,OAAO,UAAU,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;KAC/D;IACD,IAAI,UAAU,CAAC,YAAY,KAAK,OAAO,EAAE;QACvC,OAAO,UAAU,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;KACjE;IACD,IAAI,UAAU,EAAE;QACd,OAAO,UAAU,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;KACjE;IACD,OAAO,UAAU,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;AAChE,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,IAAoB,EAAkB,EAAE;IACzE,OAAO,IAAI,KAAK,MAAM,CAAC,CAAC,CAA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AC;AAHW,QAAA,cAAc,kBAGzB","sourcesContent":["import { IActionHandlerOfListOrders, IOrder } from '@yuants/data-order';\nimport {\n getApiV1OpenOrders,\n getFApiV1OpenOrders,\n IAsterFutureOpenOrder,\n IAsterSpotOpenOrder,\n ICredential,\n} from '../../api/private-api';\nimport { encodePath } from '@yuants/utils';\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\nconst resolvePerpOrderDirection = (asterOrder: IAsterFutureOpenOrder): OrderDirection => {\n const reduceOnly = asterOrder.reduceOnly || asterOrder.closePosition;\n\n if (asterOrder.positionSide === 'LONG') {\n return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'CLOSE_LONG';\n }\n if (asterOrder.positionSide === 'SHORT') {\n return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'OPEN_SHORT';\n }\n if (reduceOnly) {\n return asterOrder.side === 'BUY' ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return asterOrder.side === 'BUY' ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nconst resolveSpotOrderDirection = (side: 'BUY' | 'SELL'): OrderDirection => {\n return side === 'SELL' ? 'CLOSE_LONG' : 'OPEN_LONG';\n};\n\nexport const mapPerpOrder = (order: IAsterFutureOpenOrder, account_id: string): IOrder => {\n const volume = Number(order.origQty);\n const tradedVolume = Number(order.executedQty);\n const price = Number(order.price);\n const avgPrice = Number(order.avgPrice);\n\n return {\n order_id: `${order.orderId}`,\n account_id,\n product_id: encodePath('ASTER', 'PERP', order.symbol),\n order_type: order.type,\n order_direction: resolvePerpOrderDirection(order),\n volume: Number.isFinite(volume) ? volume : 0,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.updateTime,\n traded_volume: Number.isFinite(tradedVolume) ? tradedVolume : undefined,\n traded_price: Number.isFinite(avgPrice) && avgPrice > 0 ? avgPrice : undefined,\n order_status: order.status,\n };\n};\n\nexport const mapSpotOrder = (order: IAsterSpotOpenOrder, account_id: string): IOrder => {\n const volume = Number(order.origQty);\n const tradedVolume = Number(order.executedQty);\n const price = Number(order.price);\n const avgPrice = Number(order.avgPrice ?? order.price);\n\n return {\n order_id: `${order.orderId}`,\n account_id,\n product_id: encodePath('ASTER', 'SPOT', order.symbol),\n order_type: order.type,\n order_direction: resolveSpotOrderDirection(order.side),\n volume: Number.isFinite(volume) ? volume : 0,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.updateTime ?? order.time,\n traded_volume: Number.isFinite(tradedVolume) ? tradedVolume : undefined,\n traded_price: Number.isFinite(avgPrice) && avgPrice > 0 ? avgPrice : undefined,\n order_status: order.status,\n };\n};\n\nexport const listOrders = async (credential: ICredential) => {\n const [prepOrders, spotOrders] = await Promise.all([\n getFApiV1OpenOrders(credential, {}),\n getApiV1OpenOrders(credential, {}),\n ]);\n return [\n ...prepOrders.map((order) => mapPerpOrder(order, '')),\n ...spotOrders.map((order) => mapSpotOrder(order, '')),\n ];\n};\n\nexport const listSpotOrders = async (credential: ICredential) => {\n const [spotOrders] = await Promise.all([getApiV1OpenOrders(credential, {})]);\n return [...spotOrders.map((order) => mapSpotOrder(order, ''))];\n};\n\nexport const listPrepOrders = async (credential: ICredential) => {\n const [prepOrders] = await Promise.all([getFApiV1OpenOrders(credential, {})]);\n return [...prepOrders.map((order) => mapPerpOrder(order, ''))];\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"submitOrder.d.ts","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAuB,WAAW,EAAmC,MAAM,uBAAuB,CAAC;AA+G1G,eAAO,MAAM,iBAAiB,EAAE,2BAA2B,CAAC,WAAW,CAYtE,CAAC"}
1
+ {"version":3,"file":"submitOrder.d.ts","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAuB,WAAW,EAAmC,MAAM,uBAAuB,CAAC;AA+G1G,eAAO,MAAM,iBAAiB,EAAE,2BAA2B,CAAC,WAAW,CAStE,CAAC"}
@@ -89,14 +89,11 @@ const handleSubmitOrderOfPerp = async (credential, order) => {
89
89
  return { order_id: `${orderId}` };
90
90
  };
91
91
  const handleSubmitOrder = async (credential, order) => {
92
- var _a, _b;
93
- const accountId = (_b = (_a = order.account_id) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : order.account_id;
94
- const { category } = parseProductId(order.product_id);
95
- const productType = category === null || category === void 0 ? void 0 : category.toUpperCase();
96
- if ((accountId === null || accountId === void 0 ? void 0 : accountId.includes('/SPOT')) || productType === 'SPOT') {
92
+ const [_, instType] = (0, utils_1.decodePath)(order.product_id); // BITGET/USDT-FUTURES/BTCUSDT
93
+ if (instType === 'SPOT') {
97
94
  return handleSubmitOrderOfSpot(credential, order);
98
95
  }
99
- if ((accountId === null || accountId === void 0 ? void 0 : accountId.includes('/PERP')) || productType === 'PERPETUAL') {
96
+ if (instType === 'PERP') {
100
97
  return handleSubmitOrderOfPerp(credential, order);
101
98
  }
102
99
  throw new Error(`Unsupported account_id for SubmitOrder: ${order.account_id}`);
@@ -1 +1 @@
1
- {"version":3,"file":"submitOrder.js","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":";;;AACA,yCAAwD;AACxD,uDAA0G;AAE1G,MAAM,cAAc,GAAG,CAAC,SAAkB,EAAE,EAAE;IAC5C,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,EAAE,QAAQ,EAAE,SAA+B,EAAE,MAAM,EAAE,SAA+B,EAAE,CAAC;KAC/F;IACD,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;QACrB,OAAO,EAAE,QA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AAK,WAAW,EAAE;QAC/D,OAAO,uBAAuB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;KACnD;IACD,MAAM,IAAI,KAAK,CAAC,2CAA2C,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC;AAZW,QAAA,iBAAiB,qBAY5B","sourcesContent":["import { IActionHandlerOfSubmitOrder } from '@yuants/data-order';\nimport { decodePath, roundToStep } from '@yuants/utils';\nimport { getApiV1TickerPrice, ICredential, postApiV1Order, postFApiV1Order } from '../../api/private-api';\n\nconst parseProductId = (productId?: string) => {\n if (!productId) {\n return { category: undefined as string | undefined, symbol: undefined as string | undefined };\n }\n const parts = decodePath(productId);\n if (parts.length >= 2) {\n return { category: parts[0], symbol: parts.slice(1).join('/') };\n }\n return { category: undefined, symbol: parts[0] };\n};\n\nconst handleSubmitOrderOfSpot: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n const { symbol } = parseProductId(order.product_id);\n const resolvedSymbol = symbol ?? order.product_id;\n if (!resolvedSymbol) {\n throw new Error(`Invalid product_id: unable to resolve spot symbol from \"${order.product_id}\"`);\n }\n\n const type = ({ MARKET: 'MARKET', LIMIT: 'LIMIT', MAKER: 'LIMIT' } as const)[order.order_type!];\n if (!type) throw new Error(`Unsupported order_type: ${order.order_type}`);\n\n const side = ({ OPEN_LONG: 'BUY', OPEN_SHORT: 'SELL', CLOSE_LONG: 'SELL', CLOSE_SHORT: 'BUY' } as const)[\n order.order_direction!\n ];\n if (!side) throw new Error(`Unsupported order_direction: ${order.order_direction}`);\n\n const timeInForce = order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;\n\n const price = order.price;\n\n let quantity: number | undefined = order.volume;\n let quoteOrderQty: number | undefined;\n\n if (type === 'MARKET' && side === 'BUY') {\n const spotPrice = await getApiV1TickerPrice(credential, {});\n const thePrice = spotPrice.find((x) => x.symbol === resolvedSymbol)?.price;\n if (!thePrice) throw new Error(`Cannot get price for symbol ${resolvedSymbol}`);\n quantity = undefined;\n quoteOrderQty = roundToStep(order.volume * +thePrice, 0.01);\n }\n\n const res = await postApiV1Order(credential, {\n symbol: resolvedSymbol,\n type,\n side,\n timeInForce,\n price,\n quantity,\n quoteOrderQty,\n });\n\n if (!res.orderId) {\n throw new Error('Failed to retrieve order ID from response');\n }\n\n return { order_id: '' + res.orderId };\n};\n\nconst handleSubmitOrderOfPerp: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n const { symbol } = parseProductId(order.product_id);\n if (!symbol) {\n throw new Error(`Invalid product_id: unable to decode symbol from \"${order.product_id}\"`);\n }\n\n const side = ({ OPEN_LONG: 'BUY', OPEN_SHORT: 'SELL', CLOSE_LONG: 'SELL', CLOSE_SHORT: 'BUY' } as const)[\n order.order_direction!\n ];\n if (!side) throw new Error(`Unsupported order_direction: ${order.order_direction}`);\n\n const type = ({ MARKET: 'MARKET', LIMIT: 'LIMIT', MAKER: 'LIMIT' } as const)[order.order_type!];\n if (!type) throw new Error(`Unsupported order_type: ${order.order_type}`);\n\n const quantity = order.volume;\n const price = order.price;\n\n const positionSide =\n order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_LONG'\n ? 'LONG'\n : order.order_direction === 'OPEN_SHORT' || order.order_direction === 'CLOSE_SHORT'\n ? 'SHORT'\n : undefined;\n\n const reduceOnly =\n order.order_direction === 'CLOSE_LONG' || order.order_direction === 'CLOSE_SHORT' ? 'true' : undefined;\n\n const timeInForce = order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;\n\n const res = await postFApiV1Order(credential, {\n symbol,\n side,\n type,\n quantity,\n price,\n timeInForce,\n positionSide,\n reduceOnly,\n });\n\n const orderId =\n (res as any)?.orderId ??\n (res as any)?.order_id ??\n (res as any)?.data?.orderId ??\n (res as any)?.data?.order_id;\n\n if (!orderId) throw new Error('Failed to retrieve order ID from response');\n\n return { order_id: `${orderId}` };\n};\n\nexport const handleSubmitOrder: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n const accountId = order.account_id?.toUpperCase() ?? order.account_id;\n const { category } = parseProductId(order.product_id);\n const productType = category?.toUpperCase();\n\n if (accountId?.includes('/SPOT') || productType === 'SPOT') {\n return handleSubmitOrderOfSpot(credential, order);\n }\n if (accountId?.includes('/PERP') || productType === 'PERPETUAL') {\n return handleSubmitOrderOfPerp(credential, order);\n }\n throw new Error(`Unsupported account_id for SubmitOrder: ${order.account_id}`);\n};\n"]}
1
+ {"version":3,"file":"submitOrder.js","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":";;;AACA,yCAAwD;AACxD,uDAA0G;AAE1G,MAAM,cAAc,GAAG,CAAC,SAAkB,EAAE,EAAE;IAC5C,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,EAAE,QAAQ,EAAE,SAA+B,EAAE,MAAM,EAAE,SAA+B,EAAE,CAAC;KAC/F;IACD,MAAM,KAAK,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;QACrB,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;KACjE;IACD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAA6C,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;;IACpG,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,KAAK,CAAC,UAAU,CAAC;IAClD,IAAI,CAAC,cAAc,EAAE;QACnB,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AK,CAAC,2CAA2C,CAAC,CAAC;IAE3E,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,CAAC;AACpC,CAAC,CAAC;AAEK,MAAM,iBAAiB,GAA6C,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;IACrG,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,8BAA8B;IAClF,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,OAAO,uBAAuB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;KACnD;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,OAAO,uBAAuB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;KACnD;IACD,MAAM,IAAI,KAAK,CAAC,2CAA2C,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC;AATW,QAAA,iBAAiB,qBAS5B","sourcesContent":["import { IActionHandlerOfSubmitOrder } from '@yuants/data-order';\nimport { decodePath, roundToStep } from '@yuants/utils';\nimport { getApiV1TickerPrice, ICredential, postApiV1Order, postFApiV1Order } from '../../api/private-api';\n\nconst parseProductId = (productId?: string) => {\n if (!productId) {\n return { category: undefined as string | undefined, symbol: undefined as string | undefined };\n }\n const parts = decodePath(productId);\n if (parts.length >= 2) {\n return { category: parts[0], symbol: parts.slice(1).join('/') };\n }\n return { category: undefined, symbol: parts[0] };\n};\n\nconst handleSubmitOrderOfSpot: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n const { symbol } = parseProductId(order.product_id);\n const resolvedSymbol = symbol ?? order.product_id;\n if (!resolvedSymbol) {\n throw new Error(`Invalid product_id: unable to resolve spot symbol from \"${order.product_id}\"`);\n }\n\n const type = ({ MARKET: 'MARKET', LIMIT: 'LIMIT', MAKER: 'LIMIT' } as const)[order.order_type!];\n if (!type) throw new Error(`Unsupported order_type: ${order.order_type}`);\n\n const side = ({ OPEN_LONG: 'BUY', OPEN_SHORT: 'SELL', CLOSE_LONG: 'SELL', CLOSE_SHORT: 'BUY' } as const)[\n order.order_direction!\n ];\n if (!side) throw new Error(`Unsupported order_direction: ${order.order_direction}`);\n\n const timeInForce = order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;\n\n const price = order.price;\n\n let quantity: number | undefined = order.volume;\n let quoteOrderQty: number | undefined;\n\n if (type === 'MARKET' && side === 'BUY') {\n const spotPrice = await getApiV1TickerPrice(credential, {});\n const thePrice = spotPrice.find((x) => x.symbol === resolvedSymbol)?.price;\n if (!thePrice) throw new Error(`Cannot get price for symbol ${resolvedSymbol}`);\n quantity = undefined;\n quoteOrderQty = roundToStep(order.volume * +thePrice, 0.01);\n }\n\n const res = await postApiV1Order(credential, {\n symbol: resolvedSymbol,\n type,\n side,\n timeInForce,\n price,\n quantity,\n quoteOrderQty,\n });\n\n if (!res.orderId) {\n throw new Error('Failed to retrieve order ID from response');\n }\n\n return { order_id: '' + res.orderId };\n};\n\nconst handleSubmitOrderOfPerp: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n const { symbol } = parseProductId(order.product_id);\n if (!symbol) {\n throw new Error(`Invalid product_id: unable to decode symbol from \"${order.product_id}\"`);\n }\n\n const side = ({ OPEN_LONG: 'BUY', OPEN_SHORT: 'SELL', CLOSE_LONG: 'SELL', CLOSE_SHORT: 'BUY' } as const)[\n order.order_direction!\n ];\n if (!side) throw new Error(`Unsupported order_direction: ${order.order_direction}`);\n\n const type = ({ MARKET: 'MARKET', LIMIT: 'LIMIT', MAKER: 'LIMIT' } as const)[order.order_type!];\n if (!type) throw new Error(`Unsupported order_type: ${order.order_type}`);\n\n const quantity = order.volume;\n const price = order.price;\n\n const positionSide =\n order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_LONG'\n ? 'LONG'\n : order.order_direction === 'OPEN_SHORT' || order.order_direction === 'CLOSE_SHORT'\n ? 'SHORT'\n : undefined;\n\n const reduceOnly =\n order.order_direction === 'CLOSE_LONG' || order.order_direction === 'CLOSE_SHORT' ? 'true' : undefined;\n\n const timeInForce = order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;\n\n const res = await postFApiV1Order(credential, {\n symbol,\n side,\n type,\n quantity,\n price,\n timeInForce,\n positionSide,\n reduceOnly,\n });\n\n const orderId =\n (res as any)?.orderId ??\n (res as any)?.order_id ??\n (res as any)?.data?.orderId ??\n (res as any)?.data?.order_id;\n\n if (!orderId) throw new Error('Failed to retrieve order ID from response');\n\n return { order_id: `${orderId}` };\n};\n\nexport const handleSubmitOrder: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n const [_, instType] = decodePath(order.product_id); // BITGET/USDT-FUTURES/BTCUSDT\n if (instType === 'SPOT') {\n return handleSubmitOrderOfSpot(credential, order);\n }\n if (instType === 'PERP') {\n return handleSubmitOrderOfPerp(credential, order);\n }\n throw new Error(`Unsupported account_id for SubmitOrder: ${order.account_id}`);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuants/vendor-aster",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "dist",
@@ -8,18 +8,19 @@
8
8
  "temp"
9
9
  ],
10
10
  "dependencies": {
11
- "@yuants/protocol": "0.53.0",
12
- "@yuants/cache": "0.3.2",
13
- "@yuants/data-account": "0.8.2",
14
- "@yuants/utils": "0.13.0",
15
- "@yuants/data-series": "0.3.49",
16
- "@yuants/sql": "0.9.28",
17
- "@yuants/data-product": "0.4.19",
18
- "@yuants/data-ohlc": "0.4.20",
19
- "@yuants/data-order": "0.6.4",
20
- "@yuants/data-interest-rate": "0.1.46",
21
- "@yuants/transfer": "0.2.37",
22
- "@yuants/data-quote": "0.2.41",
11
+ "@yuants/protocol": "0.53.1",
12
+ "@yuants/cache": "0.3.3",
13
+ "@yuants/data-account": "0.8.3",
14
+ "@yuants/utils": "0.14.0",
15
+ "@yuants/data-series": "0.3.50",
16
+ "@yuants/sql": "0.9.29",
17
+ "@yuants/data-product": "0.4.20",
18
+ "@yuants/data-ohlc": "0.4.21",
19
+ "@yuants/data-order": "0.6.5",
20
+ "@yuants/data-interest-rate": "0.1.47",
21
+ "@yuants/transfer": "0.2.38",
22
+ "@yuants/data-quote": "0.2.42",
23
+ "@yuants/exchange": "0.1.1",
23
24
  "rxjs": "~7.5.6"
24
25
  },
25
26
  "devDependencies": {
@@ -29,7 +30,7 @@
29
30
  "@rushstack/heft-node-rig": "~1.10.7",
30
31
  "@types/heft-jest": "1.0.3",
31
32
  "@types/node": "22",
32
- "@yuants/extension": "0.2.30",
33
+ "@yuants/extension": "0.2.31",
33
34
  "@yuants/tool-kit": "0.2.1",
34
35
  "typescript": "~4.7.4",
35
36
  "ts-node": "~10.9.2"
@@ -1,41 +1,40 @@
1
1
  {
2
2
  "apps/vendor-aster/AGENTS.md": "dcd006d19a5c3b73081525d7c0afea68cd6d058b",
3
- "apps/vendor-aster/CHANGELOG.json": "25a8097b77b28542f112f98e70c2dd7483bcaa50",
4
- "apps/vendor-aster/CHANGELOG.md": "e83e429c73efe432ed4cf7e5480ce6add0b7308b",
3
+ "apps/vendor-aster/CHANGELOG.json": "fa2c55fe3098c89d9d8b569ff1931a2d264ba14a",
4
+ "apps/vendor-aster/CHANGELOG.md": "2b7c2d7e4c84eb2bc9ed9ec63fe4c7c333cb90df",
5
5
  "apps/vendor-aster/SESSION_NOTES.md": "f54c13cf4182d8a5e720f6db5d3acc323655ea49",
6
6
  "apps/vendor-aster/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
7
7
  "apps/vendor-aster/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
8
8
  "apps/vendor-aster/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
9
- "apps/vendor-aster/package.json": "35a307077096af3e8274f9ae2f6d99ebb313e4f5",
10
- "apps/vendor-aster/src/api/private-api.ts": "ad888086c0c7793b8cdf3f095c1f790368d4e966",
9
+ "apps/vendor-aster/package.json": "da8cc4d87ecaf101da12b0e3de8f0c2f0237f8f4",
10
+ "apps/vendor-aster/src/api/private-api.ts": "2987cb0d1d0f6aac6ec8257696da1e755f15bc3b",
11
11
  "apps/vendor-aster/src/api/public-api.ts": "bfc642fff0ae31319c23e198f365a4a3372d4b10",
12
- "apps/vendor-aster/src/index.ts": "603b5c4e487389ce5c815ed5122a408abde43e17",
13
- "apps/vendor-aster/src/services/account-actions-with-credential.ts": "2d78127a969acaa4b0b39b8a93fcd3f0b76fd158",
14
- "apps/vendor-aster/src/services/accounts/perp.ts": "790004ac274d4a56fc18026e7dd99e8e54e9803d",
15
- "apps/vendor-aster/src/services/accounts/spot.ts": "9461d9f68c48d11a249aa01d6be49ef2cdfbfacf",
16
- "apps/vendor-aster/src/services/legacy.ts": "72d322567eb377e490c9fe26e6247f11de40154b",
17
- "apps/vendor-aster/src/services/markets/interest_rate.ts": "15befd821b9cefd892210d26228f0c84a124a28e",
18
- "apps/vendor-aster/src/services/markets/product.ts": "ddab6fc348a0fff17ef717683cbc2caf48c38513",
19
- "apps/vendor-aster/src/services/markets/quote.ts": "9cf8055d9c373c5a390c9704c7f8bde4e0b1cea5",
20
- "apps/vendor-aster/src/services/order-actions-with-credential.ts": "05a9a4e403ddee7b0b7de4308ee244d52174f3a3",
21
- "apps/vendor-aster/src/services/orders/cancelOrder.ts": "51adab5d66ba739779ceb98a5831c9434ae1ef0a",
22
- "apps/vendor-aster/src/services/orders/listOrders.ts": "ef6ea64f94d0bc59527f74699892e92e235f525a",
23
- "apps/vendor-aster/src/services/orders/submitOrder.ts": "ad7b62c9f9f63f89dec9ec9661949ce3c11bb68b",
24
- "apps/vendor-aster/src/utils.ts": "cf133a98161e868ef766bd3e3c340149345889f4",
12
+ "apps/vendor-aster/src/index.ts": "509ef4c18ec2deb8a6e11ed5682334433cb2bcb2",
13
+ "apps/vendor-aster/src/services/accounts/perp.ts": "4bdb41564394f1ddc9a1516a66a66c56d00d4581",
14
+ "apps/vendor-aster/src/services/accounts/profile.ts": "01cbb2cd8a913bb6471208eb96fb0613fbcd8f10",
15
+ "apps/vendor-aster/src/services/accounts/spot.ts": "d612814726080714af3cbe3deeaa3f57e109aaf9",
16
+ "apps/vendor-aster/src/services/exchange.ts": "4cdd15bfff1d1e4b1aceda287af6b280d088ccee",
17
+ "apps/vendor-aster/src/services/markets/interest_rate.ts": "a5b96e23862db9bd418bda65f92c4117ab044e95",
18
+ "apps/vendor-aster/src/services/markets/product.ts": "a0e5c02e9f99682cd2f4cb0a9e7a01747e540b4e",
19
+ "apps/vendor-aster/src/services/markets/quote.ts": "a5a828de8c5b43963459461d057825d977304233",
20
+ "apps/vendor-aster/src/services/orders/cancelOrder.ts": "09a6d3b10a218ad226346dd68d0ff0207083a7f1",
21
+ "apps/vendor-aster/src/services/orders/listOrders.ts": "579e83c45f6c4435ad3f5a2d3fe163a036bb9fd1",
22
+ "apps/vendor-aster/src/services/orders/submitOrder.ts": "9e99af753829d8f75a110cb29042ee3ebe6b724d",
25
23
  "apps/vendor-aster/tsconfig.json": "81da8f78196974b5d15da0edb6b2d9f48641063c",
26
- "apps/vendor-aster/.rush/temp/shrinkwrap-deps.json": "8909c2a52371c1bd644b09b7ccbb4bbaf29d53dd",
27
- "libraries/protocol/temp/package-deps.json": "00d9a96a90bfc0e57ef3b9547151f2970a600402",
28
- "libraries/cache/temp/package-deps.json": "70044bb56d863988aa90d8dcea9e3919bf65d38f",
29
- "libraries/data-account/temp/package-deps.json": "bf8b41c4d878dab0f39ea684fffaf6bc3c74c988",
30
- "libraries/utils/temp/package-deps.json": "4a683c07df7c75079b700111b9f6beb36c74ff7d",
31
- "libraries/data-series/temp/package-deps.json": "28ff94f0aeb81e62c78b686e6da9ec2a4a327855",
32
- "libraries/sql/temp/package-deps.json": "d227fb17cbb9f6e3b445a3b88e0d9978f5c1c823",
33
- "libraries/data-product/temp/package-deps.json": "c9a00b88e1570374aeb333756f59975d7dcc7400",
34
- "libraries/data-ohlc/temp/package-deps.json": "5138d2df7a458d21837124761460440fdcf7ec0e",
35
- "libraries/data-order/temp/package-deps.json": "4a0272551da88c9eb52150775640b12c31786de8",
36
- "libraries/data-interest-rate/temp/package-deps.json": "ea6718a7984f99121aeb4b5613d304fd2243787e",
37
- "libraries/transfer/temp/package-deps.json": "93c56bf224a26133b0ef6bb8efa294fec3efbc55",
38
- "libraries/data-quote/temp/package-deps.json": "2e78640ce117ae07bba4895ac82ea35501a60501",
39
- "libraries/extension/temp/package-deps.json": "96f8e94be2cbcfe210f7324dfc45b04a4f93d80b",
24
+ "apps/vendor-aster/.rush/temp/shrinkwrap-deps.json": "5ded440ffb547a8aa495353d5b13c1fd1b164b4a",
25
+ "libraries/protocol/temp/package-deps.json": "14095036ed251977cb3fb362a7e23d8786aaa4c9",
26
+ "libraries/cache/temp/package-deps.json": "a4afa15e6462983f9d3735d31dc1ed8a683fb4dc",
27
+ "libraries/data-account/temp/package-deps.json": "eb3d9ccad211a998fef9e0230e164407bf1b95fc",
28
+ "libraries/utils/temp/package-deps.json": "6d58e9b325e8d16de8a878c32010f626b12a01da",
29
+ "libraries/data-series/temp/package-deps.json": "d70ec6d1ca7342204a35a1c3619481e226239e73",
30
+ "libraries/sql/temp/package-deps.json": "95cd7209bf6002d530eb37960bac77c793afadd0",
31
+ "libraries/data-product/temp/package-deps.json": "60b8abf6f95edc29268f10f0d64331e2f034a3e5",
32
+ "libraries/data-ohlc/temp/package-deps.json": "959dd21977a31d4d9b623425c4c443d33729416d",
33
+ "libraries/data-order/temp/package-deps.json": "cf5b85fc4c5160f51023f7fbdc68a7ed9db5573a",
34
+ "libraries/data-interest-rate/temp/package-deps.json": "92396227ed3aab2f407bf93c515cf340ac796932",
35
+ "libraries/transfer/temp/package-deps.json": "0be7967706065779def1ef1e7f68a9794690599a",
36
+ "libraries/data-quote/temp/package-deps.json": "5a46a556f6eb8f2c682b092ee4703207e226ea8a",
37
+ "libraries/exchange/temp/package-deps.json": "68091305dec4ea0dc245f4314f1d474a2c3247d8",
38
+ "libraries/extension/temp/package-deps.json": "9569c553c2f9a7d50b70d8f101fc2d3825aaccb9",
40
39
  "tools/toolkit/temp/package-deps.json": "23e053490eb8feade23e4d45de4e54883e322711"
41
40
  }
@@ -1,34 +0,0 @@
1
- import { provideAccountActionsWithCredential } from '@yuants/data-account';
2
- import { Terminal } from '@yuants/protocol';
3
- import { getPerpAccountInfo } from './accounts/perp';
4
- import { getSpotAccountInfo } from './accounts/spot';
5
- provideAccountActionsWithCredential(Terminal.fromNodeEnv(), 'ASTER', {
6
- type: 'object',
7
- required: ['address', 'api_key', 'secret_key'],
8
- properties: {
9
- address: { type: 'string' },
10
- api_key: { type: 'string' },
11
- secret_key: { type: 'string' },
12
- },
13
- }, {
14
- listAccounts: async (credential) => {
15
- return [
16
- {
17
- account_id: `ASTER/${credential.address}/PERP`,
18
- },
19
- {
20
- account_id: `ASTER/${credential.address}/SPOT`,
21
- },
22
- ];
23
- },
24
- getAccountInfo: async (credential, account_id) => {
25
- if (account_id.endsWith('/PERP')) {
26
- return getPerpAccountInfo(credential, account_id);
27
- }
28
- if (account_id.endsWith('/SPOT')) {
29
- return getSpotAccountInfo(credential, account_id);
30
- }
31
- throw new Error(`Unsupported account type for account_id: ${account_id}`);
32
- },
33
- });
34
- //# sourceMappingURL=account-actions-with-credential.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account-actions-with-credential.js","sourceRoot":"","sources":["../../src/services/account-actions-with-credential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,mCAAmC,CACjC,QAAQ,CAAC,WAAW,EAAE,EACtB,OAAO,EACP;IACE,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC;IAC9C,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC/B;CACF,EACD;IACE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;QACjC,OAAO;YACL;gBACE,UAAU,EAAE,SAAS,UAAU,CAAC,OAAO,OAAO;aAC/C;YACD;gBACE,UAAU,EAAE,SAAS,UAAU,CAAC,OAAO,OAAO;aAC/C;SACF,CAAC;IACJ,CAAC;IACD,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE;QAC/C,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAChC,OAAO,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;SACnD;QACD,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAChC,OAAO,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;SACnD;QACD,MAAM,IAAI,KAAK,CAAC,4CAA4C,UAAU,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF,CACF,CAAC","sourcesContent":["import { provideAccountActionsWithCredential } from '@yuants/data-account';\nimport { Terminal } from '@yuants/protocol';\nimport { ICredential } from '../api/private-api';\nimport { getPerpAccountInfo } from './accounts/perp';\nimport { getSpotAccountInfo } from './accounts/spot';\n\nprovideAccountActionsWithCredential<ICredential>(\n Terminal.fromNodeEnv(),\n 'ASTER',\n {\n type: 'object',\n required: ['address', 'api_key', 'secret_key'],\n properties: {\n address: { type: 'string' },\n api_key: { type: 'string' },\n secret_key: { type: 'string' },\n },\n },\n {\n listAccounts: async (credential) => {\n return [\n {\n account_id: `ASTER/${credential.address}/PERP`,\n },\n {\n account_id: `ASTER/${credential.address}/SPOT`,\n },\n ];\n },\n getAccountInfo: async (credential, account_id) => {\n if (account_id.endsWith('/PERP')) {\n return getPerpAccountInfo(credential, account_id);\n }\n if (account_id.endsWith('/SPOT')) {\n return getSpotAccountInfo(credential, account_id);\n }\n throw new Error(`Unsupported account type for account_id: ${account_id}`);\n },\n },\n);\n"]}
@@ -1,69 +0,0 @@
1
- import { provideAccountInfoService } from '@yuants/data-account';
2
- import { providePendingOrdersService } from '@yuants/data-order';
3
- import { Terminal } from '@yuants/protocol';
4
- import { getPerpAccountInfo } from '../services/accounts/perp';
5
- import { getSpotAccountInfo } from '../services/accounts/spot';
6
- import { handleCancelOrder } from '../services/orders/cancelOrder';
7
- import { handleSubmitOrder } from '../services/orders/submitOrder';
8
- import { listOrders } from './orders/listOrders';
9
- const getDefaultCredential = () => {
10
- return {
11
- address: process.env.API_ADDRESS || '',
12
- api_key: process.env.API_KEY || '',
13
- secret_key: process.env.SECRET_KEY || '',
14
- };
15
- };
16
- const ADDRESS = process.env.ADDRESS;
17
- const credential = getDefaultCredential();
18
- const terminal = Terminal.fromNodeEnv();
19
- const SPOT_ACCOUNT_ID = `ASTER/${ADDRESS}/SPOT`;
20
- const PERP_ACCOUNT_ID = `ASTER/${ADDRESS}`;
21
- provideAccountInfoService(Terminal.fromNodeEnv(), SPOT_ACCOUNT_ID, async () => getSpotAccountInfo(credential, SPOT_ACCOUNT_ID), { auto_refresh_interval: 1000 });
22
- provideAccountInfoService(Terminal.fromNodeEnv(), PERP_ACCOUNT_ID, async () => getPerpAccountInfo(credential, PERP_ACCOUNT_ID), { auto_refresh_interval: 1000 });
23
- providePendingOrdersService(terminal, SPOT_ACCOUNT_ID, async () => listOrders(credential, SPOT_ACCOUNT_ID), {
24
- auto_refresh_interval: 1000,
25
- });
26
- providePendingOrdersService(terminal, PERP_ACCOUNT_ID, async () => listOrders(credential, PERP_ACCOUNT_ID), {
27
- auto_refresh_interval: 2000,
28
- });
29
- Terminal.fromNodeEnv().server.provideService('CancelOrder', {
30
- required: ['account_id', 'order_id', 'product_id'],
31
- properties: {
32
- account_id: { type: 'string', const: SPOT_ACCOUNT_ID },
33
- order_id: { type: ['string', 'number'] },
34
- product_id: { type: 'string' },
35
- },
36
- }, async (msg) => {
37
- const order = msg.req;
38
- await handleCancelOrder(credential, order);
39
- return { res: { code: 0, message: 'OK' } };
40
- });
41
- Terminal.fromNodeEnv().server.provideService('SubmitOrder', { required: ['account_id'], properties: { account_id: { type: 'string', const: SPOT_ACCOUNT_ID } } }, async (msg) => {
42
- const order = msg.req;
43
- const data = await handleSubmitOrder(credential, order);
44
- return { res: { code: 0, message: 'OK', data } };
45
- });
46
- terminal.server.provideService('SubmitOrder', { required: ['account_id'], properties: { account_id: { type: 'string', const: PERP_ACCOUNT_ID } } }, async (msg) => {
47
- const order = msg.req;
48
- const data = await handleSubmitOrder(credential, order);
49
- return {
50
- res: {
51
- code: 0,
52
- message: 'OK',
53
- data,
54
- },
55
- };
56
- });
57
- terminal.server.provideService('CancelOrder', {
58
- required: ['account_id', 'order_id', 'product_id'],
59
- properties: {
60
- account_id: { type: 'string', const: PERP_ACCOUNT_ID },
61
- order_id: { type: ['string', 'number'] },
62
- product_id: { type: 'string' },
63
- },
64
- }, async (msg) => {
65
- const order = msg.req;
66
- await handleCancelOrder(credential, order);
67
- return { res: { code: 0, message: 'OK' } };
68
- });
69
- //# sourceMappingURL=legacy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../src/services/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAU,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CA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AAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;AACnD,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,MAAM,CAAC,cAAc,CAC5B,aAAa,EACb,EAAE,QAAQ,EAAE,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,EACpG,KAAK,EAAE,GAAG,EAAE,EAAE;IACZ,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC;IACtB,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAExD,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,IAAI;YACb,IAAI;SACL;KACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,MAAM,CAAC,cAAc,CAC5B,aAAa,EACb;IACE,QAAQ,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC;IAClD,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE;QACtD,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE;QACxC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC/B;CACF,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;IACZ,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC;IAEtB,MAAM,iBAAiB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAE3C,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;AAC7C,CAAC,CACF,CAAC","sourcesContent":["import { provideAccountInfoService } from '@yuants/data-account';\nimport { IOrder, providePendingOrdersService } from '@yuants/data-order';\nimport { Terminal } from '@yuants/protocol';\nimport { ICredential } from '../api/private-api';\nimport { getPerpAccountInfo } from '../services/accounts/perp';\nimport { getSpotAccountInfo } from '../services/accounts/spot';\nimport { handleCancelOrder } from '../services/orders/cancelOrder';\nimport { handleSubmitOrder } from '../services/orders/submitOrder';\nimport { listOrders } from './orders/listOrders';\n\nconst getDefaultCredential = (): ICredential => {\n return {\n address: process.env.API_ADDRESS || '',\n api_key: process.env.API_KEY || '',\n secret_key: process.env.SECRET_KEY || '',\n };\n};\n\nconst ADDRESS = process.env.ADDRESS!;\nconst credential = getDefaultCredential();\nconst terminal = Terminal.fromNodeEnv();\n\nconst SPOT_ACCOUNT_ID = `ASTER/${ADDRESS}/SPOT`;\nconst PERP_ACCOUNT_ID = `ASTER/${ADDRESS}`;\n\nprovideAccountInfoService(\n Terminal.fromNodeEnv(),\n SPOT_ACCOUNT_ID,\n async () => getSpotAccountInfo(credential, SPOT_ACCOUNT_ID),\n { auto_refresh_interval: 1000 },\n);\n\nprovideAccountInfoService(\n Terminal.fromNodeEnv(),\n PERP_ACCOUNT_ID,\n async () => getPerpAccountInfo(credential, PERP_ACCOUNT_ID),\n { auto_refresh_interval: 1000 },\n);\n\nprovidePendingOrdersService(terminal, SPOT_ACCOUNT_ID, async () => listOrders(credential, SPOT_ACCOUNT_ID), {\n auto_refresh_interval: 1000,\n});\n\nprovidePendingOrdersService(terminal, PERP_ACCOUNT_ID, async () => listOrders(credential, PERP_ACCOUNT_ID), {\n auto_refresh_interval: 2000,\n});\n\nTerminal.fromNodeEnv().server.provideService<IOrder>(\n 'CancelOrder',\n {\n required: ['account_id', 'order_id', 'product_id'],\n properties: {\n account_id: { type: 'string', const: SPOT_ACCOUNT_ID },\n order_id: { type: ['string', 'number'] },\n product_id: { type: 'string' },\n },\n },\n async (msg) => {\n const order = msg.req;\n\n await handleCancelOrder(credential, order);\n\n return { res: { code: 0, message: 'OK' } };\n },\n);\n\nTerminal.fromNodeEnv().server.provideService<IOrder, { order_id: string }>(\n 'SubmitOrder',\n { required: ['account_id'], properties: { account_id: { type: 'string', const: SPOT_ACCOUNT_ID } } },\n async (msg) => {\n const order = msg.req;\n\n const data = await handleSubmitOrder(credential, order);\n\n return { res: { code: 0, message: 'OK', data } };\n },\n);\n\nterminal.server.provideService<IOrder, { order_id?: string }>(\n 'SubmitOrder',\n { required: ['account_id'], properties: { account_id: { type: 'string', const: PERP_ACCOUNT_ID } } },\n async (msg) => {\n const order = msg.req;\n const data = await handleSubmitOrder(credential, order);\n\n return {\n res: {\n code: 0,\n message: 'OK',\n data,\n },\n };\n },\n);\n\nterminal.server.provideService<IOrder>(\n 'CancelOrder',\n {\n required: ['account_id', 'order_id', 'product_id'],\n properties: {\n account_id: { type: 'string', const: PERP_ACCOUNT_ID },\n order_id: { type: ['string', 'number'] },\n product_id: { type: 'string' },\n },\n },\n async (msg) => {\n const order = msg.req;\n\n await handleCancelOrder(credential, order);\n\n return { res: { code: 0, message: 'OK' } };\n },\n);\n"]}
@@ -1,19 +0,0 @@
1
- import { provideOrderActionsWithCredential } from '@yuants/data-order';
2
- import { Terminal } from '@yuants/protocol';
3
- import { handleCancelOrder } from './orders/cancelOrder';
4
- import { handleSubmitOrder } from './orders/submitOrder';
5
- import { listOrders } from './orders/listOrders';
6
- provideOrderActionsWithCredential(Terminal.fromNodeEnv(), 'ASTER', {
7
- type: 'object',
8
- required: ['address', 'api_key', 'secret_key'],
9
- properties: {
10
- address: { type: 'string' },
11
- api_key: { type: 'string' },
12
- secret_key: { type: 'string' },
13
- },
14
- }, {
15
- submitOrder: handleSubmitOrder,
16
- cancelOrder: handleCancelOrder,
17
- listOrders,
18
- });
19
- //# sourceMappingURL=order-actions-with-credential.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order-actions-with-credential.js","sourceRoot":"","sources":["../../src/services/order-actions-with-credential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,iCAAiC,CAC/B,QAAQ,CAAC,WAAW,EAAE,EACtB,OAAO,EACP;IACE,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC;IAC9C,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC/B;CACF,EACD;IACE,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,iBAAiB;IAC9B,UAAU;CACX,CACF,CAAC","sourcesContent":["import { provideOrderActionsWithCredential } from '@yuants/data-order';\nimport { Terminal } from '@yuants/protocol';\nimport { handleCancelOrder } from './orders/cancelOrder';\nimport { handleSubmitOrder } from './orders/submitOrder';\nimport { listOrders } from './orders/listOrders';\n\nprovideOrderActionsWithCredential(\n Terminal.fromNodeEnv(),\n 'ASTER',\n {\n type: 'object',\n required: ['address', 'api_key', 'secret_key'],\n properties: {\n address: { type: 'string' },\n api_key: { type: 'string' },\n secret_key: { type: 'string' },\n },\n },\n {\n submitOrder: handleSubmitOrder,\n cancelOrder: handleCancelOrder,\n listOrders,\n },\n);\n"]}
package/dist/utils.js DELETED
@@ -1,9 +0,0 @@
1
- export function uint8ArrayToHex(bytes) {
2
- const hexArray = [];
3
- for (const byte of bytes) {
4
- const hex = byte.toString(16).padStart(2, '0');
5
- hexArray.push(hex);
6
- }
7
- return hexArray.join('');
8
- }
9
- //# sourceMappingURL=utils.js.map
package/dist/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC/C,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACpB;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["export function uint8ArrayToHex(bytes: Uint8Array): string {\n const hexArray: string[] = [];\n\n for (const byte of bytes) {\n const hex = byte.toString(16).padStart(2, '0');\n hexArray.push(hex);\n }\n\n return hexArray.join('');\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=account-actions-with-credential.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account-actions-with-credential.d.ts","sourceRoot":"","sources":["../../src/services/account-actions-with-credential.ts"],"names":[],"mappings":""}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const data_account_1 = require("@yuants/data-account");
4
- const protocol_1 = require("@yuants/protocol");
5
- const perp_1 = require("./accounts/perp");
6
- const spot_1 = require("./accounts/spot");
7
- (0, data_account_1.provideAccountActionsWithCredential)(protocol_1.Terminal.fromNodeEnv(), 'ASTER', {
8
- type: 'object',
9
- required: ['address', 'api_key', 'secret_key'],
10
- properties: {
11
- address: { type: 'string' },
12
- api_key: { type: 'string' },
13
- secret_key: { type: 'string' },
14
- },
15
- }, {
16
- listAccounts: async (credential) => {
17
- return [
18
- {
19
- account_id: `ASTER/${credential.address}/PERP`,
20
- },
21
- {
22
- account_id: `ASTER/${credential.address}/SPOT`,
23
- },
24
- ];
25
- },
26
- getAccountInfo: async (credential, account_id) => {
27
- if (account_id.endsWith('/PERP')) {
28
- return (0, perp_1.getPerpAccountInfo)(credential, account_id);
29
- }
30
- if (account_id.endsWith('/SPOT')) {
31
- return (0, spot_1.getSpotAccountInfo)(credential, account_id);
32
- }
33
- throw new Error(`Unsupported account type for account_id: ${account_id}`);
34
- },
35
- });
36
- //# sourceMappingURL=account-actions-with-credential.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account-actions-with-credential.js","sourceRoot":"","sources":["../../src/services/account-actions-with-credential.ts"],"names":[],"mappings":";;AAAA,uDAA2E;AAC3E,+CAA4C;AAE5C,0CAAqD;AACrD,0CAAqD;AAErD,IAAA,kDAAmC,EACjC,mBAAQ,CAAC,WAAW,EAAE,EACtB,OAAO,EACP;IACE,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC;IAC9C,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC/B;CACF,EACD;IACE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;QACjC,OAAO;YACL;gBACE,UAAU,EAAE,SAAS,UAAU,CAAC,OAAO,OAAO;aAC/C;YACD;gBACE,UAAU,EAAE,SAAS,UAAU,CAAC,OAAO,OAAO;aAC/C;SACF,CAAC;IACJ,CAAC;IACD,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE;QAC/C,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAChC,OAAO,IAAA,yBAAkB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;SACnD;QACD,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAChC,OAAO,IAAA,yBAAkB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;SACnD;QACD,MAAM,IAAI,KAAK,CAAC,4CAA4C,UAAU,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF,CACF,CAAC","sourcesContent":["import { provideAccountActionsWithCredential } from '@yuants/data-account';\nimport { Terminal } from '@yuants/protocol';\nimport { ICredential } from '../api/private-api';\nimport { getPerpAccountInfo } from './accounts/perp';\nimport { getSpotAccountInfo } from './accounts/spot';\n\nprovideAccountActionsWithCredential<ICredential>(\n Terminal.fromNodeEnv(),\n 'ASTER',\n {\n type: 'object',\n required: ['address', 'api_key', 'secret_key'],\n properties: {\n address: { type: 'string' },\n api_key: { type: 'string' },\n secret_key: { type: 'string' },\n },\n },\n {\n listAccounts: async (credential) => {\n return [\n {\n account_id: `ASTER/${credential.address}/PERP`,\n },\n {\n account_id: `ASTER/${credential.address}/SPOT`,\n },\n ];\n },\n getAccountInfo: async (credential, account_id) => {\n if (account_id.endsWith('/PERP')) {\n return getPerpAccountInfo(credential, account_id);\n }\n if (account_id.endsWith('/SPOT')) {\n return getSpotAccountInfo(credential, account_id);\n }\n throw new Error(`Unsupported account type for account_id: ${account_id}`);\n },\n },\n);\n"]}