@yuants/vendor-gate 0.7.0 → 0.7.2
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/api/private-api.js +6 -0
- package/dist/api/private-api.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/services/interest-ledger-service.js +25 -21
- package/dist/services/interest-ledger-service.js.map +1 -1
- package/dist/services/trade-history-service.js +62 -0
- package/dist/services/trade-history-service.js.map +1 -0
- package/lib/api/private-api.d.ts +26 -0
- package/lib/api/private-api.d.ts.map +1 -1
- package/lib/api/private-api.js +8 -1
- package/lib/api/private-api.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/services/interest-ledger-service.js +25 -21
- package/lib/services/interest-ledger-service.js.map +1 -1
- package/lib/services/trade-history-service.d.ts +2 -0
- package/lib/services/trade-history-service.d.ts.map +1 -0
- package/lib/services/trade-history-service.js +64 -0
- package/lib/services/trade-history-service.js.map +1 -0
- package/package.json +9 -8
- package/temp/build/typescript/ts_Eujh_fX2.json +1 -1
- package/temp/package-deps.json +10 -8
- package/temp/test/jest/haste-map-ac984f375ffe2771b37aa116ca7fe6f5-87fb4bb14df3d29fb61369ce8cbe1fe1-6499ab22de0ac9ce813ded0e96430273 +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trade-history-service.js","sourceRoot":"","sources":["../../src/services/trade-history-service.ts"],"names":[],"mappings":";;AAAA,+CAA4C;AAC5C,yCAAuD;AACvD,+CAA8D;AAC9D,oDAA6D;AAE7D,uDAAgE;AAMhE,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AACxC,MAAM,aAAa,GAAG,IAAA,uCAAwB,EAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAQ,EAAE,CAAC,CAAC;AAE/E,MAAM,SAAS,GA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AM,CAAC;oBACN,SAAS,GAAG,YAAY,CAAC;gBAC3B,CAAC;YACH,CAAC;YACD,IAAI,eAAe,GAAG,CAAC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;gBAC1C,SAAS,GAAG,aAAa,CAAC;YAC5B,CAAC;YACD,IAAI,eAAe,GAAG,CAAC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;gBAC1C,SAAS,GAAG,YAAY,CAAC;YAC3B,CAAC;YAED,OAAO;gBACL,EAAE,EAAE,CAAC,CAAC,QAAQ;gBACd,UAAU;gBACV,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,MAAA,OAAO,CAAC,WAAW,mCAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;gBAClE,UAAU,EAAE,GAAG,CAAC,UAAU;gBAC1B,SAAS;gBACT,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,GAAG,EAAE,CAAC,CAAC,GAAG;gBACV,YAAY,EAAE,MAAM;gBACpB,UAAU,EAAE,IAAA,kBAAU,EAAC,EAAE,CAAC;aACV,CAAC;QACrB,CAAC,CAAC,CACH,CACF,CAAC,MAAM,CACN,CAAC,CAAC,EAAqC,EAAE,CACvC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,UAAW,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,IAAI,CACjE,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,IAAA,qCAA0B,EACxB,QAAQ,EACR;IACE,SAAS,EAAE,UAAU;IACrB,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,CAAC,WAAW,CAAC;CAC1B,EACD,yBAAyB,CAC1B,CAAC","sourcesContent":["import { Terminal } from '@yuants/protocol';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { provideTradeHistoryService } from '@yuants/exchange';\nimport { getFutureAccountsTrades } from '../api/private-api';\nimport { ITradeHistory } from '@yuants/data-trade';\nimport { createClientProductCache } from '@yuants/data-product';\ninterface IExchangeCredential {\n type: string;\n payload: any;\n}\n\nconst terminal = Terminal.fromNodeEnv();\nconst productsCache = createClientProductCache(terminal, { expire: 7200_000 });\n\nconst WINDOW_MS = 1 * 24 * 3600_000;\nconst fetchTradeHistoryBackward = async (req: {\n credential: IExchangeCredential;\n account_id: string;\n time: number;\n trade_type: string;\n}): Promise<ITradeHistory[]> => {\n if (req.trade_type === 'USDT_SWAP') {\n const params = {\n settle: 'usdt',\n to: ~~(req.time / 1000),\n from: ~~((req.time - WINDOW_MS) / 1000),\n limit: 100,\n };\n const res = await getFutureAccountsTrades(req.credential.payload, params);\n return (\n await Promise.all(\n (res ?? []).map(async (v): Promise<ITradeHistory | undefined> => {\n const product_id = encodePath('GATE', 'FUTURE', v.contract);\n const product = await productsCache.query(product_id);\n if (!product) return;\n const ms = Number(v.create_time) * 1000;\n let direction = 'OPEN_LONG';\n const numberSize = +v.size;\n const numberCloseSize = +v.close_size;\n if (numberCloseSize === 0) {\n if (numberSize > 0) {\n direction = 'OPEN_LONG';\n } else {\n direction = 'OPEN_SHORT';\n }\n }\n if (numberCloseSize > 0 && numberSize > 0) {\n direction = 'CLOSE_SHORT';\n }\n if (numberCloseSize < 0 && numberSize < 0) {\n direction = 'CLOSE_LONG';\n }\n\n return {\n id: v.trade_id,\n product_id,\n size: Math.abs(numberSize * (product.value_scale ?? 1)).toString(),\n account_id: req.account_id,\n direction,\n price: v.price,\n fee: v.fee,\n fee_currency: 'USDT',\n created_at: formatTime(ms),\n } as ITradeHistory;\n }),\n )\n ).filter(\n (x): x is Exclude<typeof x, undefined> =>\n !!x && Date.parse(x.created_at!) <= ~~(req.time / 1000) * 1000,\n );\n }\n return [];\n};\n\nprovideTradeHistoryService(\n terminal,\n {\n direction: 'backward',\n type: 'GATE',\n trade_type: ['USDT_SWAP'],\n },\n fetchTradeHistoryBackward,\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/vendor-gate",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib",
|
|
@@ -10,18 +10,19 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"rxjs": "~7.5.6",
|
|
12
12
|
"@yuants/cache": "0.3.12",
|
|
13
|
-
"@yuants/
|
|
13
|
+
"@yuants/data-order": "0.7.9",
|
|
14
14
|
"@yuants/transfer": "0.2.48",
|
|
15
15
|
"@yuants/data-account": "0.11.8",
|
|
16
|
-
"@yuants/
|
|
16
|
+
"@yuants/protocol": "0.54.1",
|
|
17
17
|
"@yuants/data-ohlc": "0.6.4",
|
|
18
|
-
"@yuants/data-
|
|
18
|
+
"@yuants/data-trade": "0.1.31",
|
|
19
|
+
"@yuants/sql": "0.9.39",
|
|
19
20
|
"@yuants/utils": "0.19.4",
|
|
21
|
+
"@yuants/data-product": "0.5.9",
|
|
22
|
+
"@yuants/data-series": "0.3.61",
|
|
20
23
|
"@yuants/data-interest-rate": "0.2.8",
|
|
21
|
-
"@yuants/
|
|
22
|
-
"@yuants/
|
|
23
|
-
"@yuants/data-quote": "0.4.8",
|
|
24
|
-
"@yuants/data-series": "0.3.61"
|
|
24
|
+
"@yuants/exchange": "0.8.13",
|
|
25
|
+
"@yuants/data-quote": "0.4.8"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@microsoft/api-extractor": "~7.55.2",
|