@yuants/vendor-coinex 0.2.14 → 0.2.16

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.
@@ -11,10 +11,11 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
11
11
  function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
12
12
  };
13
13
  import { createSeriesProvider } from '@yuants/data-series';
14
+ import { Terminal } from '@yuants/protocol';
14
15
  import { decodePath, formatTime } from '@yuants/utils';
15
16
  import { firstValueFrom, timer } from 'rxjs';
16
17
  import { client } from './api';
17
- import { terminal } from './terminal';
18
+ const terminal = Terminal.fromNodeEnv();
18
19
  createSeriesProvider(terminal, {
19
20
  tableName: 'interest_rate',
20
21
  series_id_prefix_parts: ['coinex'],
@@ -1 +1 @@
1
- {"version":3,"file":"interest_rate.js","sourceRoot":"","sources":["../src/interest_rate.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,oBAAoB,CAAgB,QAAQ,EAAE;IAC5C,SAAS,EAAE,eAAe;IAC1B,sBAAsB,EAAE,CAAC,QAAQ,CAAC;IAClC,QAAQ,EAAE,IAAI;IACd,cAAc,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;IACjC,OAAO,EAAE,UAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE;;YAC3D,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;YAC1D,MAAM,CAAC,QAAQ,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';\nimport { createSeriesProvider } from '@yuants/data-series';\nimport { decodePath, formatTime } from '@yuants/utils';\nimport { firstValueFrom, timer } from 'rxjs';\nimport { client } from './api';\nimport { terminal } from './terminal';\n\ncreateSeriesProvider<IInterestRate>(terminal, {\n tableName: 'interest_rate',\n series_id_prefix_parts: ['coinex'],\n reversed: true,\n serviceOptions: { concurrent: 1 },\n queryFn: async function* ({ series_id, started_at, ended_at }) {\n const [datasource_id, product_id] = decodePath(series_id);\n const [instType, instId] = decodePath(product_id);\n let current_page = 0;\n\n while (true) {\n const res = await client.getFuturesFundingRateHistory({\n market: instId,\n start_time: started_at,\n end_time: ended_at,\n page: current_page,\n limit: 100,\n });\n if (res.code !== 0) {\n throw `API failed: ${res.code} ${res.message}`;\n }\n if (res.data.length === 0) break;\n\n yield res.data.map(\n (v): IInterestRate => ({\n series_id,\n datasource_id,\n product_id,\n created_at: formatTime(+v.funding_time),\n long_rate: `${-v.actual_funding_rate}`,\n short_rate: `${v.actual_funding_rate}`,\n settlement_price: '',\n }),\n );\n if (!res.pagination.has_next) break;\n if (+res.data[res.data.length - 1].funding_time <= started_at) break;\n current_page++;\n await firstValueFrom(timer(1000));\n }\n },\n});\n"]}
1
+ {"version":3,"file":"interest_rate.js","sourceRoot":"","sources":["../src/interest_rate.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,oBAAoB,CAAgB,QAAQ,EAAE;IAC5C,SAAS,EAAE,eAAe;IAC1B,sBAA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AAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,UAAU;oBAAE,MAAM;gBACrE,YAAY,EAAE,CAAC;gBACf,cAAM,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA,CAAC;aACnC;QACH,CAAC;KAAA;CACF,CAAC,CAAC","sourcesContent":["import { IInterestRate } from '@yuants/data-interest-rate';\nimport { createSeriesProvider } from '@yuants/data-series';\nimport { Terminal } from '@yuants/protocol';\nimport { decodePath, formatTime } from '@yuants/utils';\nimport { firstValueFrom, timer } from 'rxjs';\nimport { client } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\ncreateSeriesProvider<IInterestRate>(terminal, {\n tableName: 'interest_rate',\n series_id_prefix_parts: ['coinex'],\n reversed: true,\n serviceOptions: { concurrent: 1 },\n queryFn: async function* ({ series_id, started_at, ended_at }) {\n const [datasource_id, product_id] = decodePath(series_id);\n const [instType, instId] = decodePath(product_id);\n let current_page = 0;\n\n while (true) {\n const res = await client.getFuturesFundingRateHistory({\n market: instId,\n start_time: started_at,\n end_time: ended_at,\n page: current_page,\n limit: 100,\n });\n if (res.code !== 0) {\n throw `API failed: ${res.code} ${res.message}`;\n }\n if (res.data.length === 0) break;\n\n yield res.data.map(\n (v): IInterestRate => ({\n series_id,\n datasource_id,\n product_id,\n created_at: formatTime(+v.funding_time),\n long_rate: `${-v.actual_funding_rate}`,\n short_rate: `${v.actual_funding_rate}`,\n settlement_price: '',\n }),\n );\n if (!res.pagination.has_next) break;\n if (+res.data[res.data.length - 1].funding_time <= started_at) break;\n current_page++;\n await firstValueFrom(timer(1000));\n }\n },\n});\n"]}
package/dist/product.js CHANGED
@@ -1,8 +1,9 @@
1
+ import { Terminal } from '@yuants/protocol';
1
2
  import { createSQLWriter } from '@yuants/sql';
2
3
  import { encodePath, formatTime } from '@yuants/utils';
3
4
  import { defer, from, map, mergeMap, repeat, retry, shareReplay, Subject, tap, toArray } from 'rxjs';
4
5
  import { client } from './api';
5
- import { terminal } from './terminal';
6
+ const terminal = Terminal.fromNodeEnv();
6
7
  const product$ = new Subject();
7
8
  export const mapSymbolToMarket$ = defer(async () => {
8
9
  const res = await client.getFuturesMarket();
@@ -1 +1 @@
1
- {"version":3,"file":"product.js","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAY,CAAC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE;IACjD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC5C,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;KAC9B;IACD,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,EAAE,KAAK,EAAE,IAAK,EAAE,CAAC,EACxB,KAAK,CAAC,EAAE,KAAK,EAAE,KAAM,EAAE,CAAC,EACxB,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CACb,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,C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ACxC,CAAC,CAAC,EACF,GAAG,CAAC;IACF,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;QACX,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF,CAAC,EACF,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EACtB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAS,EAAE,CAAC,EAC5B,WAAW,CAAC,CAAC,CAAC,CACf,CAAC;AAEF,eAAe,CAAW,QAAQ,EAAE;IAClC,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,QAAQ;IACf,aAAa,EAAE,IAAI;IACnB,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;CAC9C,CAAC,CAAC;AAEH,gBAAgB,CAAC,SAAS,EAAE,CAAC;AAE7B,MAAM,6BAA6B,GAAG,gBAAgB,CAAC,IAAI;AACzD,EAAE;AACF,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAClE,WAAW,CAAC,CAAC,CAAC,CACf,CAAC","sourcesContent":["import { IProduct } from '@yuants/data-product';\nimport { createSQLWriter } from '@yuants/sql';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, from, map, mergeMap, repeat, retry, shareReplay, Subject, tap, toArray } from 'rxjs';\nimport { client } from './api';\nimport { terminal } from './terminal';\n\nconst product$ = new Subject<IProduct>();\n\nexport const mapSymbolToMarket$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n return res.data;\n}).pipe(\n repeat({ delay: 1_000 }),\n retry({ delay: 30_000 }),\n mergeMap((x) =>\n from(x).pipe(\n map((v) => [v.market, v] as const),\n toArray(),\n map((v) => new Map(v)),\n ),\n ),\n shareReplay(1),\n);\n\nconst futuresProducts$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n\n const futures = res.data.map(\n (item): IProduct => ({\n datasource_id: 'COINEX',\n product_id: encodePath('SWAP', item.market),\n quote_currency: item.quote_ccy,\n base_currency: item.base_ccy,\n price_step: Number(item.quote_ccy_precision),\n // FIXME: volume_step, value_scale\n volume_step: 1,\n value_scale: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n }),\n );\n return futures;\n}).pipe(\n tap((list) => {\n list.forEach((v) => product$.next(v));\n }),\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'FuturesProducts', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 86400_000 }),\n shareReplay(1),\n);\n\ncreateSQLWriter<IProduct>(terminal, {\n tableName: 'product',\n data$: product$,\n writeInterval: 1000,\n conflictKeys: ['datasource_id', 'product_id'],\n});\n\nfuturesProducts$.subscribe();\n\nconst mapProductIdToFuturesProduct$ = futuresProducts$.pipe(\n //\n map((products) => new Map(products.map((v) => [v.product_id, v]))),\n shareReplay(1),\n);\n"]}
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrG,OAAO,E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C;CAC9C,CAAC,CAAC;AAEH,gBAAgB,CAAC,SAAS,EAAE,CAAC;AAE7B,MAAM,6BAA6B,GAAG,gBAAgB,CAAC,IAAI;AACzD,EAAE;AACF,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAClE,WAAW,CAAC,CAAC,CAAC,CACf,CAAC","sourcesContent":["import { IProduct } from '@yuants/data-product';\nimport { Terminal } from '@yuants/protocol';\nimport { createSQLWriter } from '@yuants/sql';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, from, map, mergeMap, repeat, retry, shareReplay, Subject, tap, toArray } from 'rxjs';\nimport { client } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst product$ = new Subject<IProduct>();\n\nexport const mapSymbolToMarket$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n return res.data;\n}).pipe(\n repeat({ delay: 1_000 }),\n retry({ delay: 30_000 }),\n mergeMap((x) =>\n from(x).pipe(\n map((v) => [v.market, v] as const),\n toArray(),\n map((v) => new Map(v)),\n ),\n ),\n shareReplay(1),\n);\n\nconst futuresProducts$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n\n const futures = res.data.map(\n (item): IProduct => ({\n datasource_id: 'COINEX',\n product_id: encodePath('SWAP', item.market),\n quote_currency: item.quote_ccy,\n base_currency: item.base_ccy,\n price_step: Number(item.quote_ccy_precision),\n // FIXME: volume_step, value_scale\n volume_step: 1,\n value_scale: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n }),\n );\n return futures;\n}).pipe(\n tap((list) => {\n list.forEach((v) => product$.next(v));\n }),\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'FuturesProducts', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 86400_000 }),\n shareReplay(1),\n);\n\ncreateSQLWriter<IProduct>(terminal, {\n tableName: 'product',\n data$: product$,\n writeInterval: 1000,\n conflictKeys: ['datasource_id', 'product_id'],\n});\n\nfuturesProducts$.subscribe();\n\nconst mapProductIdToFuturesProduct$ = futuresProducts$.pipe(\n //\n map((products) => new Map(products.map((v) => [v.product_id, v]))),\n shareReplay(1),\n);\n"]}
@@ -13,11 +13,12 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const data_series_1 = require("@yuants/data-series");
16
+ const protocol_1 = require("@yuants/protocol");
16
17
  const utils_1 = require("@yuants/utils");
17
18
  const rxjs_1 = require("rxjs");
18
19
  const api_1 = require("./api");
19
- const terminal_1 = require("./terminal");
20
- (0, data_series_1.createSeriesProvider)(terminal_1.terminal, {
20
+ const terminal = protocol_1.Terminal.fromNodeEnv();
21
+ (0, data_series_1.createSeriesProvider)(terminal, {
21
22
  tableName: 'interest_rate',
22
23
  series_id_prefix_parts: ['coinex'],
23
24
  reversed: true,
@@ -1 +1 @@
1
- {"version":3,"file":"interest_rate.js","sourceRoot":"","sources":["../src/interest_rate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,qDAA2D;AAC3D,yCAAuD;AACvD,+BAA6C;AAC7C,+BAA+B;AAC/B,yCAAsC;AAEtC,IAAA,kCAAoB,EAAgB,mBAAQ,EAAE;IAC5C,SAAS,EAAE,eAAe;IAC1B,sBAAsB,EAAE,CAAC,QAAQ,CAAC;IAClC,QAAQ,EAAE,IAAI;IACd,cAAc,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;IACjC,OAAO,EAAE,UAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE;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AA,qBAAc,EAAC,IAAA,YAAK,EAAC,IAAI,CAAC,CAAC,CAAA,CAAC;aACnC;QACH,CAAC;KAAA;CACF,CAAC,CAAC","sourcesContent":["import { IInterestRate } from '@yuants/data-interest-rate';\nimport { createSeriesProvider } from '@yuants/data-series';\nimport { decodePath, formatTime } from '@yuants/utils';\nimport { firstValueFrom, timer } from 'rxjs';\nimport { client } from './api';\nimport { terminal } from './terminal';\n\ncreateSeriesProvider<IInterestRate>(terminal, {\n tableName: 'interest_rate',\n series_id_prefix_parts: ['coinex'],\n reversed: true,\n serviceOptions: { concurrent: 1 },\n queryFn: async function* ({ series_id, started_at, ended_at }) {\n const [datasource_id, product_id] = decodePath(series_id);\n const [instType, instId] = decodePath(product_id);\n let current_page = 0;\n\n while (true) {\n const res = await client.getFuturesFundingRateHistory({\n market: instId,\n start_time: started_at,\n end_time: ended_at,\n page: current_page,\n limit: 100,\n });\n if (res.code !== 0) {\n throw `API failed: ${res.code} ${res.message}`;\n }\n if (res.data.length === 0) break;\n\n yield res.data.map(\n (v): IInterestRate => ({\n series_id,\n datasource_id,\n product_id,\n created_at: formatTime(+v.funding_time),\n long_rate: `${-v.actual_funding_rate}`,\n short_rate: `${v.actual_funding_rate}`,\n settlement_price: '',\n }),\n );\n if (!res.pagination.has_next) break;\n if (+res.data[res.data.length - 1].funding_time <= started_at) break;\n current_page++;\n await firstValueFrom(timer(1000));\n }\n },\n});\n"]}
1
+ {"version":3,"file":"interest_rate.js","sourceRoot":"","sources":["../src/interest_rate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,qDAA2D;AAC3D,+CAA4C;AAC5C,yCAAuD;AACvD,+BAA6C;AAC7C,+BAA+B;AAE/B,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,IAAA,kCAAoB,EAAgB,QAAQ,EAAE;IAC5C,SAAS,EAAE,eAAe;IAC1B,sBAAsB,EAAE,CAAC,QAAQ,CAAC;IAClC,QAAQ,EAAE,I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,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,UAAU;oBAAE,MAAM;gBACrE,YAAY,EAAE,CAAC;gBACf,cAAM,IAAA,qBAAc,EAAC,IAAA,YAAK,EAAC,IAAI,CAAC,CAAC,CAAA,CAAC;aACnC;QACH,CAAC;KAAA;CACF,CAAC,CAAC","sourcesContent":["import { IInterestRate } from '@yuants/data-interest-rate';\nimport { createSeriesProvider } from '@yuants/data-series';\nimport { Terminal } from '@yuants/protocol';\nimport { decodePath, formatTime } from '@yuants/utils';\nimport { firstValueFrom, timer } from 'rxjs';\nimport { client } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\ncreateSeriesProvider<IInterestRate>(terminal, {\n tableName: 'interest_rate',\n series_id_prefix_parts: ['coinex'],\n reversed: true,\n serviceOptions: { concurrent: 1 },\n queryFn: async function* ({ series_id, started_at, ended_at }) {\n const [datasource_id, product_id] = decodePath(series_id);\n const [instType, instId] = decodePath(product_id);\n let current_page = 0;\n\n while (true) {\n const res = await client.getFuturesFundingRateHistory({\n market: instId,\n start_time: started_at,\n end_time: ended_at,\n page: current_page,\n limit: 100,\n });\n if (res.code !== 0) {\n throw `API failed: ${res.code} ${res.message}`;\n }\n if (res.data.length === 0) break;\n\n yield res.data.map(\n (v): IInterestRate => ({\n series_id,\n datasource_id,\n product_id,\n created_at: formatTime(+v.funding_time),\n long_rate: `${-v.actual_funding_rate}`,\n short_rate: `${v.actual_funding_rate}`,\n settlement_price: '',\n }),\n );\n if (!res.pagination.has_next) break;\n if (+res.data[res.data.length - 1].funding_time <= started_at) break;\n current_page++;\n await firstValueFrom(timer(1000));\n }\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;GAiB9B,CAAC"}
1
+ {"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;GAiB9B,CAAC"}
package/lib/product.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapSymbolToMarket$ = void 0;
4
+ const protocol_1 = require("@yuants/protocol");
4
5
  const sql_1 = require("@yuants/sql");
5
6
  const utils_1 = require("@yuants/utils");
6
7
  const rxjs_1 = require("rxjs");
7
8
  const api_1 = require("./api");
8
- const terminal_1 = require("./terminal");
9
+ const terminal = protocol_1.Terminal.fromNodeEnv();
9
10
  const product$ = new rxjs_1.Subject();
10
11
  exports.mapSymbolToMarket$ = (0, rxjs_1.defer)(async () => {
11
12
  const res = await api_1.client.getFuturesMarket();
@@ -46,7 +47,7 @@ const futuresProducts$ = (0, rxjs_1.defer)(async () => {
46
47
  console.error((0, utils_1.formatTime)(Date.now()), 'FuturesProducts', e);
47
48
  },
48
49
  }), (0, rxjs_1.retry)({ delay: 5000 }), (0, rxjs_1.repeat)({ delay: 86400000 }), (0, rxjs_1.shareReplay)(1));
49
- (0, sql_1.createSQLWriter)(terminal_1.terminal, {
50
+ (0, sql_1.createSQLWriter)(terminal, {
50
51
  tableName: 'product',
51
52
  data$: product$,
52
53
  writeInterval: 1000,
@@ -1 +1 @@
1
- {"version":3,"file":"product.js","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":";;;AACA,qCAA8C;AAC9C,yCAAuD;AACvD,+BAAqG;AACrG,+BAA+B;AAC/B,yCAAsC;AAEtC,MAAM,QAAQ,GAAG,IAAI,cAAO,EAAY,CAAC;AAE5B,QAAA,kBAAkB,GAAG,IAAA,YAAK,EAAC,KAAK,IAAI,EAAE;IACjD,MAAM,GAAG,GAAG,MAAM,YAAM,CAAC,gBAAgB,EAAE,CAAC;IAC5C,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,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AU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAClE,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC","sourcesContent":["import { IProduct } from '@yuants/data-product';\nimport { createSQLWriter } from '@yuants/sql';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, from, map, mergeMap, repeat, retry, shareReplay, Subject, tap, toArray } from 'rxjs';\nimport { client } from './api';\nimport { terminal } from './terminal';\n\nconst product$ = new Subject<IProduct>();\n\nexport const mapSymbolToMarket$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n return res.data;\n}).pipe(\n repeat({ delay: 1_000 }),\n retry({ delay: 30_000 }),\n mergeMap((x) =>\n from(x).pipe(\n map((v) => [v.market, v] as const),\n toArray(),\n map((v) => new Map(v)),\n ),\n ),\n shareReplay(1),\n);\n\nconst futuresProducts$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n\n const futures = res.data.map(\n (item): IProduct => ({\n datasource_id: 'COINEX',\n product_id: encodePath('SWAP', item.market),\n quote_currency: item.quote_ccy,\n base_currency: item.base_ccy,\n price_step: Number(item.quote_ccy_precision),\n // FIXME: volume_step, value_scale\n volume_step: 1,\n value_scale: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n }),\n );\n return futures;\n}).pipe(\n tap((list) => {\n list.forEach((v) => product$.next(v));\n }),\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'FuturesProducts', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 86400_000 }),\n shareReplay(1),\n);\n\ncreateSQLWriter<IProduct>(terminal, {\n tableName: 'product',\n data$: product$,\n writeInterval: 1000,\n conflictKeys: ['datasource_id', 'product_id'],\n});\n\nfuturesProducts$.subscribe();\n\nconst mapProductIdToFuturesProduct$ = futuresProducts$.pipe(\n //\n map((products) => new Map(products.map((v) => [v.product_id, v]))),\n shareReplay(1),\n);\n"]}
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../src/product.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAC5C,qCAA8C;AAC9C,yCAAuD;AACvD,+BAAqG;AACrG,+BAA+B;AAE/B,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MAAM,QAAQ,GAAG,IAAI,cAAO,EAAY,CAAC;AAE5B,QAAA,kBAAkB,GAAG,IAAA,YAAK,EAAC,KAAK,IAAI,EAAE;IACjD,MAAM,GAAG,GAAG,MAAM,YAAM,CAAC,gBAAgB,EAAE,CAAC;IAC5C,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;KAC9B;IACD,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC,CAAC,CAAC,IAAI,CACL,IAAA,aAAM,EAAC,EAAE,KAAK,EAAE,IAAK,EAAE,CAAC,EACxB,IAAA,YAAK,EAAC,EAAE,KAAK,EAAE,KAAM,EAAE,CAAC,EACxB,IAAA,eAAQ,EAAC,CAAC,CAAC,EAAE,EAAE,CACb,IAAA,WAAI,EAAC,CAAC,CAAC,CAAC,IAAI,CACV,IAAA,UAAG,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAU,CAAC,EAClC,IAAA,cAAO,GAAE,EACT,IAAA,UAAG,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CACvB,CACF,EACD,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;AAEF,MAAM,gBAAgB,GAAG,IAAA,YAAK,EAAC,KAAK,IAAI,EAAE;IACxC,MAAM,GAAG,GAAG,MAAM,YAAM,CAAC,gBAAgB,E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AAI,EAAE,CAAC,EACtB,IAAA,aAAM,EAAC,EAAE,KAAK,EAAE,QAAS,EAAE,CAAC,EAC5B,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;AAEF,IAAA,qBAAe,EAAW,QAAQ,EAAE;IAClC,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,QAAQ;IACf,aAAa,EAAE,IAAI;IACnB,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;CAC9C,CAAC,CAAC;AAEH,gBAAgB,CAAC,SAAS,EAAE,CAAC;AAE7B,MAAM,6BAA6B,GAAG,gBAAgB,CAAC,IAAI;AACzD,EAAE;AACF,IAAA,UAAG,EAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAClE,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC","sourcesContent":["import { IProduct } from '@yuants/data-product';\nimport { Terminal } from '@yuants/protocol';\nimport { createSQLWriter } from '@yuants/sql';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { defer, from, map, mergeMap, repeat, retry, shareReplay, Subject, tap, toArray } from 'rxjs';\nimport { client } from './api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst product$ = new Subject<IProduct>();\n\nexport const mapSymbolToMarket$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n return res.data;\n}).pipe(\n repeat({ delay: 1_000 }),\n retry({ delay: 30_000 }),\n mergeMap((x) =>\n from(x).pipe(\n map((v) => [v.market, v] as const),\n toArray(),\n map((v) => new Map(v)),\n ),\n ),\n shareReplay(1),\n);\n\nconst futuresProducts$ = defer(async () => {\n const res = await client.getFuturesMarket();\n if (res.code !== 0) {\n throw new Error(res.message);\n }\n\n const futures = res.data.map(\n (item): IProduct => ({\n datasource_id: 'COINEX',\n product_id: encodePath('SWAP', item.market),\n quote_currency: item.quote_ccy,\n base_currency: item.base_ccy,\n price_step: Number(item.quote_ccy_precision),\n // FIXME: volume_step, value_scale\n volume_step: 1,\n value_scale: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 0,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n }),\n );\n return futures;\n}).pipe(\n tap((list) => {\n list.forEach((v) => product$.next(v));\n }),\n tap({\n error: (e) => {\n console.error(formatTime(Date.now()), 'FuturesProducts', e);\n },\n }),\n retry({ delay: 5000 }),\n repeat({ delay: 86400_000 }),\n shareReplay(1),\n);\n\ncreateSQLWriter<IProduct>(terminal, {\n tableName: 'product',\n data$: product$,\n writeInterval: 1000,\n conflictKeys: ['datasource_id', 'product_id'],\n});\n\nfuturesProducts$.subscribe();\n\nconst mapProductIdToFuturesProduct$ = futuresProducts$.pipe(\n //\n map((products) => new Map(products.map((v) => [v.product_id, v]))),\n shareReplay(1),\n);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuants/vendor-coinex",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "main": "lib/index.js",
5
5
  "bin": "lib/cli.js",
6
6
  "module": "dist/index.js",
@@ -10,13 +10,13 @@
10
10
  "temp"
11
11
  ],
12
12
  "dependencies": {
13
- "@yuants/protocol": "0.44.0",
14
- "@yuants/transfer": "0.2.16",
13
+ "@yuants/protocol": "0.45.0",
14
+ "@yuants/transfer": "0.2.17",
15
15
  "@yuants/utils": "0.8.0",
16
- "@yuants/sql": "0.9.7",
17
- "@yuants/data-series": "0.3.28",
18
- "@yuants/data-product": "0.2.17",
19
- "@yuants/data-interest-rate": "0.1.25",
16
+ "@yuants/sql": "0.9.8",
17
+ "@yuants/data-series": "0.3.29",
18
+ "@yuants/data-product": "0.3.0",
19
+ "@yuants/data-interest-rate": "0.1.26",
20
20
  "rxjs": "~7.5.6",
21
21
  "crypto-js": "^4.2.0"
22
22
  },
@@ -1,27 +1,26 @@
1
1
  {
2
- "apps/vendor-coinex/CHANGELOG.json": "619117d16eca5bb89e30039ee6270013f3dcfe06",
3
- "apps/vendor-coinex/CHANGELOG.md": "ece6459c844d29d7a8c40b7533739dda2ec633bb",
2
+ "apps/vendor-coinex/CHANGELOG.json": "2fae473c5be30cf8ffaa2d38e48d36bf58bbfd82",
3
+ "apps/vendor-coinex/CHANGELOG.md": "826113317cb8baafc86f4d3b3b7e38611efaee28",
4
4
  "apps/vendor-coinex/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
5
5
  "apps/vendor-coinex/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
6
6
  "apps/vendor-coinex/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
7
7
  "apps/vendor-coinex/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
8
8
  "apps/vendor-coinex/etc/vendor-coinex.api.md": "33941b70ac7469421ff8fb8c157181014a0ea655",
9
- "apps/vendor-coinex/package.json": "2e8ceb7aee3136c8e9ee889437c9bd03f6638429",
9
+ "apps/vendor-coinex/package.json": "536edea96bff5a588abfb6dd0fd52ee896d0c7a7",
10
10
  "apps/vendor-coinex/src/api.ts": "5dc2027855a6f71ff98f88ad2329abeef40593fb",
11
11
  "apps/vendor-coinex/src/cli.ts": "9bf6b5559a6c6f33da20e74cc6c5d702c60ec891",
12
12
  "apps/vendor-coinex/src/index.ts": "1839b7a344b0f693f8e835f048a0bf6a69f5ff60",
13
- "apps/vendor-coinex/src/interest_rate.ts": "e085bb282420c139fd541f7fa8fb9a676121382f",
14
- "apps/vendor-coinex/src/product.ts": "220942cd49f2ca1846edab7708dc089d443591b1",
15
- "apps/vendor-coinex/src/terminal.ts": "04776a178d253a2e53f9c84c802e80f67aa9179b",
13
+ "apps/vendor-coinex/src/interest_rate.ts": "a4c7e8f7302c9efe2dd28f6553641d85f45af45c",
14
+ "apps/vendor-coinex/src/product.ts": "c11fafeac162c0037299b79d4ce9594a931d7a96",
16
15
  "apps/vendor-coinex/tsconfig.json": "81da8f78196974b5d15da0edb6b2d9f48641063c",
17
16
  "apps/vendor-coinex/.rush/temp/shrinkwrap-deps.json": "65091c107a6149901dadc3fa1a7717446ce94f99",
18
- "libraries/protocol/temp/package-deps.json": "8eafdac8b7fcbd384da0c4d631d4232ca6e57772",
19
- "libraries/transfer/temp/package-deps.json": "e0b34d4194569952115135c95fa12960ddfd3fe7",
20
- "libraries/utils/temp/package-deps.json": "c0ccd6946461153e7eb1b04a3061e075788fad2a",
21
- "libraries/sql/temp/package-deps.json": "da0e17fb9630241beb52c1e3d124b369ddbe37b4",
22
- "libraries/data-series/temp/package-deps.json": "fc6408d3f9ac43e4695e096950633ba9b357f6a3",
23
- "libraries/data-product/temp/package-deps.json": "a59164cb062c82db4350b210ee75a7a2aa6f7022",
24
- "libraries/data-interest-rate/temp/package-deps.json": "1c404b9ff7652d0102472b8ec143e4e373af5d85",
25
- "libraries/extension/temp/package-deps.json": "abcd1ce716b9fd88f33173d01f02c4c3a9462009",
17
+ "libraries/protocol/temp/package-deps.json": "ff231b7689ff7d151498b496f70944d4598fcf33",
18
+ "libraries/transfer/temp/package-deps.json": "2a26e3db2d5ef3318172d1d29ca257bfa94d1b21",
19
+ "libraries/utils/temp/package-deps.json": "56def945d0e67a9d0ca13447d2333155be0138f2",
20
+ "libraries/sql/temp/package-deps.json": "2da55e5e704b1c1558acab11b6df163744d1b24a",
21
+ "libraries/data-series/temp/package-deps.json": "dd0d2f8322b484f074ae09c050ceb53fbc1368f4",
22
+ "libraries/data-product/temp/package-deps.json": "7c61716062e33869b203755b1b7db894e713b46f",
23
+ "libraries/data-interest-rate/temp/package-deps.json": "246f09881d5bce801a352861086d7e2b90eb5b6b",
24
+ "libraries/extension/temp/package-deps.json": "1e2fec9acb35353b204eff0d4cc0af65c3b2582a",
26
25
  "tools/toolkit/temp/package-deps.json": "3bef053db16659f0cdaceea64c8a8580c0131633"
27
26
  }
package/dist/terminal.js DELETED
@@ -1,3 +0,0 @@
1
- import { Terminal } from '@yuants/protocol';
2
- export const terminal = Terminal.fromNodeEnv();
3
- //# sourceMappingURL=terminal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import { Terminal } from '@yuants/protocol';\n\nexport const terminal = Terminal.fromNodeEnv();\n"]}
package/lib/terminal.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { Terminal } from '@yuants/protocol';
2
- export declare const terminal: Terminal;
3
- //# sourceMappingURL=terminal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,eAAO,MAAM,QAAQ,UAAyB,CAAC"}
package/lib/terminal.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.terminal = void 0;
4
- const protocol_1 = require("@yuants/protocol");
5
- exports.terminal = protocol_1.Terminal.fromNodeEnv();
6
- //# sourceMappingURL=terminal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAE/B,QAAA,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import { Terminal } from '@yuants/protocol';\n\nexport const terminal = Terminal.fromNodeEnv();\n"]}