@yuants/vendor-okx 0.20.0 → 0.20.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.
@@ -13,6 +13,7 @@ defer(async () => {
13
13
  const positions = [];
14
14
  for (const loan of x.loanData) {
15
15
  positions.push({
16
+ datasource_id: 'OKX',
16
17
  product_id: `SPOT/${loan.ccy}-USDT`,
17
18
  volume: +loan.amt,
18
19
  free_volume: +loan.amt,
@@ -26,6 +27,7 @@ defer(async () => {
26
27
  }
27
28
  for (const collateral of x.collateralData) {
28
29
  positions.push({
30
+ datasource_id: 'OKX',
29
31
  product_id: `SPOT/${collateral.ccy}-USDT`,
30
32
  volume: +collateral.amt,
31
33
  free_volume: +collateral.amt,
@@ -1 +1 @@
1
- {"version":3,"file":"loan-account.js","sourceRoot":"","sources":["../src/loan-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,KAAK,CAAC,KAAK,IAAI,EAAE;IACf,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,OAAO,GAAG,YAAY,CAAC;IAE7C,kBAAkB,CAChB,QAAQ,CAAC,WAAW,EAAE,EACtB,aAAa,EACb,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;SACtC,IAAI,CACH,MAAM,CAAC,CAAC,CAAC,EAAE,EA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ACb,CAAC,CAAC;SACJ;QACD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC;QAC7D,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAChC,MAAM,IAAI,GAAG,OAAO,CAAC;QACrB,MAAM,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO;YACL,UAAU,EAAE,OAAO,GAAG,YAAY;YAClC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,KAAK,EAAE;gBACL,QAAQ,EAAE,MAAM;gBAChB,MAAM;gBACN,OAAO;gBACP,IAAI;gBACJ,IAAI;gBACJ,MAAM;aACP;YACD,SAAS;SACV,CAAC;IACJ,CAAC,CAAC,CACH,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC","sourcesContent":["import { IAccountInfo, IPosition, publishAccountInfo } from '@yuants/data-account';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { defer, filter, firstValueFrom, map, repeat, retry } from 'rxjs';\nimport { accountUid$ } from './account';\nimport { client } from './api';\n\ndefer(async () => {\n const uid = await firstValueFrom(accountUid$);\n const loanAccountId = `okx/${uid}/loan/USDT`;\n\n publishAccountInfo(\n Terminal.fromNodeEnv(),\n loanAccountId,\n defer(() => client.getFlexibleLoanInfo())\n .pipe(\n filter((x) => x.data && x.data.length > 0),\n map((x) => x.data[0]),\n retry({ delay: 1_000 }),\n repeat({ delay: 1_000 }),\n )\n .pipe(\n map((x): IAccountInfo => {\n const positions: IPosition[] = [];\n for (const loan of x.loanData) {\n positions.push({\n product_id: `SPOT/${loan.ccy}-USDT`,\n volume: +loan.amt,\n free_volume: +loan.amt,\n position_id: encodePath('loan', loan.ccy),\n direction: 'SHORT',\n position_price: 0,\n closable_price: 0,\n floating_profit: 0,\n valuation: 0,\n });\n }\n for (const collateral of x.collateralData) {\n positions.push({\n product_id: `SPOT/${collateral.ccy}-USDT`,\n volume: +collateral.amt,\n free_volume: +collateral.amt,\n position_id: encodePath('collateral', collateral.ccy),\n direction: 'LONG',\n position_price: 0,\n closable_price: 0,\n floating_profit: 0,\n valuation: 0,\n });\n }\n const equity = +x.collateralNotionalUsd - +x.loanNotionalUsd;\n const balance = +x.collateralNotionalUsd;\n const profit = equity - balance;\n const used = balance;\n const free = equity - used;\n return {\n account_id: `okx/${uid}/loan/USDT`,\n updated_at: Date.now(),\n money: {\n currency: 'USDT',\n equity,\n balance,\n used,\n free,\n profit,\n },\n positions,\n };\n }),\n ),\n );\n}).subscribe();\n"]}
1
+ {"version":3,"file":"loan-account.js","sourceRoot":"","sources":["../src/loan-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,KAAK,CAAC,KAAK,IAAI,EAAE;IACf,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,OAAO,GAAG,YAAY,CAAC;IAE7C,kBAAkB,CAChB,QAAQ,CAAC,WAAW,EAAE,EACtB,aAAa,EACb,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;SACtC,IAAI,CACH,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CA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,CAAC;aACb,CAAC,CAAC;SACJ;QACD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC;QAC7D,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAChC,MAAM,IAAI,GAAG,OAAO,CAAC;QACrB,MAAM,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO;YACL,UAAU,EAAE,OAAO,GAAG,YAAY;YAClC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,KAAK,EAAE;gBACL,QAAQ,EAAE,MAAM;gBAChB,MAAM;gBACN,OAAO;gBACP,IAAI;gBACJ,IAAI;gBACJ,MAAM;aACP;YACD,SAAS;SACV,CAAC;IACJ,CAAC,CAAC,CACH,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC","sourcesContent":["import { IAccountInfo, IPosition, publishAccountInfo } from '@yuants/data-account';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { defer, filter, firstValueFrom, map, repeat, retry } from 'rxjs';\nimport { accountUid$ } from './account';\nimport { client } from './api';\n\ndefer(async () => {\n const uid = await firstValueFrom(accountUid$);\n const loanAccountId = `okx/${uid}/loan/USDT`;\n\n publishAccountInfo(\n Terminal.fromNodeEnv(),\n loanAccountId,\n defer(() => client.getFlexibleLoanInfo())\n .pipe(\n filter((x) => x.data && x.data.length > 0),\n map((x) => x.data[0]),\n retry({ delay: 1_000 }),\n repeat({ delay: 1_000 }),\n )\n .pipe(\n map((x): IAccountInfo => {\n const positions: IPosition[] = [];\n for (const loan of x.loanData) {\n positions.push({\n datasource_id: 'OKX',\n product_id: `SPOT/${loan.ccy}-USDT`,\n volume: +loan.amt,\n free_volume: +loan.amt,\n position_id: encodePath('loan', loan.ccy),\n direction: 'SHORT',\n position_price: 0,\n closable_price: 0,\n floating_profit: 0,\n valuation: 0,\n });\n }\n for (const collateral of x.collateralData) {\n positions.push({\n datasource_id: 'OKX',\n product_id: `SPOT/${collateral.ccy}-USDT`,\n volume: +collateral.amt,\n free_volume: +collateral.amt,\n position_id: encodePath('collateral', collateral.ccy),\n direction: 'LONG',\n position_price: 0,\n closable_price: 0,\n floating_profit: 0,\n valuation: 0,\n });\n }\n const equity = +x.collateralNotionalUsd - +x.loanNotionalUsd;\n const balance = +x.collateralNotionalUsd;\n const profit = equity - balance;\n const used = balance;\n const free = equity - used;\n return {\n account_id: `okx/${uid}/loan/USDT`,\n updated_at: Date.now(),\n money: {\n currency: 'USDT',\n equity,\n balance,\n used,\n free,\n profit,\n },\n positions,\n };\n }),\n ),\n );\n}).subscribe();\n"]}
@@ -15,6 +15,7 @@ const api_1 = require("./api");
15
15
  const positions = [];
16
16
  for (const loan of x.loanData) {
17
17
  positions.push({
18
+ datasource_id: 'OKX',
18
19
  product_id: `SPOT/${loan.ccy}-USDT`,
19
20
  volume: +loan.amt,
20
21
  free_volume: +loan.amt,
@@ -28,6 +29,7 @@ const api_1 = require("./api");
28
29
  }
29
30
  for (const collateral of x.collateralData) {
30
31
  positions.push({
32
+ datasource_id: 'OKX',
31
33
  product_id: `SPOT/${collateral.ccy}-USDT`,
32
34
  volume: +collateral.amt,
33
35
  free_volume: +collateral.amt,
@@ -1 +1 @@
1
- {"version":3,"file":"loan-account.js","sourceRoot":"","sources":["../src/loan-account.ts"],"names":[],"mappings":";;AAAA,uDAAmF;AACnF,+CAA4C;AAC5C,yCAA2C;AAC3C,+BAAyE;AACzE,uCAAwC;AACxC,+BAA+B;AAE/B,IAAA,YAAK,EAAC,KAAK,IAAI,EAAE;IACf,MAAM,GAAG,GAAG,MAAM,IAAA,qBAAc,EAAC,qBAAW,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,OAAO,GAAG,YAAY,CAAC;IAE7C,IAAA,iCAAkB,EAChB,mBAAQ,CAAC,WAAW,EAAE,E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,kBAAU,EAAC,YAAY,EAAE,UAAU,CAAC,GAAG,CAAC;gBACrD,SAAS,EAAE,MAAM;gBACjB,cAAc,EAAE,CAAC;gBACjB,cAAc,EAAE,CAAC;gBACjB,eAAe,EAAE,CAAC;gBAClB,SAAS,EAAE,CAAC;aACb,CAAC,CAAC;SACJ;QACD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC;QAC7D,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAChC,MAAM,IAAI,GAAG,OAAO,CAAC;QACrB,MAAM,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO;YACL,UAAU,EAAE,OAAO,GAAG,YAAY;YAClC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,KAAK,EAAE;gBACL,QAAQ,EAAE,MAAM;gBAChB,MAAM;gBACN,OAAO;gBACP,IAAI;gBACJ,IAAI;gBACJ,MAAM;aACP;YACD,SAAS;SACV,CAAC;IACJ,CAAC,CAAC,CACH,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC","sourcesContent":["import { IAccountInfo, IPosition, publishAccountInfo } from '@yuants/data-account';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { defer, filter, firstValueFrom, map, repeat, retry } from 'rxjs';\nimport { accountUid$ } from './account';\nimport { client } from './api';\n\ndefer(async () => {\n const uid = await firstValueFrom(accountUid$);\n const loanAccountId = `okx/${uid}/loan/USDT`;\n\n publishAccountInfo(\n Terminal.fromNodeEnv(),\n loanAccountId,\n defer(() => client.getFlexibleLoanInfo())\n .pipe(\n filter((x) => x.data && x.data.length > 0),\n map((x) => x.data[0]),\n retry({ delay: 1_000 }),\n repeat({ delay: 1_000 }),\n )\n .pipe(\n map((x): IAccountInfo => {\n const positions: IPosition[] = [];\n for (const loan of x.loanData) {\n positions.push({\n product_id: `SPOT/${loan.ccy}-USDT`,\n volume: +loan.amt,\n free_volume: +loan.amt,\n position_id: encodePath('loan', loan.ccy),\n direction: 'SHORT',\n position_price: 0,\n closable_price: 0,\n floating_profit: 0,\n valuation: 0,\n });\n }\n for (const collateral of x.collateralData) {\n positions.push({\n product_id: `SPOT/${collateral.ccy}-USDT`,\n volume: +collateral.amt,\n free_volume: +collateral.amt,\n position_id: encodePath('collateral', collateral.ccy),\n direction: 'LONG',\n position_price: 0,\n closable_price: 0,\n floating_profit: 0,\n valuation: 0,\n });\n }\n const equity = +x.collateralNotionalUsd - +x.loanNotionalUsd;\n const balance = +x.collateralNotionalUsd;\n const profit = equity - balance;\n const used = balance;\n const free = equity - used;\n return {\n account_id: `okx/${uid}/loan/USDT`,\n updated_at: Date.now(),\n money: {\n currency: 'USDT',\n equity,\n balance,\n used,\n free,\n profit,\n },\n positions,\n };\n }),\n ),\n );\n}).subscribe();\n"]}
1
+ {"version":3,"file":"loan-account.js","sourceRoot":"","sources":["../src/loan-account.ts"],"names":[],"mappings":";;AAAA,uDAAmF;AACnF,+CAA4C;AAC5C,yCAA2C;AAC3C,+BAAyE;AACzE,uCAAwC;AACxC,+BAA+B;AAE/B,IAAA,YAAK,EAAC,KAAK,IAAI,EAAE;IACf,MAAM,GAAG,GAAG,MAAM,IAAA,qBAAc,EAAC,qBAAW,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,OAAO,GAAG,YAAY,CAAC;IAE7C,IAAA,iCAAkB,EAChB,mBAAQ,CAAC,WAAW,EAAE,EACtB,aAAa,EACb,IAAA,YAAK,EAAC,GAAG,EAAE,CAAC,YAAM,CAAC,mBAAmB,EAAE,CAAC;SACtC,IAAI,CACH,IAAA,aAAM,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAC1C,IAAA,UAAG,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AC;SACJ;QACD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC;QAC7D,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAChC,MAAM,IAAI,GAAG,OAAO,CAAC;QACrB,MAAM,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO;YACL,UAAU,EAAE,OAAO,GAAG,YAAY;YAClC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,KAAK,EAAE;gBACL,QAAQ,EAAE,MAAM;gBAChB,MAAM;gBACN,OAAO;gBACP,IAAI;gBACJ,IAAI;gBACJ,MAAM;aACP;YACD,SAAS;SACV,CAAC;IACJ,CAAC,CAAC,CACH,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC","sourcesContent":["import { IAccountInfo, IPosition, publishAccountInfo } from '@yuants/data-account';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { defer, filter, firstValueFrom, map, repeat, retry } from 'rxjs';\nimport { accountUid$ } from './account';\nimport { client } from './api';\n\ndefer(async () => {\n const uid = await firstValueFrom(accountUid$);\n const loanAccountId = `okx/${uid}/loan/USDT`;\n\n publishAccountInfo(\n Terminal.fromNodeEnv(),\n loanAccountId,\n defer(() => client.getFlexibleLoanInfo())\n .pipe(\n filter((x) => x.data && x.data.length > 0),\n map((x) => x.data[0]),\n retry({ delay: 1_000 }),\n repeat({ delay: 1_000 }),\n )\n .pipe(\n map((x): IAccountInfo => {\n const positions: IPosition[] = [];\n for (const loan of x.loanData) {\n positions.push({\n datasource_id: 'OKX',\n product_id: `SPOT/${loan.ccy}-USDT`,\n volume: +loan.amt,\n free_volume: +loan.amt,\n position_id: encodePath('loan', loan.ccy),\n direction: 'SHORT',\n position_price: 0,\n closable_price: 0,\n floating_profit: 0,\n valuation: 0,\n });\n }\n for (const collateral of x.collateralData) {\n positions.push({\n datasource_id: 'OKX',\n product_id: `SPOT/${collateral.ccy}-USDT`,\n volume: +collateral.amt,\n free_volume: +collateral.amt,\n position_id: encodePath('collateral', collateral.ccy),\n direction: 'LONG',\n position_price: 0,\n closable_price: 0,\n floating_profit: 0,\n valuation: 0,\n });\n }\n const equity = +x.collateralNotionalUsd - +x.loanNotionalUsd;\n const balance = +x.collateralNotionalUsd;\n const profit = equity - balance;\n const used = balance;\n const free = equity - used;\n return {\n account_id: `okx/${uid}/loan/USDT`,\n updated_at: Date.now(),\n money: {\n currency: 'USDT',\n equity,\n balance,\n used,\n free,\n profit,\n },\n positions,\n };\n }),\n ),\n );\n}).subscribe();\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuants/vendor-okx",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "bin": "lib/cli.js",
5
5
  "main": "lib/index.js",
6
6
  "files": [
package/temp/image-tag CHANGED
@@ -1 +1 @@
1
- sha-b1dae972749f07bc0fba92a8e9f5d26d331a65e8
1
+ sha-9f6871e5ca3d550227e8da0403db8218b8871d24
@@ -1,6 +1,6 @@
1
1
  {
2
- "apps/vendor-okx/CHANGELOG.json": "31164cc505d0231b02b948b79286229771438a22",
3
- "apps/vendor-okx/CHANGELOG.md": "4c54223a78231a9103a29d5d64c80f83dd418116",
2
+ "apps/vendor-okx/CHANGELOG.json": "efb8d4b79a2ab6efb63fb6a91796f95e507dbe0d",
3
+ "apps/vendor-okx/CHANGELOG.md": "b569bb21652ed21ff5c9cce7bea05f375a385865",
4
4
  "apps/vendor-okx/README.md": "ac3d1f6c4c8d73066664699b0bb1b01db02e67a2",
5
5
  "apps/vendor-okx/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
6
6
  "apps/vendor-okx/build/Dockerfile": "e625b9593e496c343297c9ce133d6cc4be9617a7",
@@ -8,7 +8,7 @@
8
8
  "apps/vendor-okx/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
9
9
  "apps/vendor-okx/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
10
10
  "apps/vendor-okx/etc/vendor-okx.api.md": "92c54ccd547d2ad81ca6088158ca193e85c208df",
11
- "apps/vendor-okx/package.json": "9cebb93d60bbf21f4bc010efaa8cadb5df8bab04",
11
+ "apps/vendor-okx/package.json": "eb72a23f9643832f8fbd7ef721e6fd477e21f672",
12
12
  "apps/vendor-okx/src/account.ts": "7e8bb44845269a401a850aff2e5bf170b0811bd8",
13
13
  "apps/vendor-okx/src/api.ts": "ffcb8471e644c24089b266c88a83224abe177c6a",
14
14
  "apps/vendor-okx/src/cli.ts": "9bf6b5559a6c6f33da20e74cc6c5d702c60ec891",
@@ -17,7 +17,7 @@
17
17
  "apps/vendor-okx/src/index.ts": "d01657b1e1a8168edc88768599a2d92f97d6e439",
18
18
  "apps/vendor-okx/src/interest_rate.ts": "f5ee44bf6b92a484dccc57863c47a7101a78e793",
19
19
  "apps/vendor-okx/src/legacy_index.ts": "1bf031b9f8f870a099d74867292b257346344e4d",
20
- "apps/vendor-okx/src/loan-account.ts": "b0fb41ac3d7ac1d48592e41c81ee859f17a52675",
20
+ "apps/vendor-okx/src/loan-account.ts": "5e7662b41b90ba307ce1e5689b3613e84ff9ab0b",
21
21
  "apps/vendor-okx/src/logger.ts": "d25d427e74f46819a601e0cb17d5358b22c8db7b",
22
22
  "apps/vendor-okx/src/ohlc.ts": "31f7d72513dc32a31938313e79c7e75b0964906c",
23
23
  "apps/vendor-okx/src/order.ts": "09509ae5af4b212cc1c99c55c436b3b0ce8bda33",