tigeropen 0.5.5 → 0.5.8
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/README.md +173 -0
- package/dist/cjs/client/api-response.js +6 -5
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/model/news-requests.js +9 -0
- package/dist/cjs/model/news.js +8 -0
- package/dist/cjs/news/index.js +8 -0
- package/dist/cjs/news/news-client.js +84 -0
- package/dist/cjs/push/pb/QuoteBasicData.js +37 -1
- package/dist/cjs/push/pb/QuoteData.js +37 -1
- package/dist/cjs/push/pb/Request.js +12 -1
- package/dist/cjs/push/proto-message.js +5 -1
- package/dist/cjs/push/push-client.js +29 -13
- package/dist/cjs/quote/quote-client.js +4 -1
- package/dist/cjs/trade/trade-client.js +26 -5
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client/api-response.js +6 -5
- package/dist/esm/index.js +2 -1
- package/dist/esm/model/news-requests.js +8 -0
- package/dist/esm/model/news.js +7 -0
- package/dist/esm/news/index.js +4 -0
- package/dist/esm/news/news-client.js +80 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/push/pb/QuoteBasicData.js +37 -1
- package/dist/esm/push/pb/QuoteData.js +37 -1
- package/dist/esm/push/pb/Request.js +12 -1
- package/dist/esm/push/proto-message.js +5 -1
- package/dist/esm/push/push-client.js +29 -13
- package/dist/esm/quote/quote-client.js +4 -1
- package/dist/esm/trade/trade-client.js +26 -5
- package/dist/esm/version.js +1 -1
- package/dist/types/index.d.ts +7 -3
- package/dist/types/model/news-requests.d.ts +39 -0
- package/dist/types/model/news.d.ts +38 -0
- package/dist/types/model/quote.d.ts +17 -0
- package/dist/types/model/trade-requests.d.ts +7 -1
- package/dist/types/news/index.d.ts +5 -0
- package/dist/types/news/news-client.d.ts +60 -0
- package/dist/types/push/index.d.ts +1 -1
- package/dist/types/push/pb/QuoteBasicData.d.ts +14 -5
- package/dist/types/push/pb/QuoteData.d.ts +14 -5
- package/dist/types/push/pb/Request.d.ts +1 -0
- package/dist/types/push/proto-message.d.ts +4 -1
- package/dist/types/push/push-client.d.ts +33 -0
- package/dist/types/quote/quote-client.d.ts +2 -1
- package/dist/types/trade/trade-client.d.ts +14 -4
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -4
|
@@ -95,6 +95,8 @@ class PushClient {
|
|
|
95
95
|
this.subscriptions = new Map();
|
|
96
96
|
/** Account-level subscriptions: subject -> account string used at subscribe time */
|
|
97
97
|
this.accountSubs = new Map();
|
|
98
|
+
/** Account-level subscriptions: subject -> assetQuoteType used at subscribe time (reconnect replay) */
|
|
99
|
+
this.accountSubQuoteTypes = new Map();
|
|
98
100
|
this.heartbeatTimer = null;
|
|
99
101
|
this.reconnectTimer = null;
|
|
100
102
|
this.stopped = false;
|
|
@@ -355,7 +357,7 @@ class PushClient {
|
|
|
355
357
|
this.doSubscribe(subject, Array.from(symbols));
|
|
356
358
|
}
|
|
357
359
|
for (const [subject, account] of this.accountSubs) {
|
|
358
|
-
this.doSubscribe(subject, undefined, account);
|
|
360
|
+
this.doSubscribe(subject, undefined, account, undefined, this.accountSubQuoteTypes.get(subject));
|
|
359
361
|
}
|
|
360
362
|
}
|
|
361
363
|
/** Dispatch push data to the appropriate callback based on dataType */
|
|
@@ -425,10 +427,10 @@ class PushClient {
|
|
|
425
427
|
}
|
|
426
428
|
}
|
|
427
429
|
/** Internal subscribe method */
|
|
428
|
-
doSubscribe(subject, symbols, account, market) {
|
|
430
|
+
doSubscribe(subject, symbols, account, market, assetQuoteType) {
|
|
429
431
|
const dataType = (0, proto_message_1.subjectToDataType)(subject);
|
|
430
432
|
const symbolsStr = symbols ? symbols.join(',') : undefined;
|
|
431
|
-
const req = (0, proto_message_1.buildSubscribeMessage)(dataType, symbolsStr, account, market);
|
|
433
|
+
const req = (0, proto_message_1.buildSubscribeMessage)(dataType, symbolsStr, account, market, assetQuoteType);
|
|
432
434
|
this.sendMessage(req);
|
|
433
435
|
}
|
|
434
436
|
/** Internal unsubscribe method */
|
|
@@ -588,27 +590,41 @@ class PushClient {
|
|
|
588
590
|
this.removeSubscription(push_message_1.SubjectType.Market, [market]);
|
|
589
591
|
}
|
|
590
592
|
// ===== Account push subscribe/unsubscribe =====
|
|
591
|
-
/**
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
593
|
+
/**
|
|
594
|
+
* Shared implementation for the account/options overloads of
|
|
595
|
+
* subscribeAsset / subscribePosition.
|
|
596
|
+
*/
|
|
597
|
+
subscribeAccount(subject, accountOrOptions) {
|
|
598
|
+
const opts = typeof accountOrOptions === 'string'
|
|
599
|
+
? { account: accountOrOptions }
|
|
600
|
+
: (accountOrOptions ?? {});
|
|
601
|
+
const acct = opts.account || this.config.account;
|
|
602
|
+
this.doSubscribe(subject, undefined, acct, undefined, opts.assetQuoteType);
|
|
603
|
+
this.accountSubs.set(subject, acct);
|
|
604
|
+
if (opts.assetQuoteType) {
|
|
605
|
+
this.accountSubQuoteTypes.set(subject, opts.assetQuoteType);
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
this.accountSubQuoteTypes.delete(subject);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
subscribeAsset(accountOrOptions) {
|
|
612
|
+
this.subscribeAccount(push_message_1.SubjectType.Asset, accountOrOptions);
|
|
596
613
|
}
|
|
597
614
|
/** Unsubscribe from asset changes */
|
|
598
615
|
unsubscribeAsset() {
|
|
599
616
|
this.doUnsubscribe(push_message_1.SubjectType.Asset);
|
|
600
617
|
this.accountSubs.delete(push_message_1.SubjectType.Asset);
|
|
618
|
+
this.accountSubQuoteTypes.delete(push_message_1.SubjectType.Asset);
|
|
601
619
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
const acct = account || this.config.account;
|
|
605
|
-
this.doSubscribe(push_message_1.SubjectType.Position, undefined, acct);
|
|
606
|
-
this.accountSubs.set(push_message_1.SubjectType.Position, acct);
|
|
620
|
+
subscribePosition(accountOrOptions) {
|
|
621
|
+
this.subscribeAccount(push_message_1.SubjectType.Position, accountOrOptions);
|
|
607
622
|
}
|
|
608
623
|
/** Unsubscribe from position changes */
|
|
609
624
|
unsubscribePosition() {
|
|
610
625
|
this.doUnsubscribe(push_message_1.SubjectType.Position);
|
|
611
626
|
this.accountSubs.delete(push_message_1.SubjectType.Position);
|
|
627
|
+
this.accountSubQuoteTypes.delete(push_message_1.SubjectType.Position);
|
|
612
628
|
}
|
|
613
629
|
/** Subscribe to order status */
|
|
614
630
|
subscribeOrder(account) {
|
|
@@ -245,8 +245,9 @@ class QuoteClient {
|
|
|
245
245
|
* If omitted, defaults to America/New_York for US symbols and Asia/Hong_Kong for .HK symbols.
|
|
246
246
|
* @param limit - Maximum number of bars to return.
|
|
247
247
|
* @param sortDir - Sort direction ('asc' or 'desc').
|
|
248
|
+
* @param withHourTrading - Include GTH/CURB minute bars; omitted preserves the server default.
|
|
248
249
|
*/
|
|
249
|
-
async getOptionKline(identifiers, period, beginTime = -1, endTime = -1, timezone, limit, sortDir) {
|
|
250
|
+
async getOptionKline(identifiers, period, beginTime = -1, endTime = -1, timezone, limit, sortDir, withHourTrading) {
|
|
250
251
|
const resolvedBegin = beginTime === 0 ? -1 : beginTime;
|
|
251
252
|
const resolvedEnd = endTime === 0 ? -1 : endTime;
|
|
252
253
|
const optionQuery = identifiers.map((id) => {
|
|
@@ -264,6 +265,8 @@ class QuoteClient {
|
|
|
264
265
|
entry['limit'] = limit;
|
|
265
266
|
if (sortDir !== undefined && sortDir !== '')
|
|
266
267
|
entry['sort_dir'] = sortDir;
|
|
268
|
+
if (withHourTrading !== undefined)
|
|
269
|
+
entry['with_hour_trading'] = withHourTrading;
|
|
267
270
|
return entry;
|
|
268
271
|
});
|
|
269
272
|
return this.callInto('option_kline', { option_query: optionQuery }, '2.0');
|
|
@@ -235,11 +235,23 @@ class TradeClient {
|
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
237
237
|
* Get a single order by ID (v0.4.0 new).
|
|
238
|
-
*
|
|
238
|
+
* Wire method: `orders` with `id` / `order_id` parameters.
|
|
239
|
+
* Returns `undefined` if no match or the result contains multiple orders.
|
|
239
240
|
*/
|
|
240
241
|
async getOrder(req) {
|
|
241
242
|
const merged = withAccount(req, this.account);
|
|
242
|
-
const
|
|
243
|
+
const data = await this.callInto('orders', merged);
|
|
244
|
+
let out;
|
|
245
|
+
if (Array.isArray(data)) {
|
|
246
|
+
out = data.length === 1 ? data[0] : undefined;
|
|
247
|
+
}
|
|
248
|
+
else if (data && typeof data === 'object' && 'items' in data) {
|
|
249
|
+
const items = data.items;
|
|
250
|
+
out = Array.isArray(items) && items.length === 1 ? items[0] : undefined;
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
out = data;
|
|
254
|
+
}
|
|
243
255
|
if (!out || (!out.id && !out.orderId))
|
|
244
256
|
return undefined;
|
|
245
257
|
normalizeOrderInPlace(out);
|
|
@@ -257,11 +269,17 @@ class TradeClient {
|
|
|
257
269
|
async getPositions(req) {
|
|
258
270
|
return this.callIntoItems('positions', withAccount(req, this.account));
|
|
259
271
|
}
|
|
260
|
-
/**
|
|
272
|
+
/**
|
|
273
|
+
* Query assets. v0.4.0: supports sub-account list and aggregation options.
|
|
274
|
+
* `assetQuoteType`(ETH / RTH / OVERNIGHT) 选择资产行情口径。
|
|
275
|
+
*/
|
|
261
276
|
async getAssets(req) {
|
|
262
277
|
return this.callIntoItems('assets', withAccount(req, this.account));
|
|
263
278
|
}
|
|
264
|
-
/**
|
|
279
|
+
/**
|
|
280
|
+
* Query prime assets. v0.4.0: takes AssetsRequest for filters.
|
|
281
|
+
* `assetQuoteType`(ETH / RTH / OVERNIGHT) 选择资产行情口径。
|
|
282
|
+
*/
|
|
265
283
|
async getPrimeAssets(req) {
|
|
266
284
|
return this.callInto('prime_assets', withAccount(req, this.account));
|
|
267
285
|
}
|
|
@@ -282,7 +300,10 @@ class TradeClient {
|
|
|
282
300
|
async getAnalyticsAsset(req) {
|
|
283
301
|
return this.callIntoItems('analytics_asset', withAccount(req, this.account));
|
|
284
302
|
}
|
|
285
|
-
/**
|
|
303
|
+
/**
|
|
304
|
+
* Aggregate assets (prime) by base currency.
|
|
305
|
+
* `assetQuoteType`(ETH / RTH / OVERNIGHT) 选择资产行情口径。
|
|
306
|
+
*/
|
|
286
307
|
async getAggregateAssets(req) {
|
|
287
308
|
return this.callInto('aggregate_assets', withAccount(req, this.account));
|
|
288
309
|
}
|
package/dist/cjs/version.js
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { TigerError } from './errors.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* so 16-digit microsecond timestamps remain as numbers.
|
|
6
|
+
* Quotes bare integers outside Number's safe range before JSON.parse.
|
|
7
|
+
* Values are checked by range, including 16-digit order IDs; safe integers
|
|
8
|
+
* such as microsecond timestamps remain numbers. Floats are left unchanged.
|
|
10
9
|
*/
|
|
11
10
|
function patchLargeIntegers(text) {
|
|
12
11
|
const strings = [];
|
|
@@ -17,7 +16,9 @@ function patchLargeIntegers(text) {
|
|
|
17
16
|
// Match bare integers preceded by a JSON structural character or line start,
|
|
18
17
|
// not followed by decimal point or exponent (avoids matching float components).
|
|
19
18
|
// The `m` flag makes `^` match line-start for multi-line JSON.
|
|
20
|
-
const patched = masked.replace(/([:,\[{]|^)\s*(-?\d{
|
|
19
|
+
const patched = masked.replace(/([:,\[{]|^)\s*(-?\d{16,})(?![.\deE])/gm, (full, prefix, num) => {
|
|
20
|
+
if (Number.isSafeInteger(Number(num)))
|
|
21
|
+
return full;
|
|
21
22
|
return prefix + '"' + num + '"';
|
|
22
23
|
});
|
|
23
24
|
return patched.replace(/\x01(\d+)\x01/g, (_, i) => strings[parseInt(i, 10)]);
|
package/dist/esm/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - 配置层(config):ClientConfig、ConfigParser
|
|
10
10
|
* - 认证层(signer):RSA 签名
|
|
11
11
|
* - 传输层(client):HttpClient、重试策略
|
|
12
|
-
* - 业务层(quote/trade):QuoteClient、TradeClient
|
|
12
|
+
* - 业务层(quote/trade/news):QuoteClient、TradeClient、NewsClient
|
|
13
13
|
* - 推送层(push):PushClient
|
|
14
14
|
*
|
|
15
15
|
* @packageDocumentation
|
|
@@ -25,6 +25,7 @@ export { TigerError, classifyErrorCode } from './client/index.js';
|
|
|
25
25
|
// Clients
|
|
26
26
|
export { QuoteClient, parseOptionIdentifier } from './quote/index.js';
|
|
27
27
|
export { TradeClient } from './trade/index.js';
|
|
28
|
+
export { NewsClient } from './news/index.js';
|
|
28
29
|
export { PushClient, ConnectionState, SubjectType } from './push/index.js';
|
|
29
30
|
export { marketOrder, limitOrder, stopOrder, stopLimitOrder } from './model/order-helpers.js';
|
|
30
31
|
export { normalizeOrderStatus } from './model/order-status.js';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NewsClient — 资讯客户端(news_stock_list / news_highlight_list)。
|
|
3
|
+
*
|
|
4
|
+
* 路由约定(对齐 Java SDK 的 MethodType.NEWS):
|
|
5
|
+
* 资讯接口走主网关(config.serverUrl,与交易域同一路由),**不走行情域名**
|
|
6
|
+
* (config.quoteServerUrl)。本 SDK 的路由在 HttpClient 构造期决定——
|
|
7
|
+
* QuoteClient 以 useQuoteServerUrl 指向行情域名,其余客户端(TradeClient、
|
|
8
|
+
* NewsClient)默认指向主网关——因此 NewsClient 永远不传 useQuoteServerUrl。
|
|
9
|
+
*
|
|
10
|
+
* 请求参数 TypeScript 侧 camelCase,自动转为 wire snake_case;响应出参为
|
|
11
|
+
* camelCase,无需转换。
|
|
12
|
+
*/
|
|
13
|
+
import { HttpClient } from '../client/http-client.js';
|
|
14
|
+
import { createApiRequest } from '../client/api-request.js';
|
|
15
|
+
import { unmarshalData } from '../client/api-response.js';
|
|
16
|
+
/** 资讯客户端:个股新闻列表与市场要闻列表。 */
|
|
17
|
+
export class NewsClient {
|
|
18
|
+
constructor(httpClient, options) {
|
|
19
|
+
this.httpClient = httpClient;
|
|
20
|
+
this.defaultLang = options?.lang || undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 从 ClientConfig 直接创建 NewsClient——主网关路由,默认语言取
|
|
24
|
+
* config.language。
|
|
25
|
+
*/
|
|
26
|
+
static fromConfig(config) {
|
|
27
|
+
// 资讯走主网关:不传 useQuoteServerUrl(对照 QuoteClient 的构造方式)。
|
|
28
|
+
return new NewsClient(new HttpClient(config), { lang: config.language });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 查询个股新闻列表(wire: news_stock_list)。
|
|
32
|
+
*
|
|
33
|
+
* @param req - symbol 必填(单标的,该接口不支持批量查询);
|
|
34
|
+
* pageCount / pageSize 可选(缺省服务端默认 1 / 20);
|
|
35
|
+
* lang 可选('zh_CN' / 'zh_TW' / 'en_US')
|
|
36
|
+
* @returns 分页信封 NewsPage;空列表属正常成功返回
|
|
37
|
+
*/
|
|
38
|
+
async getStockNews(req) {
|
|
39
|
+
const page = await this.callInto('news_stock_list', {
|
|
40
|
+
symbol: req.symbol,
|
|
41
|
+
pageCount: req.pageCount,
|
|
42
|
+
pageSize: req.pageSize,
|
|
43
|
+
lang: this.resolveLang(req.lang),
|
|
44
|
+
});
|
|
45
|
+
return page ?? { items: [] };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 查询市场要闻列表(wire: news_highlight_list)。
|
|
49
|
+
*
|
|
50
|
+
* 翻页只走 lastId 游标:把上一页 items 最后一条的 id 作为 lastId 传入
|
|
51
|
+
* 即取下一页;不传从最新开始。本接口无 page_count / page_size,响应
|
|
52
|
+
* pageCount 恒为 1。
|
|
53
|
+
*
|
|
54
|
+
* @param req - 全部字段可选,不传即从最新开始
|
|
55
|
+
* @returns 分页信封 NewsPage;空列表属正常成功返回
|
|
56
|
+
*/
|
|
57
|
+
async getMarketNews(req) {
|
|
58
|
+
const body = {};
|
|
59
|
+
if (req?.lastId !== undefined) {
|
|
60
|
+
body['lastId'] = req.lastId;
|
|
61
|
+
}
|
|
62
|
+
const lang = this.resolveLang(req?.lang);
|
|
63
|
+
if (lang !== undefined) {
|
|
64
|
+
body['lang'] = lang;
|
|
65
|
+
}
|
|
66
|
+
const page = await this.callInto('news_highlight_list', body);
|
|
67
|
+
return page ?? { items: [] };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 解析生效的 lang:显式传值原样透传,缺省回退客户端默认语言。
|
|
71
|
+
*/
|
|
72
|
+
resolveLang(lang) {
|
|
73
|
+
return lang !== undefined ? lang : this.defaultLang;
|
|
74
|
+
}
|
|
75
|
+
async callInto(method, bizParams) {
|
|
76
|
+
const request = createApiRequest(method, bizParams);
|
|
77
|
+
const response = await this.httpClient.executeRequest(request);
|
|
78
|
+
return unmarshalData(response.data);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
2
|
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.11.
|
|
3
|
+
// protoc-gen-ts_proto v2.11.8
|
|
4
4
|
// protoc v5.28.3
|
|
5
5
|
// source: QuoteBasicData.proto
|
|
6
6
|
/* eslint-disable */
|
|
@@ -32,6 +32,9 @@ function createBaseQuoteBasicData() {
|
|
|
32
32
|
minTick: undefined,
|
|
33
33
|
mi: undefined,
|
|
34
34
|
volumeDecimal: undefined,
|
|
35
|
+
cumVolume: undefined,
|
|
36
|
+
cumAmount: undefined,
|
|
37
|
+
session: undefined,
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
export const QuoteBasicData = {
|
|
@@ -105,6 +108,15 @@ export const QuoteBasicData = {
|
|
|
105
108
|
if (message.volumeDecimal !== undefined) {
|
|
106
109
|
writer.uint32(233).double(message.volumeDecimal);
|
|
107
110
|
}
|
|
111
|
+
if (message.cumVolume !== undefined) {
|
|
112
|
+
writer.uint32(240).sint64(message.cumVolume);
|
|
113
|
+
}
|
|
114
|
+
if (message.cumAmount !== undefined) {
|
|
115
|
+
writer.uint32(249).double(message.cumAmount);
|
|
116
|
+
}
|
|
117
|
+
if (message.session !== undefined) {
|
|
118
|
+
writer.uint32(258).string(message.session);
|
|
119
|
+
}
|
|
108
120
|
return writer;
|
|
109
121
|
},
|
|
110
122
|
decode(input, length) {
|
|
@@ -275,6 +287,27 @@ export const QuoteBasicData = {
|
|
|
275
287
|
message.volumeDecimal = reader.double();
|
|
276
288
|
continue;
|
|
277
289
|
}
|
|
290
|
+
case 30: {
|
|
291
|
+
if (tag !== 240) {
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
message.cumVolume = longToNumber(reader.sint64());
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
case 31: {
|
|
298
|
+
if (tag !== 249) {
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
message.cumAmount = reader.double();
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
case 32: {
|
|
305
|
+
if (tag !== 258) {
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
message.session = reader.string();
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
278
311
|
}
|
|
279
312
|
if ((tag & 7) === 4 || tag === 0) {
|
|
280
313
|
break;
|
|
@@ -311,6 +344,9 @@ export const QuoteBasicData = {
|
|
|
311
344
|
message.minTick = object.minTick ?? undefined;
|
|
312
345
|
message.mi = (object.mi !== undefined && object.mi !== null) ? QuoteData_Minute.fromPartial(object.mi) : undefined;
|
|
313
346
|
message.volumeDecimal = object.volumeDecimal ?? undefined;
|
|
347
|
+
message.cumVolume = object.cumVolume ?? undefined;
|
|
348
|
+
message.cumAmount = object.cumAmount ?? undefined;
|
|
349
|
+
message.session = object.session ?? undefined;
|
|
314
350
|
return message;
|
|
315
351
|
},
|
|
316
352
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
2
|
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.11.
|
|
3
|
+
// protoc-gen-ts_proto v2.11.8
|
|
4
4
|
// protoc v5.28.3
|
|
5
5
|
// source: QuoteData.proto
|
|
6
6
|
/* eslint-disable */
|
|
@@ -37,6 +37,9 @@ function createBaseQuoteData() {
|
|
|
37
37
|
minTick: undefined,
|
|
38
38
|
mi: undefined,
|
|
39
39
|
volumeDecimal: undefined,
|
|
40
|
+
cumVolume: undefined,
|
|
41
|
+
cumAmount: undefined,
|
|
42
|
+
session: undefined,
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
45
|
export const QuoteData = {
|
|
@@ -128,6 +131,15 @@ export const QuoteData = {
|
|
|
128
131
|
if (message.volumeDecimal !== undefined) {
|
|
129
132
|
writer.uint32(233).double(message.volumeDecimal);
|
|
130
133
|
}
|
|
134
|
+
if (message.cumVolume !== undefined) {
|
|
135
|
+
writer.uint32(240).sint64(message.cumVolume);
|
|
136
|
+
}
|
|
137
|
+
if (message.cumAmount !== undefined) {
|
|
138
|
+
writer.uint32(249).double(message.cumAmount);
|
|
139
|
+
}
|
|
140
|
+
if (message.session !== undefined) {
|
|
141
|
+
writer.uint32(258).string(message.session);
|
|
142
|
+
}
|
|
131
143
|
return writer;
|
|
132
144
|
},
|
|
133
145
|
decode(input, length) {
|
|
@@ -340,6 +352,27 @@ export const QuoteData = {
|
|
|
340
352
|
message.volumeDecimal = reader.double();
|
|
341
353
|
continue;
|
|
342
354
|
}
|
|
355
|
+
case 30: {
|
|
356
|
+
if (tag !== 240) {
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
message.cumVolume = longToNumber(reader.sint64());
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
case 31: {
|
|
363
|
+
if (tag !== 249) {
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
message.cumAmount = reader.double();
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
case 32: {
|
|
370
|
+
if (tag !== 258) {
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
message.session = reader.string();
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
343
376
|
}
|
|
344
377
|
if ((tag & 7) === 4 || tag === 0) {
|
|
345
378
|
break;
|
|
@@ -382,6 +415,9 @@ export const QuoteData = {
|
|
|
382
415
|
message.minTick = object.minTick ?? undefined;
|
|
383
416
|
message.mi = (object.mi !== undefined && object.mi !== null) ? QuoteData_Minute.fromPartial(object.mi) : undefined;
|
|
384
417
|
message.volumeDecimal = object.volumeDecimal ?? undefined;
|
|
418
|
+
message.cumVolume = object.cumVolume ?? undefined;
|
|
419
|
+
message.cumAmount = object.cumAmount ?? undefined;
|
|
420
|
+
message.session = object.session ?? undefined;
|
|
385
421
|
return message;
|
|
386
422
|
},
|
|
387
423
|
};
|
|
@@ -200,7 +200,7 @@ export const Request_Connect = {
|
|
|
200
200
|
},
|
|
201
201
|
};
|
|
202
202
|
function createBaseRequest_Subscribe() {
|
|
203
|
-
return { dataType: 0, symbols: undefined, account: undefined, market: undefined };
|
|
203
|
+
return { dataType: 0, symbols: undefined, account: undefined, market: undefined, assetQuoteType: undefined };
|
|
204
204
|
}
|
|
205
205
|
export const Request_Subscribe = {
|
|
206
206
|
encode(message, writer = new BinaryWriter()) {
|
|
@@ -216,6 +216,9 @@ export const Request_Subscribe = {
|
|
|
216
216
|
if (message.market !== undefined) {
|
|
217
217
|
writer.uint32(34).string(message.market);
|
|
218
218
|
}
|
|
219
|
+
if (message.assetQuoteType !== undefined) {
|
|
220
|
+
writer.uint32(42).string(message.assetQuoteType);
|
|
221
|
+
}
|
|
219
222
|
return writer;
|
|
220
223
|
},
|
|
221
224
|
decode(input, length) {
|
|
@@ -253,6 +256,13 @@ export const Request_Subscribe = {
|
|
|
253
256
|
message.market = reader.string();
|
|
254
257
|
continue;
|
|
255
258
|
}
|
|
259
|
+
case 5: {
|
|
260
|
+
if (tag !== 42) {
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
message.assetQuoteType = reader.string();
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
256
266
|
}
|
|
257
267
|
if ((tag & 7) === 4 || tag === 0) {
|
|
258
268
|
break;
|
|
@@ -270,6 +280,7 @@ export const Request_Subscribe = {
|
|
|
270
280
|
message.symbols = object.symbols ?? undefined;
|
|
271
281
|
message.account = object.account ?? undefined;
|
|
272
282
|
message.market = object.market ?? undefined;
|
|
283
|
+
message.assetQuoteType = object.assetQuoteType ?? undefined;
|
|
273
284
|
return message;
|
|
274
285
|
},
|
|
275
286
|
};
|
|
@@ -45,8 +45,11 @@ export function buildHeartBeatMessage() {
|
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* 构建 SUBSCRIBE 请求消息
|
|
48
|
+
*
|
|
49
|
+
* @param assetQuoteType 资产行情类型枚举名(ETH / RTH / OVERNIGHT),
|
|
50
|
+
* 仅对 Asset / Position 两种订阅有意义,其余场景传 undefined
|
|
48
51
|
*/
|
|
49
|
-
export function buildSubscribeMessage(dataType, symbols, account, market) {
|
|
52
|
+
export function buildSubscribeMessage(dataType, symbols, account, market, assetQuoteType) {
|
|
50
53
|
return Request.fromPartial({
|
|
51
54
|
command: SocketCommon_Command.SUBSCRIBE,
|
|
52
55
|
id: nextRequestId(),
|
|
@@ -55,6 +58,7 @@ export function buildSubscribeMessage(dataType, symbols, account, market) {
|
|
|
55
58
|
symbols,
|
|
56
59
|
account,
|
|
57
60
|
market,
|
|
61
|
+
assetQuoteType,
|
|
58
62
|
}),
|
|
59
63
|
});
|
|
60
64
|
}
|
|
@@ -59,6 +59,8 @@ export class PushClient {
|
|
|
59
59
|
this.subscriptions = new Map();
|
|
60
60
|
/** Account-level subscriptions: subject -> account string used at subscribe time */
|
|
61
61
|
this.accountSubs = new Map();
|
|
62
|
+
/** Account-level subscriptions: subject -> assetQuoteType used at subscribe time (reconnect replay) */
|
|
63
|
+
this.accountSubQuoteTypes = new Map();
|
|
62
64
|
this.heartbeatTimer = null;
|
|
63
65
|
this.reconnectTimer = null;
|
|
64
66
|
this.stopped = false;
|
|
@@ -319,7 +321,7 @@ export class PushClient {
|
|
|
319
321
|
this.doSubscribe(subject, Array.from(symbols));
|
|
320
322
|
}
|
|
321
323
|
for (const [subject, account] of this.accountSubs) {
|
|
322
|
-
this.doSubscribe(subject, undefined, account);
|
|
324
|
+
this.doSubscribe(subject, undefined, account, undefined, this.accountSubQuoteTypes.get(subject));
|
|
323
325
|
}
|
|
324
326
|
}
|
|
325
327
|
/** Dispatch push data to the appropriate callback based on dataType */
|
|
@@ -389,10 +391,10 @@ export class PushClient {
|
|
|
389
391
|
}
|
|
390
392
|
}
|
|
391
393
|
/** Internal subscribe method */
|
|
392
|
-
doSubscribe(subject, symbols, account, market) {
|
|
394
|
+
doSubscribe(subject, symbols, account, market, assetQuoteType) {
|
|
393
395
|
const dataType = subjectToDataType(subject);
|
|
394
396
|
const symbolsStr = symbols ? symbols.join(',') : undefined;
|
|
395
|
-
const req = buildSubscribeMessage(dataType, symbolsStr, account, market);
|
|
397
|
+
const req = buildSubscribeMessage(dataType, symbolsStr, account, market, assetQuoteType);
|
|
396
398
|
this.sendMessage(req);
|
|
397
399
|
}
|
|
398
400
|
/** Internal unsubscribe method */
|
|
@@ -552,27 +554,41 @@ export class PushClient {
|
|
|
552
554
|
this.removeSubscription(SubjectType.Market, [market]);
|
|
553
555
|
}
|
|
554
556
|
// ===== Account push subscribe/unsubscribe =====
|
|
555
|
-
/**
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
557
|
+
/**
|
|
558
|
+
* Shared implementation for the account/options overloads of
|
|
559
|
+
* subscribeAsset / subscribePosition.
|
|
560
|
+
*/
|
|
561
|
+
subscribeAccount(subject, accountOrOptions) {
|
|
562
|
+
const opts = typeof accountOrOptions === 'string'
|
|
563
|
+
? { account: accountOrOptions }
|
|
564
|
+
: (accountOrOptions ?? {});
|
|
565
|
+
const acct = opts.account || this.config.account;
|
|
566
|
+
this.doSubscribe(subject, undefined, acct, undefined, opts.assetQuoteType);
|
|
567
|
+
this.accountSubs.set(subject, acct);
|
|
568
|
+
if (opts.assetQuoteType) {
|
|
569
|
+
this.accountSubQuoteTypes.set(subject, opts.assetQuoteType);
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
this.accountSubQuoteTypes.delete(subject);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
subscribeAsset(accountOrOptions) {
|
|
576
|
+
this.subscribeAccount(SubjectType.Asset, accountOrOptions);
|
|
560
577
|
}
|
|
561
578
|
/** Unsubscribe from asset changes */
|
|
562
579
|
unsubscribeAsset() {
|
|
563
580
|
this.doUnsubscribe(SubjectType.Asset);
|
|
564
581
|
this.accountSubs.delete(SubjectType.Asset);
|
|
582
|
+
this.accountSubQuoteTypes.delete(SubjectType.Asset);
|
|
565
583
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
const acct = account || this.config.account;
|
|
569
|
-
this.doSubscribe(SubjectType.Position, undefined, acct);
|
|
570
|
-
this.accountSubs.set(SubjectType.Position, acct);
|
|
584
|
+
subscribePosition(accountOrOptions) {
|
|
585
|
+
this.subscribeAccount(SubjectType.Position, accountOrOptions);
|
|
571
586
|
}
|
|
572
587
|
/** Unsubscribe from position changes */
|
|
573
588
|
unsubscribePosition() {
|
|
574
589
|
this.doUnsubscribe(SubjectType.Position);
|
|
575
590
|
this.accountSubs.delete(SubjectType.Position);
|
|
591
|
+
this.accountSubQuoteTypes.delete(SubjectType.Position);
|
|
576
592
|
}
|
|
577
593
|
/** Subscribe to order status */
|
|
578
594
|
subscribeOrder(account) {
|
|
@@ -208,8 +208,9 @@ export class QuoteClient {
|
|
|
208
208
|
* If omitted, defaults to America/New_York for US symbols and Asia/Hong_Kong for .HK symbols.
|
|
209
209
|
* @param limit - Maximum number of bars to return.
|
|
210
210
|
* @param sortDir - Sort direction ('asc' or 'desc').
|
|
211
|
+
* @param withHourTrading - Include GTH/CURB minute bars; omitted preserves the server default.
|
|
211
212
|
*/
|
|
212
|
-
async getOptionKline(identifiers, period, beginTime = -1, endTime = -1, timezone, limit, sortDir) {
|
|
213
|
+
async getOptionKline(identifiers, period, beginTime = -1, endTime = -1, timezone, limit, sortDir, withHourTrading) {
|
|
213
214
|
const resolvedBegin = beginTime === 0 ? -1 : beginTime;
|
|
214
215
|
const resolvedEnd = endTime === 0 ? -1 : endTime;
|
|
215
216
|
const optionQuery = identifiers.map((id) => {
|
|
@@ -227,6 +228,8 @@ export class QuoteClient {
|
|
|
227
228
|
entry['limit'] = limit;
|
|
228
229
|
if (sortDir !== undefined && sortDir !== '')
|
|
229
230
|
entry['sort_dir'] = sortDir;
|
|
231
|
+
if (withHourTrading !== undefined)
|
|
232
|
+
entry['with_hour_trading'] = withHourTrading;
|
|
230
233
|
return entry;
|
|
231
234
|
});
|
|
232
235
|
return this.callInto('option_kline', { option_query: optionQuery }, '2.0');
|