@yuants/vendor-okx 0.16.9 → 0.17.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 (90) hide show
  1. package/dist/account.js +198 -0
  2. package/dist/account.js.map +1 -0
  3. package/dist/api.js +463 -0
  4. package/dist/api.js.map +1 -0
  5. package/dist/cli.js +3 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/cluster.js +80 -0
  8. package/dist/cluster.js.map +1 -0
  9. package/dist/extension.js +89 -0
  10. package/dist/extension.js.map +1 -0
  11. package/dist/index.js +7 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/interest_rate.js +133 -0
  14. package/dist/interest_rate.js.map +1 -0
  15. package/dist/legacy_index.js +554 -0
  16. package/dist/legacy_index.js.map +1 -0
  17. package/dist/logger.js +91 -0
  18. package/dist/logger.js.map +1 -0
  19. package/dist/ohlc.js +171 -0
  20. package/dist/ohlc.js.map +1 -0
  21. package/dist/order.js +96 -0
  22. package/dist/order.js.map +1 -0
  23. package/dist/product.js +85 -0
  24. package/dist/product.js.map +1 -0
  25. package/dist/quote.js +58 -0
  26. package/dist/quote.js.map +1 -0
  27. package/dist/vendor-okx.d.ts +1 -0
  28. package/dist/websocket.js +80 -0
  29. package/dist/websocket.js.map +1 -0
  30. package/lib/account.d.ts +102 -0
  31. package/lib/account.d.ts.map +1 -0
  32. package/lib/account.js +201 -0
  33. package/lib/account.js.map +1 -0
  34. package/lib/api.d.ts +1401 -0
  35. package/lib/api.d.ts.map +1 -0
  36. package/lib/api.js +470 -0
  37. package/lib/api.js.map +1 -0
  38. package/lib/cli.d.ts +3 -0
  39. package/lib/cli.d.ts.map +1 -0
  40. package/lib/cli.js +5 -0
  41. package/lib/cli.js.map +1 -0
  42. package/lib/cluster.d.ts +2 -0
  43. package/lib/cluster.d.ts.map +1 -0
  44. package/lib/cluster.js +108 -0
  45. package/lib/cluster.js.map +1 -0
  46. package/lib/extension.d.ts +4 -0
  47. package/lib/extension.d.ts.map +1 -0
  48. package/lib/extension.js +91 -0
  49. package/lib/extension.js.map +1 -0
  50. package/lib/index.d.ts +7 -0
  51. package/lib/index.d.ts.map +1 -0
  52. package/lib/index.js +9 -0
  53. package/lib/index.js.map +1 -0
  54. package/lib/interest_rate.d.ts +2 -0
  55. package/lib/interest_rate.d.ts.map +1 -0
  56. package/lib/interest_rate.js +135 -0
  57. package/lib/interest_rate.js.map +1 -0
  58. package/lib/legacy_index.d.ts +2 -0
  59. package/lib/legacy_index.d.ts.map +1 -0
  60. package/lib/legacy_index.js +556 -0
  61. package/lib/legacy_index.js.map +1 -0
  62. package/lib/logger.d.ts +21 -0
  63. package/lib/logger.d.ts.map +1 -0
  64. package/lib/logger.js +98 -0
  65. package/lib/logger.js.map +1 -0
  66. package/lib/ohlc.d.ts +2 -0
  67. package/lib/ohlc.d.ts.map +1 -0
  68. package/lib/ohlc.js +173 -0
  69. package/lib/ohlc.js.map +1 -0
  70. package/lib/order.d.ts +4 -0
  71. package/lib/order.d.ts.map +1 -0
  72. package/lib/order.js +99 -0
  73. package/lib/order.js.map +1 -0
  74. package/lib/product.d.ts +6 -0
  75. package/lib/product.d.ts.map +1 -0
  76. package/lib/product.js +88 -0
  77. package/lib/product.js.map +1 -0
  78. package/lib/quote.d.ts +42 -0
  79. package/lib/quote.d.ts.map +1 -0
  80. package/lib/quote.js +61 -0
  81. package/lib/quote.js.map +1 -0
  82. package/lib/websocket.d.ts +14 -0
  83. package/lib/websocket.d.ts.map +1 -0
  84. package/lib/websocket.js +83 -0
  85. package/lib/websocket.js.map +1 -0
  86. package/package.json +9 -4
  87. package/temp/image-tag +1 -0
  88. package/temp/package-deps.json +42 -0
  89. package/temp/vendor-okx.api.json +177 -0
  90. package/temp/vendor-okx.api.md +9 -0
