@yuants/vendor-turboflow 1.2.0 → 1.2.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.
Files changed (48) hide show
  1. package/.rush/temp/chunked-rush-logs/vendor-turboflow.build.chunks.jsonl +6 -6
  2. package/.rush/temp/operation/build/all.log +6 -6
  3. package/.rush/temp/operation/build/log-chunks.jsonl +6 -6
  4. package/.rush/temp/operation/build/state.json +1 -1
  5. package/.rush/temp/shrinkwrap-deps.json +1 -1
  6. package/CHANGELOG.json +17 -0
  7. package/CHANGELOG.md +8 -1
  8. package/lib/api/private-api.d.ts +1 -1
  9. package/lib/api/private-api.d.ts.map +1 -1
  10. package/lib/api/private-api.js +3 -2
  11. package/lib/api/private-api.js.map +1 -1
  12. package/lib/api/public-api.d.ts +31 -0
  13. package/lib/api/public-api.d.ts.map +1 -0
  14. package/lib/api/public-api.js +29 -0
  15. package/lib/api/public-api.js.map +1 -0
  16. package/lib/index.d.ts +1 -2
  17. package/lib/index.d.ts.map +1 -1
  18. package/lib/index.js +1 -3
  19. package/lib/index.js.map +1 -1
  20. package/lib/services/exchange.d.ts +2 -0
  21. package/lib/services/exchange.d.ts.map +1 -0
  22. package/lib/services/exchange.js +96 -0
  23. package/lib/services/exchange.js.map +1 -0
  24. package/lib/services/orders/cancelOrder.d.ts.map +1 -1
  25. package/lib/services/orders/cancelOrder.js +21 -28
  26. package/lib/services/orders/cancelOrder.js.map +1 -1
  27. package/lib/services/orders/listOrders.d.ts +2 -2
  28. package/lib/services/orders/listOrders.d.ts.map +1 -1
  29. package/lib/services/orders/listOrders.js +9 -23
  30. package/lib/services/orders/listOrders.js.map +1 -1
  31. package/lib/services/orders/submitOrder.d.ts.map +1 -1
  32. package/lib/services/orders/submitOrder.js +7 -5
  33. package/lib/services/orders/submitOrder.js.map +1 -1
  34. package/package.json +3 -1
  35. package/rush-logs/vendor-turboflow.build.log +6 -6
  36. package/src/api/private-api.ts +4 -3
  37. package/src/api/public-api.ts +65 -0
  38. package/src/index.ts +1 -3
  39. package/src/services/exchange.ts +107 -0
  40. package/src/services/orders/cancelOrder.ts +22 -29
  41. package/src/services/orders/listOrders.ts +11 -28
  42. package/src/services/orders/submitOrder.ts +6 -5
  43. package/temp/package-deps.json +13 -10
  44. package/lib/services/account-actions-with-credential.d.ts +0 -2
  45. package/lib/services/account-actions-with-credential.d.ts.map +0 -1
  46. package/lib/services/account-actions-with-credential.js +0 -60
  47. package/lib/services/account-actions-with-credential.js.map +0 -1
  48. package/src/services/account-actions-with-credential.ts +0 -76
