@yuants/exchange 0.7.0 → 0.8.0
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/exchange.d.ts +90 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interest_rate.js +129 -0
- package/dist/interest_rate.js.map +1 -0
- package/dist/interest_rate.test.js +24 -0
- package/dist/interest_rate.test.js.map +1 -0
- package/dist/ohlc.js +152 -0
- package/dist/ohlc.js.map +1 -0
- package/dist/ohlc.test.js +26 -0
- package/dist/ohlc.test.js.map +1 -0
- package/dist/quote.test.js +31 -0
- package/dist/quote.test.js.map +1 -0
- package/dist/types.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/interest_rate.d.ts +34 -0
- package/lib/interest_rate.d.ts.map +1 -0
- package/lib/interest_rate.js +134 -0
- package/lib/interest_rate.js.map +1 -0
- package/lib/interest_rate.test.d.ts +2 -0
- package/lib/interest_rate.test.d.ts.map +1 -0
- package/lib/interest_rate.test.js +26 -0
- package/lib/interest_rate.test.js.map +1 -0
- package/lib/ohlc.d.ts +36 -0
- package/lib/ohlc.d.ts.map +1 -0
- package/lib/ohlc.js +157 -0
- package/lib/ohlc.js.map +1 -0
- package/lib/ohlc.test.d.ts +2 -0
- package/lib/ohlc.test.d.ts.map +1 -0
- package/lib/ohlc.test.js +28 -0
- package/lib/ohlc.test.js.map +1 -0
- package/lib/quote.test.d.ts +2 -0
- package/lib/quote.test.d.ts.map +1 -0
- package/lib/quote.test.js +33 -0
- package/lib/quote.test.js.map +1 -0
- package/lib/types.d.ts +16 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +4 -2
- package/temp/exchange.api.json +752 -0
- package/temp/exchange.api.md +80 -0
- package/temp/package-deps.json +15 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote.test.d.ts","sourceRoot":"","sources":["../src/quote.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const quote_1 = require("./quote");
|
|
4
|
+
describe('parseQuoteServiceMetadataFromSchema', () => {
|
|
5
|
+
it('parses quote service schema', () => {
|
|
6
|
+
const schema = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
required: ['product_ids', 'fields'],
|
|
9
|
+
properties: {
|
|
10
|
+
product_ids: {
|
|
11
|
+
type: 'array',
|
|
12
|
+
maxItems: 20,
|
|
13
|
+
items: { type: 'string', pattern: '^BINANCE/USDT-FUTURE' },
|
|
14
|
+
},
|
|
15
|
+
fields: {
|
|
16
|
+
type: 'array',
|
|
17
|
+
const: ['last_price', 'bid_price'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const meta = (0, quote_1.parseQuoteServiceMetadataFromSchema)(schema);
|
|
22
|
+
expect(meta).toEqual({
|
|
23
|
+
product_id_prefix: 'BINANCE/USDT-FUTURE',
|
|
24
|
+
fields: ['last_price', 'bid_price'],
|
|
25
|
+
max_products_per_request: 20,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
it('throws when schema missing/invalid', () => {
|
|
29
|
+
expect(() => (0, quote_1.parseQuoteServiceMetadataFromSchema)(undefined)).toThrow('QUOTE_SERVICE_SCHEMA_MISSING');
|
|
30
|
+
expect(() => (0, quote_1.parseQuoteServiceMetadataFromSchema)({})).toThrow('QUOTE_SERVICE_SCHEMA_INVALID');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=quote.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote.test.js","sourceRoot":"","sources":["../src/quote.test.ts"],"names":[],"mappings":";;AAAA,mCAA8D;AAE9D,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,MAAM,GAAG;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC;YACnC,UAAU,EAAE;gBACV,WAAW,EAAE;oBACX,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,EAAE;oBACZ,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,sBAAsB,EAAE;iBAC3D;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC;iBACnC;aACF;SACF,CAAC;QAEF,MAAM,IAAI,GAAG,IAAA,2CAAmC,EAAC,MAAM,CAAC,CAAC;QACzD,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;YACnB,iBAAiB,EAAE,qBAAqB;YACxC,MAAM,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC;YACnC,wBAAwB,EAAE,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,2CAAmC,EAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;QACrG,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,2CAAmC,EAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { parseQuoteServiceMetadataFromSchema } from './quote';\n\ndescribe('parseQuoteServiceMetadataFromSchema', () => {\n it('parses quote service schema', () => {\n const schema = {\n type: 'object',\n required: ['product_ids', 'fields'],\n properties: {\n product_ids: {\n type: 'array',\n maxItems: 20,\n items: { type: 'string', pattern: '^BINANCE/USDT-FUTURE' },\n },\n fields: {\n type: 'array',\n const: ['last_price', 'bid_price'],\n },\n },\n };\n\n const meta = parseQuoteServiceMetadataFromSchema(schema);\n expect(meta).toEqual({\n product_id_prefix: 'BINANCE/USDT-FUTURE',\n fields: ['last_price', 'bid_price'],\n max_products_per_request: 20,\n });\n });\n\n it('throws when schema missing/invalid', () => {\n expect(() => parseQuoteServiceMetadataFromSchema(undefined)).toThrow('QUOTE_SERVICE_SCHEMA_MISSING');\n expect(() => parseQuoteServiceMetadataFromSchema({})).toThrow('QUOTE_SERVICE_SCHEMA_INVALID');\n });\n});\n"]}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { IQuote } from '@yuants/data-quote';
|
|
2
|
+
/**
|
|
3
|
+
* 历史数据翻页方向
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare type SeriesFetchDirection = 'backward' | 'forward';
|
|
7
|
+
/**
|
|
8
|
+
* 历史数据写库结果(不返回数据本体)
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export interface ISeriesIngestResult {
|
|
12
|
+
wrote_count: number;
|
|
13
|
+
range?: {
|
|
14
|
+
start_time: string;
|
|
15
|
+
end_time: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
2
18
|
/**
|
|
3
19
|
* Quote 字段类型,排除掉 product_id, updated_at, datasource_id 三个字段
|
|
4
20
|
* @public
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;GAGG;AACH,oBAAY,WAAW,GAAG,OAAO,CAAC,MAAM,MAAM,EAAE,YAAY,GAAG,YAAY,GAAG,eAAe,CAAC,CAAC;AAE/F;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;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AAE,CAAC;CACvB;AACD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oBAAY,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,MAAM,CAC1E,MAAM,EACN,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CACxD,CAAC"}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { IQuote } from '@yuants/data-quote';\n\n/**\n * Quote 字段类型,排除掉 product_id, updated_at, datasource_id 三个字段\n * @public\n */\nexport type IQuoteField = Exclude<keyof IQuote, 'product_id' | 'updated_at' | 'datasource_id'>;\n\n/**\n * Quote Service Metadata\n * @public\n */\nexport interface IQuoteServiceMetadata<K extends IQuoteField = IQuoteField> {\n product_id_prefix: string;\n fields: K[];\n max_products_per_request?: number;\n}\n\n/**\n * Quote Service Request from VEX to Vendor\n * @public\n */\nexport interface IQuoteServiceRequestByVEX {\n product_ids: string[];\n fields: IQuoteField[];\n}\n/**\n * 用于批量更新的数据结构\n * 结构为:\n * product_id -\\> field_name (keyof IQuote) -\\> [value: string, updated_at: number]\n * 这样设计的目的是为了减少更新的数据量,同时保留每个字段的更新时间\n *\n * 例如:\n * ```json\n * {\n * \"product_123\": {\n * \"last_price\": [\"100.5\", 1627890123456],\n * \"volume\": [\"1500\", 1627890123456]\n * },\n * \"product_456\": {\n * \"last_price\": [\"200.0\", 1627890123456]\n * }\n * }\n * ```\n * @public\n */\nexport type IQuoteUpdateAction<K extends IQuoteField = IQuoteField> = Record<\n string,\n Partial<Record<K, [value: string, updated_at: number]>>\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { IQuote } from '@yuants/data-quote';\n\n/**\n * 历史数据翻页方向\n * @public\n */\nexport type SeriesFetchDirection = 'backward' | 'forward';\n\n/**\n * 历史数据写库结果(不返回数据本体)\n * @public\n */\nexport interface ISeriesIngestResult {\n wrote_count: number;\n range?: { start_time: string; end_time: string };\n}\n\n/**\n * Quote 字段类型,排除掉 product_id, updated_at, datasource_id 三个字段\n * @public\n */\nexport type IQuoteField = Exclude<keyof IQuote, 'product_id' | 'updated_at' | 'datasource_id'>;\n\n/**\n * Quote Service Metadata\n * @public\n */\nexport interface IQuoteServiceMetadata<K extends IQuoteField = IQuoteField> {\n product_id_prefix: string;\n fields: K[];\n max_products_per_request?: number;\n}\n\n/**\n * Quote Service Request from VEX to Vendor\n * @public\n */\nexport interface IQuoteServiceRequestByVEX {\n product_ids: string[];\n fields: IQuoteField[];\n}\n/**\n * 用于批量更新的数据结构\n * 结构为:\n * product_id -\\> field_name (keyof IQuote) -\\> [value: string, updated_at: number]\n * 这样设计的目的是为了减少更新的数据量,同时保留每个字段的更新时间\n *\n * 例如:\n * ```json\n * {\n * \"product_123\": {\n * \"last_price\": [\"100.5\", 1627890123456],\n * \"volume\": [\"1500\", 1627890123456]\n * },\n * \"product_456\": {\n * \"last_price\": [\"200.0\", 1627890123456]\n * }\n * }\n * ```\n * @public\n */\nexport type IQuoteUpdateAction<K extends IQuoteField = IQuoteField> = Record<\n string,\n Partial<Record<K, [value: string, updated_at: number]>>\n>;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/exchange",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"@yuants/data-account": "0.11.0",
|
|
29
29
|
"@yuants/data-order": "0.7.1",
|
|
30
30
|
"@yuants/data-product": "0.5.1",
|
|
31
|
-
"@yuants/data-quote": "0.
|
|
31
|
+
"@yuants/data-quote": "0.4.0",
|
|
32
|
+
"@yuants/data-ohlc": "0.4.23",
|
|
33
|
+
"@yuants/data-interest-rate": "0.1.49",
|
|
32
34
|
"@yuants/cache": "0.3.4",
|
|
33
35
|
"@yuants/sql": "0.9.31",
|
|
34
36
|
"@yuants/utils": "0.15.0",
|