@@ -0,0 +1,198 @@
1
+ import { addAccountMarket, publishAccountInfo, } from '@yuants/data-account';
2
+ import { Terminal } from '@yuants/protocol';
3
+ import { encodePath } from '@yuants/utils';
4
+ import { combineLatest, defer, filter, first, map, repeat, retry, shareReplay, withLatestFrom } from 'rxjs';
5
+ import { client } from './api';
6
+ import { mapProductIdToMarginProduct$, mapProductIdToUsdtSwapProduct$ } from './product';
7
+ const terminal = Terminal.fromNodeEnv();
8
+ export const accountPosition$ = defer(() => client.getAccountPositions({})).pipe(repeat({ delay: 5000 }), retry({ delay: 5000 }), shareReplay(1));
9
+ export const accountConfig$ = defer(() => client.getAccountConfig()).pipe(repeat({ delay: 10000 }), retry({ delay: 10000 }), shareReplay(1));
10
+ const subAccountUids$ = defer(() => client.getSubAccountList()).pipe(repeat({ delay: 10000 }), retry({ delay: 10000 }), shareReplay(1));
11
+ export const accountUid$ = accountConfig$.pipe(map((x) => x.data[0].uid), filter((x) => !!x), shareReplay(1));
12
+ const accountBalance$ = defer(() => client.getAccountBalance({})).pipe(repeat({ delay: 1000 }), retry({ delay: 5000 }), shareReplay(1));
13
+ const accountUsdtBalance$ = accountBalance$.pipe(map((x) => { var _a; return (_a = x.data[0]) === null || _a === void 0 ? void 0 : _a.details.find((x) => x.ccy === 'USDT'); }), filter((x) => !!x), shareReplay(1));
14
+ const pendingOrders$ = defer(() => client.getTradeOrdersPending({})).pipe(repeat({ delay: 1000 }), retry({ delay: 5000 }), shareReplay(1));
15
+ const marketIndexTickerUSDT$ = defer(() => client.getMarketIndexTicker({ quoteCcy: 'USDT' })).pipe(map((x) => {
16
+ const mapInstIdToPrice = new Map();
17
+ x.data.forEach((inst) => mapInstIdToPrice.set(inst.instId, Number(inst.idxPx)));
18
+ return mapInstIdToPrice;
19
+ }), repeat({ delay: 1000 }), retry({ delay: 5000 }), shareReplay(1));
20
+ export const tradingAccountInfo$ = accountPosition$.pipe(withLatestFrom(accountUid$, accountBalance$, pendingOrders$, mapProductIdToUsdtSwapProduct$, mapProductIdToMarginProduct$, marketIndexTickerUSDT$), map(([positionsApi, uid, balanceApi, orders, mapProductIdToUsdtSwapProduct, mapProductIdToMarginProduct, marketIndexTickerUSDT,]) => {
21
+ var _a;
22
+ const account_id = `okx/${uid}/trading`;
23
+ const money = { currency: 'USDT', equity: 0, balance: 0, used: 0, free: 0, profit: 0 };
24
+ const positions = [];
25
+ (_a = balanceApi.data[0]) === null || _a === void 0 ? void 0 : _a.details.forEach((detail) => {
26
+ var _a, _b, _c, _d, _e;
27
+ if (detail.ccy === 'USDT') {
28
+ const balance = +((_a = detail.cashBal) !== null && _a !== void 0 ? _a : 0);
29
+ const free = Math.min(balance, // free should no more than balance if there is much profits
30
+ +((_b = detail.availEq) !== null && _b !== void 0 ? _b : 0));
31
+ const equity = +((_c = detail.eq) !== null && _c !== void 0 ? _c : 0);
32
+ const used = equity - free;
33
+ const profit = equity - balance;
34
+ money.equity += equity;
35
+ money.balance += balance;
36
+ money.used += used;
37
+ money.free += free;
38
+ money.profit += profit;
39
+ }
40
+ else {
41
+ const volume = +((_d = detail.cashBal) !== null && _d !== void 0 ? _d : 0);
42
+ const free_volume = Math.min(volume, // free should no more than balance if there is much profits
43
+ +((_e = detail.availEq) !== null && _e !== void 0 ? _e : 0));
44
+ const closable_price = marketIndexTickerUSDT.get(detail.ccy + '-USDT') || 0;
45
+ const delta_equity = volume * closable_price || 0;
46
+ const delta_profit = +detail.totalPnl || 0;
47
+ const delta_balance = delta_equity - delta_profit;
48
+ const delta_used = delta_equity; // all used
49
+ const delta_free = 0;
50
+ const product_id = encodePath('SPOT', `${detail.ccy}-USDT`);
51
+ positions.push({
52
+ position_id: product_id,
53
+ datasource_id: 'OKX',
54
+ product_id: product_id,
55
+ direction: 'LONG',
56
+ volume: volume,
57
+ free_volume: free_volume,
58
+ position_price: +detail.accAvgPx,
59
+ floating_profit: delta_profit,
60
+ closable_price: closable_price,
61
+ valuation: delta_equity,
62
+ });
63
+ money.equity += delta_equity;
64
+ money.profit += delta_profit;
65
+ money.balance += delta_balance;
66
+ money.used += delta_used;
67
+ money.free += delta_free;
68
+ }
69
+ });
70
+ positionsApi.data.forEach((x) => {
71
+ var _a, _b, _c, _d;
72
+ const direction = x.posSide === 'long' ? 'LONG' : x.posSide === 'short' ? 'SHORT' : +x.pos > 0 ? 'LONG' : 'SHORT';
73
+ const volume = Math.abs(+x.pos);
74
+ const product_id = encodePath(x.instType, x.instId);
75
+ const closable_price = +x.last;
76
+ const valuation = x.instType === 'SWAP'
77
+ ? ((_b = (_a = mapProductIdToUsdtSwapProduct.get(product_id)) === null || _a === void 0 ? void 0 : _a.value_scale) !== null && _b !== void 0 ? _b : 1) * volume * closable_price
78
+ : x.instType === 'MARGIN'
79
+ ? ((_d = (_c = mapProductIdToMarginProduct.get(product_id)) === null || _c === void 0 ? void 0 : _c.value_scale) !== null && _d !== void 0 ? _d : 1) * volume * closable_price
80
+ : 0;
81
+ positions.push({
82
+ position_id: x.posId,
83
+ datasource_id: 'OKX',
84
+ product_id,
85
+ direction,
86
+ volume: volume,
87
+ free_volume: +x.availPos,
88
+ closable_price,
89
+ position_price: +x.avgPx,
90
+ floating_profit: +x.upl,
91
+ valuation,
92
+ });
93
+ });
94
+ return {
95
+ account_id: account_id,
96
+ updated_at: Date.now(),
97
+ money: money,
98
+ currencies: [money],
99
+ positions: positions,
100
+ orders: orders.data.map((x) => {
101
+ const order_type = x.ordType === 'market' ? 'MARKET' : x.ordType === 'limit' ? 'LIMIT' : 'UNKNOWN';
102
+ const order_direction = x.side === 'buy'
103
+ ? x.posSide === 'long'
104
+ ? 'OPEN_LONG'
105
+ : 'CLOSE_SHORT'
106
+ : x.posSide === 'short'
107
+ ? 'OPEN_SHORT'
108
+ : 'CLOSE_LONG';
109
+ return {
110
+ order_id: x.ordId,
111
+ account_id,
112
+ product_id: encodePath(x.instType, x.instId),
113
+ submit_at: +x.cTime,
114
+ filled_at: +x.fillTime,
115
+ order_type,
116
+ order_direction,
117
+ volume: +x.sz,
118
+ traded_volume: +x.accFillSz,
119
+ price: +x.px,
120
+ traded_price: +x.avgPx,
121
+ };
122
+ }),
123
+ };
124
+ }), shareReplay(1));
125
+ const sub = defer(() => accountUid$)
126
+ .pipe(first())
127
+ .subscribe((uid) => {
128
+ publishAccountInfo(terminal, `okx/${uid}/trading`, tradingAccountInfo$);
129
+ addAccountMarket(terminal, { account_id: `okx/${uid}/trading`, market_id: 'OKX' });
130
+ publishAccountInfo(terminal, `okx/${uid}/funding/USDT`, fundingAccountInfo$);
131
+ publishAccountInfo(terminal, `okx/${uid}/earning/USDT`, earningAccountInfo$);
132
+ });
133
+ defer(() => terminal.dispose$).subscribe(() => sub.unsubscribe());
134
+ const assetBalance$ = defer(() => client.getAssetBalances({})).pipe(repeat({ delay: 1000 }), retry({ delay: 5000 }), shareReplay(1));
135
+ const fundingAccountInfo$ = combineLatest([accountUid$, assetBalance$, marketIndexTickerUSDT$]).pipe(map(([uid, assetBalances, marketIndexTickerUSDT]) => {
136
+ const money = { currency: 'USDT', equity: 0, balance: 0, used: 0, free: 0, profit: 0 };
137
+ const positions = [];
138
+ assetBalances.data.forEach((x) => {
139
+ if (x.ccy === 'USDT') {
140
+ money.equity += +x.bal;
141
+ money.balance += +x.bal;
142
+ money.free += +x.bal;
143
+ }
144
+ else {
145
+ const price = marketIndexTickerUSDT.get(x.ccy + '-USDT') || 0;
146
+ const productId = encodePath('SPOT', `${x.ccy}-USDT`);
147
+ const valuation = price * +x.bal || 0;
148
+ positions.push({
149
+ datasource_id: 'OKX',
150
+ position_id: productId,
151
+ product_id: productId,
152
+ direction: 'LONG',
153
+ volume: +x.bal,
154
+ free_volume: +x.bal,
155
+ position_price: price,
156
+ floating_profit: 0,
157
+ closable_price: price,
158
+ valuation: valuation,
159
+ });
160
+ money.equity += valuation;
161
+ money.balance += valuation;
162
+ money.used += valuation;
163
+ }
164
+ });
165
+ return {
166
+ account_id: `okx/${uid}/funding/USDT`,
167
+ updated_at: Date.now(),
168
+ money: money,
169
+ currencies: [money],
170
+ positions: positions,
171
+ orders: [],
172
+ };
173
+ }), shareReplay(1));
174
+ const savingBalance$ = defer(() => client.getFinanceSavingsBalance({})).pipe(repeat({ delay: 5000 }), retry({ delay: 5000 }), shareReplay(1));
175
+ const earningAccountInfo$ = combineLatest([accountUid$, savingBalance$]).pipe(map(([uid, offers]) => {
176
+ const equity = offers.data.filter((x) => x.ccy === 'USDT').reduce((acc, x) => acc + +x.amt, 0);
177
+ const balance = equity;
178
+ const free = equity;
179
+ const used = 0;
180
+ const profit = 0;
181
+ const money = {
182
+ currency: 'USDT',
183
+ equity,
184
+ balance,
185
+ used,
186
+ free,
187
+ profit,
188
+ };
189
+ return {
190
+ account_id: `okx/${uid}/earning/USDT`,
191
+ updated_at: Date.now(),
192
+ money: money,
193
+ currencies: [money],
194
+ positions: [],
195
+ orders: [],
196
+ };
197
+ }), shareReplay(1));
198
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAIhB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAC5G,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,4BAA4B,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAEzF,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAC9E,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACvB,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,E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AK;QACZ,UAAU,EAAE,CAAC,KAAK,CAAC;QACnB,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC,CAAC,EACF,WAAW,CAAC,CAAC,CAAC,CACf,CAAC","sourcesContent":["import {\n addAccountMarket,\n IAccountInfo,\n IAccountMoney,\n IPosition,\n publishAccountInfo,\n} from '@yuants/data-account';\nimport { IOrder } from '@yuants/data-order';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { combineLatest, defer, filter, first, map, repeat, retry, shareReplay, withLatestFrom } from 'rxjs';\nimport { client } from './api';\nimport { mapProductIdToMarginProduct$, mapProductIdToUsdtSwapProduct$ } from './product';\n\nconst terminal = Terminal.fromNodeEnv();\n\nexport const accountPosition$ = defer(() => client.getAccountPositions({})).pipe(\n repeat({ delay: 5000 }),\n retry({ delay: 5000 }),\n shareReplay(1),\n);\n\nexport const accountConfig$ = defer(() => client.getAccountConfig()).pipe(\n repeat({ delay: 10_000 }),\n retry({ delay: 10_000 }),\n shareReplay(1),\n);\n\nconst subAccountUids$ = defer(() => client.getSubAccountList()).pipe(\n repeat({ delay: 10_000 }),\n retry({ delay: 10_000 }),\n shareReplay(1),\n);\n\nexport const accountUid$ = accountConfig$.pipe(\n map((x) => x.data[0].uid),\n filter((x) => !!x),\n shareReplay(1),\n);\n\nconst accountBalance$ = defer(() => client.getAccountBalance({})).pipe(\n repeat({ delay: 1000 }),\n retry({ delay: 5000 }),\n shareReplay(1),\n);\n\nconst accountUsdtBalance$ = accountBalance$.pipe(\n map((x) => x.data[0]?.details.find((x) => x.ccy === 'USDT')),\n filter((x): x is Exclude<typeof x, undefined> => !!x),\n shareReplay(1),\n);\n\nconst pendingOrders$ = defer(() => client.getTradeOrdersPending({})).pipe(\n repeat({ delay: 1000 }),\n retry({ delay: 5000 }),\n shareReplay(1),\n);\n\nconst marketIndexTickerUSDT$ = defer(() => client.getMarketIndexTicker({ quoteCcy: 'USDT' })).pipe(\n map((x) => {\n const mapInstIdToPrice = new Map<string, number>();\n x.data.forEach((inst) => mapInstIdToPrice.set(inst.instId, Number(inst.idxPx)));\n return mapInstIdToPrice;\n }),\n repeat({ delay: 1000 }),\n retry({ delay: 5000 }),\n shareReplay(1),\n);\n\nexport const tradingAccountInfo$ = accountPosition$.pipe(\n withLatestFrom(\n accountUid$,\n accountBalance$,\n pendingOrders$,\n mapProductIdToUsdtSwapProduct$,\n mapProductIdToMarginProduct$,\n marketIndexTickerUSDT$,\n ),\n map(\n ([\n positionsApi,\n uid,\n balanceApi,\n orders,\n mapProductIdToUsdtSwapProduct,\n mapProductIdToMarginProduct,\n marketIndexTickerUSDT,\n ]): IAccountInfo => {\n const account_id = `okx/${uid}/trading`;\n const money: IAccountMoney = { currency: 'USDT', equity: 0, balance: 0, used: 0, free: 0, profit: 0 };\n const positions: IPosition[] = [];\n\n balanceApi.data[0]?.details.forEach((detail) => {\n if (detail.ccy === 'USDT') {\n const balance = +(detail.cashBal ?? 0);\n const free = Math.min(\n balance, // free should no more than balance if there is much profits\n +(detail.availEq ?? 0),\n );\n const equity = +(detail.eq ?? 0);\n const used = equity - free;\n const profit = equity - balance;\n money.equity += equity;\n money.balance += balance;\n money.used += used;\n money.free += free;\n money.profit += profit;\n } else {\n const volume = +(detail.cashBal ?? 0);\n const free_volume = Math.min(\n volume, // free should no more than balance if there is much profits\n +(detail.availEq ?? 0),\n );\n const closable_price = marketIndexTickerUSDT.get(detail.ccy + '-USDT') || 0;\n const delta_equity = volume * closable_price || 0;\n const delta_profit = +detail.totalPnl || 0;\n const delta_balance = delta_equity - delta_profit;\n const delta_used = delta_equity; // all used\n const delta_free = 0;\n\n const product_id = encodePath('SPOT', `${detail.ccy}-USDT`);\n positions.push({\n position_id: product_id,\n datasource_id: 'OKX',\n product_id: product_id,\n direction: 'LONG',\n volume: volume,\n free_volume: free_volume,\n position_price: +detail.accAvgPx,\n floating_profit: delta_profit,\n closable_price: closable_price,\n valuation: delta_equity,\n });\n\n money.equity += delta_equity;\n money.profit += delta_profit;\n money.balance += delta_balance;\n money.used += delta_used;\n money.free += delta_free;\n }\n });\n positionsApi.data.forEach((x) => {\n const direction =\n x.posSide === 'long' ? 'LONG' : x.posSide === 'short' ? 'SHORT' : +x.pos > 0 ? 'LONG' : 'SHORT';\n const volume = Math.abs(+x.pos);\n const product_id = encodePath(x.instType, x.instId);\n const closable_price = +x.last;\n const valuation =\n x.instType === 'SWAP'\n ? (mapProductIdToUsdtSwapProduct.get(product_id)?.value_scale ?? 1) * volume * closable_price\n : x.instType === 'MARGIN'\n ? (mapProductIdToMarginProduct.get(product_id)?.value_scale ?? 1) * volume * closable_price\n : 0;\n\n positions.push({\n position_id: x.posId,\n datasource_id: 'OKX',\n product_id,\n direction,\n volume: volume,\n free_volume: +x.availPos,\n closable_price,\n position_price: +x.avgPx,\n floating_profit: +x.upl,\n valuation,\n });\n });\n return {\n account_id: account_id,\n updated_at: Date.now(),\n money: money,\n currencies: [money],\n positions: positions,\n orders: orders.data.map((x): IOrder => {\n const order_type = x.ordType === 'market' ? 'MARKET' : x.ordType === 'limit' ? 'LIMIT' : 'UNKNOWN';\n\n const order_direction =\n x.side === 'buy'\n ? x.posSide === 'long'\n ? 'OPEN_LONG'\n : 'CLOSE_SHORT'\n : x.posSide === 'short'\n ? 'OPEN_SHORT'\n : 'CLOSE_LONG';\n return {\n order_id: x.ordId,\n account_id,\n product_id: encodePath(x.instType, x.instId),\n submit_at: +x.cTime,\n filled_at: +x.fillTime,\n order_type,\n order_direction,\n volume: +x.sz,\n traded_volume: +x.accFillSz,\n price: +x.px,\n traded_price: +x.avgPx,\n };\n }),\n };\n },\n ),\n shareReplay(1),\n);\n\nconst sub = defer(() => accountUid$)\n .pipe(first())\n .subscribe((uid) => {\n publishAccountInfo(terminal, `okx/${uid}/trading`, tradingAccountInfo$);\n addAccountMarket(terminal, { account_id: `okx/${uid}/trading`, market_id: 'OKX' });\n publishAccountInfo(terminal, `okx/${uid}/funding/USDT`, fundingAccountInfo$);\n publishAccountInfo(terminal, `okx/${uid}/earning/USDT`, earningAccountInfo$);\n });\ndefer(() => terminal.dispose$).subscribe(() => sub.unsubscribe());\n\nconst assetBalance$ = defer(() => client.getAssetBalances({})).pipe(\n repeat({ delay: 1000 }),\n retry({ delay: 5000 }),\n shareReplay(1),\n);\n\nconst fundingAccountInfo$ = combineLatest([accountUid$, assetBalance$, marketIndexTickerUSDT$]).pipe(\n map(([uid, assetBalances, marketIndexTickerUSDT]): IAccountInfo => {\n const money: IAccountMoney = { currency: 'USDT', equity: 0, balance: 0, used: 0, free: 0, profit: 0 };\n const positions: IPosition[] = [];\n\n assetBalances.data.forEach((x) => {\n if (x.ccy === 'USDT') {\n money.equity += +x.bal;\n money.balance += +x.bal;\n money.free += +x.bal;\n } else {\n const price = marketIndexTickerUSDT.get(x.ccy + '-USDT') || 0;\n const productId = encodePath('SPOT', `${x.ccy}-USDT`);\n const valuation = price * +x.bal || 0;\n positions.push({\n datasource_id: 'OKX',\n position_id: productId,\n product_id: productId,\n direction: 'LONG',\n volume: +x.bal,\n free_volume: +x.bal,\n position_price: price,\n floating_profit: 0,\n closable_price: price,\n valuation: valuation,\n });\n\n money.equity += valuation;\n money.balance += valuation;\n money.used += valuation;\n }\n });\n\n return {\n account_id: `okx/${uid}/funding/USDT`,\n updated_at: Date.now(),\n money: money,\n currencies: [money],\n positions: positions,\n orders: [],\n };\n }),\n shareReplay(1),\n);\n\nconst savingBalance$ = defer(() => client.getFinanceSavingsBalance({})).pipe(\n repeat({ delay: 5000 }),\n retry({ delay: 5000 }),\n shareReplay(1),\n);\n\nconst earningAccountInfo$ = combineLatest([accountUid$, savingBalance$]).pipe(\n map(([uid, offers]): IAccountInfo => {\n const equity = offers.data.filter((x) => x.ccy === 'USDT').reduce((acc, x) => acc + +x.amt, 0);\n const balance = equity;\n const free = equity;\n const used = 0;\n const profit = 0;\n\n const money: IAccountMoney = {\n currency: 'USDT',\n equity,\n balance,\n used,\n free,\n profit,\n };\n return {\n account_id: `okx/${uid}/earning/USDT`,\n updated_at: Date.now(),\n money: money,\n currencies: [money],\n positions: [],\n orders: [],\n };\n }),\n shareReplay(1),\n);\n"]}