@@ -1,60 +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 utils_1 = require("@yuants/utils");
6
- const private_api_1 = require("../api/private-api");
7
- (0, data_account_1.provideAccountActionsWithCredential)(protocol_1.Terminal.fromNodeEnv(), 'TURBOFLOW', {
8
- type: 'object',
9
- required: ['private_key'],
10
- properties: {
11
- private_key: {
12
- type: 'string',
13
- description: 'ED25519 Private Key (base58 encoded)',
14
- },
15
- },
16
- }, {
17
- listAccounts: async (credential) => {
18
- const accountInfo = await (0, private_api_1.getAccountInfo)(credential, undefined);
19
- return (0, utils_1.scopeError)('ListAccountsError::TurboFlow', { error: accountInfo.errno, message: accountInfo.msg }, () => [
20
- {
21
- account_id: `turboflow/${accountInfo.data.account_id}`,
22
- },
23
- ]);
24
- },
25
- getAccountInfo: async (credential, account_id) => {
26
- const assetsResponse = await (0, private_api_1.getAccountAssets)(credential, {
27
- fill_coin_sub_info: '1',
28
- });
29
- const assetPositions = assetsResponse.data.list.map((x) => (0, data_account_1.makeSpotPosition)({
30
- position_id: x.coin_code,
31
- product_id: (0, utils_1.encodePath)('SPOT', x.coin_name),
32
- volume: parseFloat(x.available_balance),
33
- free_volume: parseFloat(x.available_balance),
34
- closable_price: 1,
35
- }));
36
- const positionsResponse = await (0, private_api_1.getPositionList)(credential, { status: 'Holding' });
37
- const positions = (positionsResponse.data.data || []).map((position) => {
38
- const side = position.side === 1 ? 'LONG' : 'SHORT';
39
- const holdSize = parseFloat(position.hold_size);
40
- const holdAv = parseFloat(position.hold_av);
41
- const unpnl = parseFloat(position.unpnl);
42
- const im = parseFloat(position.im);
43
- return {
44
- position_id: position.id,
45
- datasource_id: 'TURBOFLOW',
46
- product_id: (0, utils_1.encodePath)('PERP', position.symbol),
47
- direction: side,
48
- volume: holdSize,
49
- free_volume: holdSize,
50
- position_price: holdAv,
51
- closable_price: holdAv,
52
- floating_profit: unpnl,
53
- valuation: holdSize * holdAv,
54
- margin: im,
55
- };
56
- });
57
- return [...assetPositions, ...positions];
58
- },
59
- });
60
- //# 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,uDAAwG;AACxG,+CAA4C;AAC5C,yCAAuD;AACvD,oDAAoG;AAEpG,IAAA,kDAAmC,EACjC,mBAAQ,CAAC,WAAW,EAAE,EACtB,WAAW,EACX;IACE,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,aAAa,CAAC;IACzB,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,sCAAsC;SACpD;KACF;CACF,EACD;IACE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;QACjC,MAAM,WAAW,GAAG,MAAM,IAAA,4BAAc,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAEhE,OAAO,IAAA,kBAAU,EACf,8BAA8B,EAC9B,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,EACtD,GAAG,EAAE,CAAC;YACJ;gBACE,UAAU,EAAE,aAAa,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE;aACvD;SACF,CACF,CAAC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EAAE;gBACxB,aAAa,EAAE,WAAW;gBAC1B,UAAU,EAAE,IAAA,kBAAU,EAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAC/C,SAAS,EAAE,IAAI;gBACf,MAAM,EAAE,QAAQ;gBAChB,WAAW,EAAE,QAAQ;gBACrB,cAAc,EAAE,MAAM;gBACtB,cAAc,EAAE,MAAM;gBACtB,eAAe,EAAE,KAAK;gBACtB,SAAS,EAAE,QAAQ,GAAG,MAAM;gBAC5B,MAAM,EAAE,EAAE;aACX,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,cAAc,EAAE,GAAG,SAAS,CAAC,CAAC;IAC3C,CAAC;CACF,CACF,CAAC","sourcesContent":["import { IPosition, makeSpotPosition, provideAccountActionsWithCredential } from '@yuants/data-account';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath, scopeError } from '@yuants/utils';\nimport { getAccountAssets, getAccountInfo, getPositionList, ICredential } from '../api/private-api';\n\nprovideAccountActionsWithCredential<ICredential>(\n Terminal.fromNodeEnv(),\n 'TURBOFLOW',\n {\n type: 'object',\n required: ['private_key'],\n properties: {\n private_key: {\n type: 'string',\n description: 'ED25519 Private Key (base58 encoded)',\n },\n },\n },\n {\n listAccounts: async (credential) => {\n const accountInfo = await getAccountInfo(credential, undefined);\n\n return scopeError(\n 'ListAccountsError::TurboFlow',\n { error: accountInfo.errno, message: accountInfo.msg },\n () => [\n {\n account_id: `turboflow/${accountInfo.data.account_id}`,\n },\n ],\n );\n },\n\n getAccountInfo: async (credential, account_id) => {\n const assetsResponse = await getAccountAssets(credential, {\n fill_coin_sub_info: '1',\n });\n\n const assetPositions = assetsResponse.data.list.map((x) =>\n makeSpotPosition({\n position_id: x.coin_code,\n product_id: encodePath('SPOT', x.coin_name),\n volume: parseFloat(x.available_balance),\n free_volume: parseFloat(x.available_balance),\n closable_price: 1,\n }),\n );\n\n const positionsResponse = await getPositionList(credential, { status: 'Holding' });\n\n const positions: IPosition[] = (positionsResponse.data.data || []).map((position) => {\n const side = position.side === 1 ? 'LONG' : 'SHORT';\n const holdSize = parseFloat(position.hold_size);\n const holdAv = parseFloat(position.hold_av);\n const unpnl = parseFloat(position.unpnl);\n const im = parseFloat(position.im);\n\n return {\n position_id: position.id,\n datasource_id: 'TURBOFLOW',\n product_id: encodePath('PERP', position.symbol),\n direction: side,\n volume: holdSize,\n free_volume: holdSize, // Assuming all volume is free\n position_price: holdAv,\n closable_price: holdAv,\n floating_profit: unpnl,\n valuation: holdSize * holdAv,\n margin: im,\n };\n });\n\n return [...assetPositions, ...positions];\n },\n },\n);\n"]}
@@ -1,76 +0,0 @@
1
- import { IPosition, makeSpotPosition, provideAccountActionsWithCredential } from '@yuants/data-account';
2
- import { Terminal } from '@yuants/protocol';
3
- import { encodePath, scopeError } from '@yuants/utils';
4
- import { getAccountAssets, getAccountInfo, getPositionList, ICredential } from '../api/private-api';
5
-
6
- provideAccountActionsWithCredential<ICredential>(
7
- Terminal.fromNodeEnv(),
8
- 'TURBOFLOW',
9
- {
10
- type: 'object',
11
- required: ['private_key'],
12
- properties: {
13
- private_key: {
14
- type: 'string',
15
- description: 'ED25519 Private Key (base58 encoded)',
16
- },
17
- },
18
- },
19
- {
20
- listAccounts: async (credential) => {
21
- const accountInfo = await getAccountInfo(credential, undefined);
22
-
23
- return scopeError(
24
- 'ListAccountsError::TurboFlow',
25
- { error: accountInfo.errno, message: accountInfo.msg },
26
- () => [
27
- {
28
- account_id: `turboflow/${accountInfo.data.account_id}`,
29
- },
30
- ],
31
- );
32
- },
33
-
34
- getAccountInfo: async (credential, account_id) => {
35
- const assetsResponse = await getAccountAssets(credential, {
36
- fill_coin_sub_info: '1',
37
- });
38
-
39
- const assetPositions = assetsResponse.data.list.map((x) =>
40
- makeSpotPosition({
41
- position_id: x.coin_code,
42
- product_id: encodePath('SPOT', x.coin_name),
43
- volume: parseFloat(x.available_balance),
44
- free_volume: parseFloat(x.available_balance),
45
- closable_price: 1,
46
- }),
47
- );
48
-
49
- const positionsResponse = await getPositionList(credential, { status: 'Holding' });
50
-
51
- const positions: IPosition[] = (positionsResponse.data.data || []).map((position) => {
52
- const side = position.side === 1 ? 'LONG' : 'SHORT';
53
- const holdSize = parseFloat(position.hold_size);
54
- const holdAv = parseFloat(position.hold_av);
55
- const unpnl = parseFloat(position.unpnl);
56
- const im = parseFloat(position.im);
57
-
58
- return {
59
- position_id: position.id,
60
- datasource_id: 'TURBOFLOW',
61
- product_id: encodePath('PERP', position.symbol),
62
- direction: side,
63
- volume: holdSize,
64
- free_volume: holdSize, // Assuming all volume is free
65
- position_price: holdAv,
66
- closable_price: holdAv,
67
- floating_profit: unpnl,
68
- valuation: holdSize * holdAv,
69
- margin: im,
70
- };
71
- });
72
-
73
- return [...assetPositions, ...positions];
74
- },
75
- },
76
- );