@yuants/vendor-trading-view 0.3.52 → 0.4.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.
- package/dist/index.js +59 -64
- package/dist/index.js.map +1 -1
- package/lib/index.js +59 -64
- package/lib/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/cli.js +0 -3
- package/dist/cli.js.map +0 -1
- package/dist/vendor-trading-view.d.ts +0 -1
- package/lib/cli.d.ts +0 -3
- package/lib/cli.d.ts.map +0 -1
- package/lib/cli.js +0 -5
- package/lib/cli.js.map +0 -1
- package/lib/tsdoc-metadata.json +0 -11
- package/temp/package-deps.json +0 -22
- package/temp/vendor-trading-view.api.json +0 -177
- package/temp/vendor-trading-view.api.md +0 -9
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { provideOHLCDurationService } from '@yuants/data-ohlc';
|
|
2
|
-
import { createSeriesProvider } from '@yuants/data-series';
|
|
3
2
|
import { Terminal } from '@yuants/protocol';
|
|
4
3
|
import { convertDurationToOffset, decodePath, formatTime } from '@yuants/utils';
|
|
5
4
|
import { Observable, firstValueFrom } from 'rxjs';
|
|
6
5
|
//@ts-ignore
|
|
7
6
|
import TradingView from '@mathieuc/tradingview';
|
|
7
|
+
import { provideOHLCService } from '@yuants/exchange';
|
|
8
8
|
const terminal = Terminal.fromNodeEnv();
|
|
9
9
|
const DURATION_TO_TRADINGVIEW_PERIOD = {
|
|
10
10
|
PT1M: '1',
|
|
@@ -26,67 +26,62 @@ const DURATION_TO_TRADINGVIEW_PERIOD = {
|
|
|
26
26
|
};
|
|
27
27
|
provideOHLCDurationService(terminal, 'TradingView', // datasource_id
|
|
28
28
|
() => Object.keys(DURATION_TO_TRADINGVIEW_PERIOD));
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
chart.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
data_length: data.length,
|
|
88
|
-
}));
|
|
89
|
-
return data;
|
|
90
|
-
},
|
|
91
|
-
});
|
|
29
|
+
provideOHLCService(terminal, {
|
|
30
|
+
product_id_prefix: 'TradingView/',
|
|
31
|
+
direction: 'backward',
|
|
32
|
+
duration_list: Object.keys(DURATION_TO_TRADINGVIEW_PERIOD),
|
|
33
|
+
}, async ({ product_id, duration, series_id, time }) => {
|
|
34
|
+
const [datasource_id, symbol] = decodePath(product_id);
|
|
35
|
+
const offset = convertDurationToOffset(duration);
|
|
36
|
+
if (!offset)
|
|
37
|
+
throw new Error(`Unsupported duration: ${duration}`);
|
|
38
|
+
const timeframe = DURATION_TO_TRADINGVIEW_PERIOD[duration];
|
|
39
|
+
if (!timeframe)
|
|
40
|
+
throw new Error(`Unsupported timeframe: ${duration}`);
|
|
41
|
+
const range = 5000;
|
|
42
|
+
console.info(formatTime(Date.now()), 'queryChartRequest', JSON.stringify({ series_id, product_id, duration, range }));
|
|
43
|
+
const data = await firstValueFrom(new Observable((subscriber) => {
|
|
44
|
+
const client = new TradingView.Client();
|
|
45
|
+
const chart = new client.Session.Chart();
|
|
46
|
+
chart.setMarket(symbol, {
|
|
47
|
+
timeframe,
|
|
48
|
+
range,
|
|
49
|
+
to: time,
|
|
50
|
+
});
|
|
51
|
+
chart.onError((e) => {
|
|
52
|
+
subscriber.error(e);
|
|
53
|
+
});
|
|
54
|
+
chart.onUpdate(() => {
|
|
55
|
+
const rawPeriods = chart.periods;
|
|
56
|
+
if (rawPeriods.length !== 0) {
|
|
57
|
+
const periods = rawPeriods.map((v) => ({
|
|
58
|
+
series_id,
|
|
59
|
+
created_at: formatTime(v.time * 1000),
|
|
60
|
+
datasource_id,
|
|
61
|
+
product_id,
|
|
62
|
+
duration,
|
|
63
|
+
closed_at: formatTime(v.time * 1000 + offset),
|
|
64
|
+
open: `${v.open}`,
|
|
65
|
+
high: `${v.max}`,
|
|
66
|
+
low: `${v.min}`,
|
|
67
|
+
close: `${v.close}`,
|
|
68
|
+
volume: `${v.volume}`,
|
|
69
|
+
open_interest: '0',
|
|
70
|
+
}));
|
|
71
|
+
subscriber.next(periods);
|
|
72
|
+
subscriber.complete();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return () => {
|
|
76
|
+
client.end();
|
|
77
|
+
};
|
|
78
|
+
}));
|
|
79
|
+
console.info(formatTime(Date.now()), 'queryChartResponse', JSON.stringify({
|
|
80
|
+
series_id,
|
|
81
|
+
product_id,
|
|
82
|
+
duration,
|
|
83
|
+
data_length: data.length,
|
|
84
|
+
}));
|
|
85
|
+
return data;
|
|
86
|
+
}, { concurrent: +(process.env.CONCURRENCY || 2) });
|
|
92
87
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,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,EAAS,EAAE,CAAC,CAAC;oBACb,SAAS;oBACT,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;oBACrC,aAAa;oBACb,UAAU;oBACV,QAAQ;oBACR,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;oBAC7C,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE;oBACjB,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE;oBAChB,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE;oBACf,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE;oBACnB,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE;oBACrB,aAAa,EAAE,GAAG;iBACnB,CAAC,CACH,CAAC;gBACF,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACzB,UAAU,CAAC,QAAQ,EAAE,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,CAAC,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,CAAC,IAAI,CACV,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EACtB,oBAAoB,EACpB,IAAI,CAAC,SAAS,CAAC;QACb,SAAS;QACT,UAAU;QACV,QAAQ;QACR,WAAW,EAAE,IAAI,CAAC,MAAM;KACzB,CAAC,CACH,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC,EACD,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,EAAE,CAChD,CAAC","sourcesContent":["import { IOHLC, provideOHLCDurationService } from '@yuants/data-ohlc';\nimport { Terminal } from '@yuants/protocol';\nimport { convertDurationToOffset, decodePath, formatTime } from '@yuants/utils';\nimport { Observable, firstValueFrom } from 'rxjs';\n//@ts-ignore\nimport TradingView from '@mathieuc/tradingview';\nimport { provideOHLCService } from '@yuants/exchange';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst DURATION_TO_TRADINGVIEW_PERIOD: Record<string, string> = {\n PT1M: '1',\n PT3M: '3',\n PT5M: '5',\n PT15M: '15',\n PT30M: '30',\n PT45M: '45',\n PT1H: '60',\n PT2H: '120',\n PT3H: '180',\n PT4H: '240',\n P1D: '1D',\n P1W: '1W',\n P1M: '1M',\n P3M: '3M',\n P6M: '6M',\n P1Y: '12M',\n};\n\nprovideOHLCDurationService(\n terminal,\n 'TradingView', // datasource_id\n () => Object.keys(DURATION_TO_TRADINGVIEW_PERIOD),\n);\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'TradingView/',\n direction: 'backward',\n duration_list: Object.keys(DURATION_TO_TRADINGVIEW_PERIOD),\n },\n async ({ product_id, duration, series_id, time }) => {\n const [datasource_id, symbol] = decodePath(product_id);\n const offset = convertDurationToOffset(duration);\n if (!offset) throw new Error(`Unsupported duration: ${duration}`);\n\n const timeframe = DURATION_TO_TRADINGVIEW_PERIOD[duration];\n if (!timeframe) throw new Error(`Unsupported timeframe: ${duration}`);\n\n const range = 5000;\n\n console.info(\n formatTime(Date.now()),\n 'queryChartRequest',\n JSON.stringify({ series_id, product_id, duration, range }),\n );\n\n const data = await firstValueFrom(\n new Observable<IOHLC[]>((subscriber) => {\n const client = new TradingView.Client();\n const chart = new client.Session.Chart();\n chart.setMarket(symbol, {\n timeframe,\n range,\n to: time,\n });\n chart.onError((e: any) => {\n subscriber.error(e);\n });\n chart.onUpdate(() => {\n const rawPeriods: any[] = chart.periods;\n if (rawPeriods.length !== 0) {\n const periods = rawPeriods.map(\n (v): IOHLC => ({\n series_id,\n created_at: formatTime(v.time * 1000),\n datasource_id,\n product_id,\n duration,\n closed_at: formatTime(v.time * 1000 + offset),\n open: `${v.open}`,\n high: `${v.max}`,\n low: `${v.min}`,\n close: `${v.close}`,\n volume: `${v.volume}`,\n open_interest: '0',\n }),\n );\n subscriber.next(periods);\n subscriber.complete();\n }\n });\n return () => {\n client.end();\n };\n }),\n );\n\n console.info(\n formatTime(Date.now()),\n 'queryChartResponse',\n JSON.stringify({\n series_id,\n product_id,\n duration,\n data_length: data.length,\n }),\n );\n\n return data;\n },\n { concurrent: +(process.env.CONCURRENCY || 2) },\n);\n"]}
|
package/lib/index.js
CHANGED
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const data_ohlc_1 = require("@yuants/data-ohlc");
|
|
7
|
-
const data_series_1 = require("@yuants/data-series");
|
|
8
7
|
const protocol_1 = require("@yuants/protocol");
|
|
9
8
|
const utils_1 = require("@yuants/utils");
|
|
10
9
|
const rxjs_1 = require("rxjs");
|
|
11
10
|
//@ts-ignore
|
|
12
11
|
const tradingview_1 = __importDefault(require("@mathieuc/tradingview"));
|
|
12
|
+
const exchange_1 = require("@yuants/exchange");
|
|
13
13
|
const terminal = protocol_1.Terminal.fromNodeEnv();
|
|
14
14
|
const DURATION_TO_TRADINGVIEW_PERIOD = {
|
|
15
15
|
PT1M: '1',
|
|
@@ -31,67 +31,62 @@ const DURATION_TO_TRADINGVIEW_PERIOD = {
|
|
|
31
31
|
};
|
|
32
32
|
(0, data_ohlc_1.provideOHLCDurationService)(terminal, 'TradingView', // datasource_id
|
|
33
33
|
() => Object.keys(DURATION_TO_TRADINGVIEW_PERIOD));
|
|
34
|
-
(0,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
chart.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
data_length: data.length,
|
|
93
|
-
}));
|
|
94
|
-
return data;
|
|
95
|
-
},
|
|
96
|
-
});
|
|
34
|
+
(0, exchange_1.provideOHLCService)(terminal, {
|
|
35
|
+
product_id_prefix: 'TradingView/',
|
|
36
|
+
direction: 'backward',
|
|
37
|
+
duration_list: Object.keys(DURATION_TO_TRADINGVIEW_PERIOD),
|
|
38
|
+
}, async ({ product_id, duration, series_id, time }) => {
|
|
39
|
+
const [datasource_id, symbol] = (0, utils_1.decodePath)(product_id);
|
|
40
|
+
const offset = (0, utils_1.convertDurationToOffset)(duration);
|
|
41
|
+
if (!offset)
|
|
42
|
+
throw new Error(`Unsupported duration: ${duration}`);
|
|
43
|
+
const timeframe = DURATION_TO_TRADINGVIEW_PERIOD[duration];
|
|
44
|
+
if (!timeframe)
|
|
45
|
+
throw new Error(`Unsupported timeframe: ${duration}`);
|
|
46
|
+
const range = 5000;
|
|
47
|
+
console.info((0, utils_1.formatTime)(Date.now()), 'queryChartRequest', JSON.stringify({ series_id, product_id, duration, range }));
|
|
48
|
+
const data = await (0, rxjs_1.firstValueFrom)(new rxjs_1.Observable((subscriber) => {
|
|
49
|
+
const client = new tradingview_1.default.Client();
|
|
50
|
+
const chart = new client.Session.Chart();
|
|
51
|
+
chart.setMarket(symbol, {
|
|
52
|
+
timeframe,
|
|
53
|
+
range,
|
|
54
|
+
to: time,
|
|
55
|
+
});
|
|
56
|
+
chart.onError((e) => {
|
|
57
|
+
subscriber.error(e);
|
|
58
|
+
});
|
|
59
|
+
chart.onUpdate(() => {
|
|
60
|
+
const rawPeriods = chart.periods;
|
|
61
|
+
if (rawPeriods.length !== 0) {
|
|
62
|
+
const periods = rawPeriods.map((v) => ({
|
|
63
|
+
series_id,
|
|
64
|
+
created_at: (0, utils_1.formatTime)(v.time * 1000),
|
|
65
|
+
datasource_id,
|
|
66
|
+
product_id,
|
|
67
|
+
duration,
|
|
68
|
+
closed_at: (0, utils_1.formatTime)(v.time * 1000 + offset),
|
|
69
|
+
open: `${v.open}`,
|
|
70
|
+
high: `${v.max}`,
|
|
71
|
+
low: `${v.min}`,
|
|
72
|
+
close: `${v.close}`,
|
|
73
|
+
volume: `${v.volume}`,
|
|
74
|
+
open_interest: '0',
|
|
75
|
+
}));
|
|
76
|
+
subscriber.next(periods);
|
|
77
|
+
subscriber.complete();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return () => {
|
|
81
|
+
client.end();
|
|
82
|
+
};
|
|
83
|
+
}));
|
|
84
|
+
console.info((0, utils_1.formatTime)(Date.now()), 'queryChartResponse', JSON.stringify({
|
|
85
|
+
series_id,
|
|
86
|
+
product_id,
|
|
87
|
+
duration,
|
|
88
|
+
data_length: data.length,
|
|
89
|
+
}));
|
|
90
|
+
return data;
|
|
91
|
+
}, { concurrent: +(process.env.CONCURRENCY || 2) });
|
|
97
92
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,iDAAsE;AACtE
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,iDAAsE;AACtE,+CAA4C;AAC5C,yCAAgF;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AI,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE;oBAChB,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE;oBACf,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE;oBACnB,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE;oBACrB,aAAa,EAAE,GAAG;iBACnB,CAAC,CACH,CAAC;gBACF,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACzB,UAAU,CAAC,QAAQ,EAAE,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,CAAC,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,CAAC,IAAI,CACV,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EACtB,oBAAoB,EACpB,IAAI,CAAC,SAAS,CAAC;QACb,SAAS;QACT,UAAU;QACV,QAAQ;QACR,WAAW,EAAE,IAAI,CAAC,MAAM;KACzB,CAAC,CACH,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC,EACD,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,EAAE,CAChD,CAAC","sourcesContent":["import { IOHLC, provideOHLCDurationService } from '@yuants/data-ohlc';\nimport { Terminal } from '@yuants/protocol';\nimport { convertDurationToOffset, decodePath, formatTime } from '@yuants/utils';\nimport { Observable, firstValueFrom } from 'rxjs';\n//@ts-ignore\nimport TradingView from '@mathieuc/tradingview';\nimport { provideOHLCService } from '@yuants/exchange';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst DURATION_TO_TRADINGVIEW_PERIOD: Record<string, string> = {\n PT1M: '1',\n PT3M: '3',\n PT5M: '5',\n PT15M: '15',\n PT30M: '30',\n PT45M: '45',\n PT1H: '60',\n PT2H: '120',\n PT3H: '180',\n PT4H: '240',\n P1D: '1D',\n P1W: '1W',\n P1M: '1M',\n P3M: '3M',\n P6M: '6M',\n P1Y: '12M',\n};\n\nprovideOHLCDurationService(\n terminal,\n 'TradingView', // datasource_id\n () => Object.keys(DURATION_TO_TRADINGVIEW_PERIOD),\n);\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'TradingView/',\n direction: 'backward',\n duration_list: Object.keys(DURATION_TO_TRADINGVIEW_PERIOD),\n },\n async ({ product_id, duration, series_id, time }) => {\n const [datasource_id, symbol] = decodePath(product_id);\n const offset = convertDurationToOffset(duration);\n if (!offset) throw new Error(`Unsupported duration: ${duration}`);\n\n const timeframe = DURATION_TO_TRADINGVIEW_PERIOD[duration];\n if (!timeframe) throw new Error(`Unsupported timeframe: ${duration}`);\n\n const range = 5000;\n\n console.info(\n formatTime(Date.now()),\n 'queryChartRequest',\n JSON.stringify({ series_id, product_id, duration, range }),\n );\n\n const data = await firstValueFrom(\n new Observable<IOHLC[]>((subscriber) => {\n const client = new TradingView.Client();\n const chart = new client.Session.Chart();\n chart.setMarket(symbol, {\n timeframe,\n range,\n to: time,\n });\n chart.onError((e: any) => {\n subscriber.error(e);\n });\n chart.onUpdate(() => {\n const rawPeriods: any[] = chart.periods;\n if (rawPeriods.length !== 0) {\n const periods = rawPeriods.map(\n (v): IOHLC => ({\n series_id,\n created_at: formatTime(v.time * 1000),\n datasource_id,\n product_id,\n duration,\n closed_at: formatTime(v.time * 1000 + offset),\n open: `${v.open}`,\n high: `${v.max}`,\n low: `${v.min}`,\n close: `${v.close}`,\n volume: `${v.volume}`,\n open_interest: '0',\n }),\n );\n subscriber.next(periods);\n subscriber.complete();\n }\n });\n return () => {\n client.end();\n };\n }),\n );\n\n console.info(\n formatTime(Date.now()),\n 'queryChartResponse',\n JSON.stringify({\n series_id,\n product_id,\n duration,\n data_length: data.length,\n }),\n );\n\n return data;\n },\n { concurrent: +(process.env.CONCURRENCY || 2) },\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/vendor-trading-view",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"@yuants/sql": "0.9.38",
|
|
14
14
|
"@yuants/data-product": "0.5.8",
|
|
15
15
|
"@yuants/utils": "0.19.3",
|
|
16
|
+
"@yuants/exchange": "0.8.10",
|
|
16
17
|
"@yuants/data-ohlc": "0.6.3",
|
|
17
18
|
"rxjs": "~7.5.6",
|
|
18
19
|
"@mathieuc/tradingview": "~3.4.2"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"@microsoft/api-extractor": "~7.30.0",
|
|
22
22
|
"@rushstack/heft": "~0.47.5",
|
|
23
23
|
"@rushstack/heft-jest-plugin": "~0.16.8",
|
|
24
24
|
"@rushstack/heft-node-rig": "~1.10.7",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "heft test --clean
|
|
37
|
+
"build": "heft test --clean",
|
|
38
|
+
"test": "heft test"
|
|
38
39
|
}
|
|
39
40
|
}
|
package/dist/cli.js
DELETED
package/dist/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,SAAS,CAAC","sourcesContent":["#!/usr/bin/env node\nimport './index';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { }
|
package/lib/cli.d.ts
DELETED
package/lib/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,SAAS,CAAC"}
|
package/lib/cli.js
DELETED
package/lib/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AACA,mBAAiB","sourcesContent":["#!/usr/bin/env node\nimport './index';\n"]}
|
package/lib/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.30.1"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
package/temp/package-deps.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"apps/vendor-trading-view/CHANGELOG.json": "194728b6b429a77cf6e5c1a45af8d3f000ae0c36",
|
|
3
|
-
"apps/vendor-trading-view/CHANGELOG.md": "e510a40dc2ab4098ec0d7a51b70d9e56b831e444",
|
|
4
|
-
"apps/vendor-trading-view/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
|
|
5
|
-
"apps/vendor-trading-view/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
|
|
6
|
-
"apps/vendor-trading-view/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
|
|
7
|
-
"apps/vendor-trading-view/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
|
|
8
|
-
"apps/vendor-trading-view/etc/vendor-trading-view.api.md": "341d99a0258ce3dff77a871b518a458d33bb3df5",
|
|
9
|
-
"apps/vendor-trading-view/package.json": "bb5091c6f06e3eb94878e50231decbd778b0053e",
|
|
10
|
-
"apps/vendor-trading-view/src/cli.ts": "9bf6b5559a6c6f33da20e74cc6c5d702c60ec891",
|
|
11
|
-
"apps/vendor-trading-view/src/index.ts": "dea893ca8ae94a70bc9ff8167e9ec53d5a93deb2",
|
|
12
|
-
"apps/vendor-trading-view/tsconfig.json": "c96157f0fbf3503af6f84e03a0df4ac624a82d47",
|
|
13
|
-
"apps/vendor-trading-view/.rush/temp/shrinkwrap-deps.json": "c7628aefb2275d409bfbd57b3355bd5f24683160",
|
|
14
|
-
"libraries/protocol/temp/package-deps.json": "f9ac8a0412f63d53f93ce189a390eab4a74b772b",
|
|
15
|
-
"libraries/data-series/temp/package-deps.json": "cc0091507594699dcba5a91b5068259c4776fffe",
|
|
16
|
-
"libraries/sql/temp/package-deps.json": "d1a7297dec9849184bda8843800beae36c6b1f09",
|
|
17
|
-
"libraries/data-product/temp/package-deps.json": "0eee98e9df8a5aa401aa1e87cefa141630973535",
|
|
18
|
-
"libraries/utils/temp/package-deps.json": "16ee87f512cd903d59f2ce9935be22e5ed6d03a1",
|
|
19
|
-
"libraries/data-ohlc/temp/package-deps.json": "d746fd7cc4964310a4f239d6c59538e7562d537a",
|
|
20
|
-
"libraries/extension/temp/package-deps.json": "85f040a21803ec7d18c2730a13e0a2d79d5245fa",
|
|
21
|
-
"tools/toolkit/temp/package-deps.json": "23e053490eb8feade23e4d45de4e54883e322711"
|
|
22
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"metadata": {
|
|
3
|
-
"toolPackage": "@microsoft/api-extractor",
|
|
4
|
-
"toolVersion": "7.30.1",
|
|
5
|
-
"schemaVersion": 1009,
|
|
6
|
-
"oldestForwardsCompatibleVersion": 1001,
|
|
7
|
-
"tsdocConfig": {
|
|
8
|
-
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
|
|
9
|
-
"noStandardTags": true,
|
|
10
|
-
"tagDefinitions": [
|
|
11
|
-
{
|
|
12
|
-
"tagName": "@alpha",
|
|
13
|
-
"syntaxKind": "modifier"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"tagName": "@beta",
|
|
17
|
-
"syntaxKind": "modifier"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"tagName": "@defaultValue",
|
|
21
|
-
"syntaxKind": "block"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"tagName": "@decorator",
|
|
25
|
-
"syntaxKind": "block",
|
|
26
|
-
"allowMultiple": true
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"tagName": "@deprecated",
|
|
30
|
-
"syntaxKind": "block"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"tagName": "@eventProperty",
|
|
34
|
-
"syntaxKind": "modifier"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"tagName": "@example",
|
|
38
|
-
"syntaxKind": "block",
|
|
39
|
-
"allowMultiple": true
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"tagName": "@experimental",
|
|
43
|
-
"syntaxKind": "modifier"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"tagName": "@inheritDoc",
|
|
47
|
-
"syntaxKind": "inline"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"tagName": "@internal",
|
|
51
|
-
"syntaxKind": "modifier"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"tagName": "@label",
|
|
55
|
-
"syntaxKind": "inline"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"tagName": "@link",
|
|
59
|
-
"syntaxKind": "inline",
|
|
60
|
-
"allowMultiple": true
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"tagName": "@override",
|
|
64
|
-
"syntaxKind": "modifier"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"tagName": "@packageDocumentation",
|
|
68
|
-
"syntaxKind": "modifier"
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"tagName": "@param",
|
|
72
|
-
"syntaxKind": "block",
|
|
73
|
-
"allowMultiple": true
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"tagName": "@privateRemarks",
|
|
77
|
-
"syntaxKind": "block"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"tagName": "@public",
|
|
81
|
-
"syntaxKind": "modifier"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"tagName": "@readonly",
|
|
85
|
-
"syntaxKind": "modifier"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"tagName": "@remarks",
|
|
89
|
-
"syntaxKind": "block"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"tagName": "@returns",
|
|
93
|
-
"syntaxKind": "block"
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"tagName": "@sealed",
|
|
97
|
-
"syntaxKind": "modifier"
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"tagName": "@see",
|
|
101
|
-
"syntaxKind": "block"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"tagName": "@throws",
|
|
105
|
-
"syntaxKind": "block",
|
|
106
|
-
"allowMultiple": true
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"tagName": "@typeParam",
|
|
110
|
-
"syntaxKind": "block",
|
|
111
|
-
"allowMultiple": true
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
"tagName": "@virtual",
|
|
115
|
-
"syntaxKind": "modifier"
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"tagName": "@betaDocumentation",
|
|
119
|
-
"syntaxKind": "modifier"
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
"tagName": "@internalRemarks",
|
|
123
|
-
"syntaxKind": "block"
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
"tagName": "@preapproved",
|
|
127
|
-
"syntaxKind": "modifier"
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
"supportForTags": {
|
|
131
|
-
"@alpha": true,
|
|
132
|
-
"@beta": true,
|
|
133
|
-
"@defaultValue": true,
|
|
134
|
-
"@decorator": true,
|
|
135
|
-
"@deprecated": true,
|
|
136
|
-
"@eventProperty": true,
|
|
137
|
-
"@example": true,
|
|
138
|
-
"@experimental": true,
|
|
139
|
-
"@inheritDoc": true,
|
|
140
|
-
"@internal": true,
|
|
141
|
-
"@label": true,
|
|
142
|
-
"@link": true,
|
|
143
|
-
"@override": true,
|
|
144
|
-
"@packageDocumentation": true,
|
|
145
|
-
"@param": true,
|
|
146
|
-
"@privateRemarks": true,
|
|
147
|
-
"@public": true,
|
|
148
|
-
"@readonly": true,
|
|
149
|
-
"@remarks": true,
|
|
150
|
-
"@returns": true,
|
|
151
|
-
"@sealed": true,
|
|
152
|
-
"@see": true,
|
|
153
|
-
"@throws": true,
|
|
154
|
-
"@typeParam": true,
|
|
155
|
-
"@virtual": true,
|
|
156
|
-
"@betaDocumentation": true,
|
|
157
|
-
"@internalRemarks": true,
|
|
158
|
-
"@preapproved": true
|
|
159
|
-
},
|
|
160
|
-
"reportUnsupportedHtmlElements": false
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
"kind": "Package",
|
|
164
|
-
"canonicalReference": "@yuants/vendor-trading-view!",
|
|
165
|
-
"docComment": "",
|
|
166
|
-
"name": "@yuants/vendor-trading-view",
|
|
167
|
-
"preserveMemberOrder": false,
|
|
168
|
-
"members": [
|
|
169
|
-
{
|
|
170
|
-
"kind": "EntryPoint",
|
|
171
|
-
"canonicalReference": "@yuants/vendor-trading-view!",
|
|
172
|
-
"name": "",
|
|
173
|
-
"preserveMemberOrder": false,
|
|
174
|
-
"members": []
|
|
175
|
-
}
|
|
176
|
-
]
|
|
177
|
-
}
|