tigeropen 0.5.7 → 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 +146 -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/quote/quote-client.js +4 -1
- package/dist/cjs/trade/trade-client.js +14 -2
- 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/push/pb/QuoteBasicData.js +37 -1
- package/dist/esm/push/pb/QuoteData.js +37 -1
- package/dist/esm/quote/quote-client.js +4 -1
- package/dist/esm/trade/trade-client.js +14 -2
- package/dist/esm/version.js +1 -1
- package/dist/types/index.d.ts +6 -2
- 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 +16 -0
- package/dist/types/model/trade-requests.d.ts +2 -1
- package/dist/types/news/index.d.ts +5 -0
- package/dist/types/news/news-client.d.ts +60 -0
- package/dist/types/push/pb/QuoteBasicData.d.ts +14 -5
- package/dist/types/push/pb/QuoteData.d.ts +14 -5
- package/dist/types/quote/quote-client.d.ts +2 -1
- package/dist/types/trade/trade-client.d.ts +2 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/auth/authentication.js +0 -74
- package/dist/cjs/auth/index.js +0 -24
- package/dist/cjs/auth/oauth2/client-registration.js +0 -44
- package/dist/cjs/auth/oauth2/device-authorization.js +0 -40
- package/dist/cjs/auth/oauth2/errors.js +0 -64
- package/dist/cjs/auth/oauth2/http-utils.js +0 -112
- package/dist/cjs/auth/oauth2/index.js +0 -42
- package/dist/cjs/auth/oauth2/loopback-receiver.js +0 -215
- package/dist/cjs/auth/oauth2/metadata.js +0 -34
- package/dist/cjs/auth/oauth2/oauth2-authentication.js +0 -74
- package/dist/cjs/auth/oauth2/session-manager.js +0 -762
- package/dist/cjs/auth/oauth2/token-store.js +0 -252
- package/dist/cjs/auth/oauth2/token.js +0 -76
- package/dist/esm/auth/authentication.js +0 -68
- package/dist/esm/auth/index.js +0 -3
- package/dist/esm/auth/oauth2/client-registration.js +0 -40
- package/dist/esm/auth/oauth2/device-authorization.js +0 -36
- package/dist/esm/auth/oauth2/errors.js +0 -59
- package/dist/esm/auth/oauth2/http-utils.js +0 -105
- package/dist/esm/auth/oauth2/index.js +0 -11
- package/dist/esm/auth/oauth2/loopback-receiver.js +0 -178
- package/dist/esm/auth/oauth2/metadata.js +0 -30
- package/dist/esm/auth/oauth2/oauth2-authentication.js +0 -70
- package/dist/esm/auth/oauth2/session-manager.js +0 -725
- package/dist/esm/auth/oauth2/token-store.js +0 -214
- package/dist/esm/auth/oauth2/token.js +0 -71
- package/dist/types/auth/authentication.d.ts +0 -98
- package/dist/types/auth/index.d.ts +0 -4
- package/dist/types/auth/oauth2/client-registration.d.ts +0 -32
- package/dist/types/auth/oauth2/device-authorization.d.ts +0 -40
- package/dist/types/auth/oauth2/errors.d.ts +0 -46
- package/dist/types/auth/oauth2/http-utils.d.ts +0 -21
- package/dist/types/auth/oauth2/index.d.ts +0 -16
- package/dist/types/auth/oauth2/loopback-receiver.d.ts +0 -29
- package/dist/types/auth/oauth2/metadata.d.ts +0 -32
- package/dist/types/auth/oauth2/oauth2-authentication.d.ts +0 -31
- package/dist/types/auth/oauth2/session-manager.d.ts +0 -241
- package/dist/types/auth/oauth2/token-store.d.ts +0 -49
- package/dist/types/auth/oauth2/token.d.ts +0 -56
|
@@ -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
|
};
|
|
@@ -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');
|
|
@@ -199,11 +199,23 @@ export class TradeClient {
|
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* Get a single order by ID (v0.4.0 new).
|
|
202
|
-
*
|
|
202
|
+
* Wire method: `orders` with `id` / `order_id` parameters.
|
|
203
|
+
* Returns `undefined` if no match or the result contains multiple orders.
|
|
203
204
|
*/
|
|
204
205
|
async getOrder(req) {
|
|
205
206
|
const merged = withAccount(req, this.account);
|
|
206
|
-
const
|
|
207
|
+
const data = await this.callInto('orders', merged);
|
|
208
|
+
let out;
|
|
209
|
+
if (Array.isArray(data)) {
|
|
210
|
+
out = data.length === 1 ? data[0] : undefined;
|
|
211
|
+
}
|
|
212
|
+
else if (data && typeof data === 'object' && 'items' in data) {
|
|
213
|
+
const items = data.items;
|
|
214
|
+
out = Array.isArray(items) && items.length === 1 ? items[0] : undefined;
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
out = data;
|
|
218
|
+
}
|
|
207
219
|
if (!out || (!out.id && !out.orderId))
|
|
208
220
|
return undefined;
|
|
209
221
|
normalizeOrderInPlace(out);
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = '0.5.
|
|
1
|
+
export const SDK_VERSION = '0.5.8';
|
package/dist/types/index.d.ts
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,8 @@ export { TigerError, classifyErrorCode } from './client';
|
|
|
25
25
|
export type { ErrorCategory } from './client';
|
|
26
26
|
export { QuoteClient, parseOptionIdentifier } from './quote';
|
|
27
27
|
export { TradeClient } from './trade';
|
|
28
|
+
export { NewsClient } from './news';
|
|
29
|
+
export type { NewsClientOptions } from './news';
|
|
28
30
|
export { PushClient, ConnectionState, SubjectType } from './push';
|
|
29
31
|
export type { PushClientOptions, AccountSubscribeOptions } from './push';
|
|
30
32
|
export type { Order, OrderRequest, ContractLegRequest } from './model/order';
|
|
@@ -34,6 +36,8 @@ export type { Contract } from './model/contract';
|
|
|
34
36
|
export type { Position } from './model/position';
|
|
35
37
|
export type { Asset, AssetSegment, PrimeAsset, PreviewResult, PlaceOrderResult, OrderIdResult, Transaction, ManagedAccount, AnalyticsAsset, AggregateAssets, EstimateTradableQuantity, ForexOrderResult, SegmentFund, SegmentFundAvailableItem, SegmentFundHistoryItem, FundDetails, FundingHistoryItem, PositionTransferRecord, PositionTransferDetail, PositionTransferExternalRecord, OptionExerciseCheckResult, OptionExercisePositionPageResult, OptionExerciseRecordPageResult, } from './model/trade';
|
|
36
38
|
export type { OrdersRequest, GetOrderRequest, OrderTransactionsRequest, PositionsRequest, AssetsRequest, ManagedAccountsRequest, DerivativeContractsRequest, AnalyticsAssetRequest, AggregateAssetsRequest, EstimateTradableQuantityRequest, ForexOrderRequest, SegmentFundRequest, FundDetailsRequest, FundingHistoryRequest, PositionTransferRequest, PositionTransferRecordsRequest, PositionTransferDetailRequest, PositionTransferExternalRecordsRequest, OptionExerciseCheckRequest, OptionExercisePositionRequest, OptionExerciseSubmitRequest, OptionExerciseRecordsRequest, OptionExerciseCancelRequest, } from './model/trade-requests';
|
|
37
|
-
export type { MarketState, Brief, Kline, KlineItem, Timeline, TimelineItem, TradeTick, TradeTickItem, Depth, DepthLevel, OptionExpiration, OptionChain, OptionChainRow, OptionSymbol, OptionChainFilter, OptionChainFilterGreeks, Range, FutureExchange, FutureContractInfo, FutureQuote, FutureKline, FutureKlineItem, FutureDepth, FutureTradeTickItem, FutureTradingTime, FinancialDailyItem, FinancialReportItem, CorporateAction, CorporateSymbolChange, CorporateDelisting, CorporateIPO, CapitalFlow, CapitalFlowItem, CapitalDistribution, ScannerResult, ScannerResultItem, QuotePermission, SymbolName, TradeMeta, StockDetail, StockBroker, StockBrokerItem, ShortInterest, StockIndustry, IndustryItem, IndustryStock, WarrantBrief, WarrantFilterResult, FundContractInfo, FundQuote, FundHistoryQuote, QuoteOvernight, KlineQuota, MarketScannerTag, MarketScannerTags, OptionAnalysis, OptionLeg, OptionVolatilityPoint, ExchangeRate, FinancialCurrency, BrokerDetail, TradingCalendarItem, FutureMainContractHistory, } from './model/quote';
|
|
39
|
+
export type { MarketState, Brief, Kline, KlineItem, Timeline, TimelineItem, TradeTick, TradeTickItem, Depth, DepthLevel, OptionExpiration, OptionHourTrading, OptionChain, OptionChainRow, OptionSymbol, OptionChainFilter, OptionChainFilterGreeks, Range, FutureExchange, FutureContractInfo, FutureQuote, FutureKline, FutureKlineItem, FutureDepth, FutureTradeTickItem, FutureTradingTime, FinancialDailyItem, FinancialReportItem, CorporateAction, CorporateSymbolChange, CorporateDelisting, CorporateIPO, CapitalFlow, CapitalFlowItem, CapitalDistribution, ScannerResult, ScannerResultItem, QuotePermission, SymbolName, TradeMeta, StockDetail, StockBroker, StockBrokerItem, ShortInterest, StockIndustry, IndustryItem, IndustryStock, WarrantBrief, WarrantFilterResult, FundContractInfo, FundQuote, FundHistoryQuote, QuoteOvernight, KlineQuota, MarketScannerTag, MarketScannerTags, OptionAnalysis, OptionLeg, OptionVolatilityPoint, ExchangeRate, FinancialCurrency, BrokerDetail, TradingCalendarItem, FutureMainContractHistory, } from './model/quote';
|
|
38
40
|
export type { BriefRequest, DepthQuoteRequest, TradeTickRequest, KlineRequest, KlineByPageRequest, TimelineRequest, FutureBriefRequest, FutureKlineRequest, FutureKlineByPageRequest, FutureTradeTicksRequest, FutureDepthRequest, FutureContractSingleRequest, FutureContinuousContractsRequest, FutureHistoryMainContractRequest, FutureTradingTimesRequest, AllFutureContractsRequest, OptionTradeTicksRequest, OptionTimelineRequest, OptionDepthRequest, OptionSymbolsRequest, OptionAnalysisRequest, OptionQueryItem, ShortInterestRequest, StockBrokerRequest, StockDetailsRequest, StockFundamentalRequest, StockIndustryRequest, StockDelayBriefsRequest, SymbolsRequest, TradeMetasRequest, TradeRankRequest, TimelineHistoryRequest, TradingCalendarRequest, KlineQuotaRequest, QuotePermissionRequest, QuoteOvernightRequest, IndustryListRequest, IndustryStocksRequest, FundSymbolsRequest, FundContractsRequest, FundQuoteRequest, FundHistoryQuoteRequest, WarrantBriefsRequest, WarrantFilterRequest, MarketScannerTagsRequest, FinancialCurrencyRequest, FinancialExchangeRateRequest, } from './model/quote-requests';
|
|
41
|
+
export type { NewsItem, NewsPage } from './model/news';
|
|
42
|
+
export type { NewsStockListRequest, NewsHighlightListRequest } from './model/news-requests';
|
|
39
43
|
export { OrderStatus, SecurityType, OrderType, TimeInForce, Market, Currency, QuoteRight, SegmentType, OrderSortBy, CorporateActionType, IndustryLevel, SortDirection, OptionAnalysisPeriod, FinancialReportPeriod, Language, License, BarPeriod, orderStatusCode, } from './model/enums';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 资讯请求参数模型(wire: news_stock_list / news_highlight_list)。
|
|
3
|
+
*
|
|
4
|
+
* TypeScript 侧使用 camelCase,序列化时由 createApiRequest 自动转为
|
|
5
|
+
* snake_case(契约决策 #13:入参 snake_case)。可选字段不传时不出现在
|
|
6
|
+
* biz_content 中,由服务端取缺省值。
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 个股新闻列表请求。wire: news_stock_list
|
|
10
|
+
*
|
|
11
|
+
* symbol 单标的必填(下游资讯服务实际不支持批量查询,契约决策 #5);
|
|
12
|
+
* pageCount / pageSize 缺省时服务端默认 1 / 20(决策 #6);
|
|
13
|
+
* lang 可选('zh_CN' / 'zh_TW' / 'en_US')。
|
|
14
|
+
*/
|
|
15
|
+
export interface NewsStockListRequest {
|
|
16
|
+
/** 股票代码,必填、单标的(如 "AAPL",该接口不支持批量查询) */
|
|
17
|
+
symbol: string;
|
|
18
|
+
/** 页码,缺省 = 1;显式传值须 >= 1(越界由服务端报参数错误) */
|
|
19
|
+
pageCount?: number;
|
|
20
|
+
/** 每页条数,缺省 = 20;显式传值须 1-50(闭区间) */
|
|
21
|
+
pageSize?: number;
|
|
22
|
+
/** 内容语言:'zh_CN' / 'zh_TW' / 'en_US' */
|
|
23
|
+
lang?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 市场要闻列表请求。wire: news_highlight_list
|
|
27
|
+
*
|
|
28
|
+
* 翻页只走 lastId 游标(契约决策 #14,该接口无 page_count / page_size);
|
|
29
|
+
* lang 语义同 NewsStockListRequest。
|
|
30
|
+
*/
|
|
31
|
+
export interface NewsHighlightListRequest {
|
|
32
|
+
/**
|
|
33
|
+
* 游标翻页:取上一页 items 最后一条的 id;不传从最新开始。
|
|
34
|
+
* 这是本接口唯一的翻页方式。
|
|
35
|
+
*/
|
|
36
|
+
lastId?: string;
|
|
37
|
+
/** 内容语言:'zh_CN' / 'zh_TW' / 'en_US' */
|
|
38
|
+
lang?: string;
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 资讯数据模型(news_stock_list / news_highlight_list 共用)。
|
|
3
|
+
*
|
|
4
|
+
* 服务端响应出参为 camelCase(契约决策 #13),与 TypeScript 字段名一致,
|
|
5
|
+
* 响应侧无需命名转换。
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 资讯条目(news_stock_list 与 news_highlight_list 共用,契约 §3.3)。
|
|
9
|
+
*/
|
|
10
|
+
export interface NewsItem {
|
|
11
|
+
/** 资讯 ID(同时是 highlight 游标翻页 last_id 的取值来源) */
|
|
12
|
+
id?: string;
|
|
13
|
+
/** 标题 */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** 摘要 */
|
|
16
|
+
summary?: string;
|
|
17
|
+
/** 发布时间戳(秒级) */
|
|
18
|
+
pubTimestamp?: number;
|
|
19
|
+
/** 原文链接 */
|
|
20
|
+
url?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 资讯列表分页信封(news_stock_list 与 news_highlight_list 共用,契约 §3.3)。
|
|
24
|
+
*
|
|
25
|
+
* news_highlight_list 仅支持 last_id 游标翻页(决策 #14),其 pageCount 恒为 1。
|
|
26
|
+
*/
|
|
27
|
+
export interface NewsPage {
|
|
28
|
+
/** 当前页资讯列表(下游返回空 items 属正常成功) */
|
|
29
|
+
items: NewsItem[];
|
|
30
|
+
/** 当前页码(highlight 接口恒为 1) */
|
|
31
|
+
pageCount?: number;
|
|
32
|
+
/** 每页条数 */
|
|
33
|
+
pageSize?: number;
|
|
34
|
+
/** 总页数 */
|
|
35
|
+
totalPage?: number;
|
|
36
|
+
/** 总条数 */
|
|
37
|
+
totalSize?: number;
|
|
38
|
+
}
|
|
@@ -9,7 +9,20 @@ export interface MarketState {
|
|
|
9
9
|
status: string;
|
|
10
10
|
openTime?: string;
|
|
11
11
|
}
|
|
12
|
+
/** Current GTH/CURB option quote. Absent/null during regular trading. */
|
|
13
|
+
export interface OptionHourTrading {
|
|
14
|
+
tag?: string;
|
|
15
|
+
session?: string;
|
|
16
|
+
latestPrice?: number;
|
|
17
|
+
latestTimestamp?: number;
|
|
18
|
+
volume?: number;
|
|
19
|
+
amount?: number;
|
|
20
|
+
preClose?: number;
|
|
21
|
+
}
|
|
12
22
|
export interface Brief {
|
|
23
|
+
cumVolume?: number;
|
|
24
|
+
cumAmount?: number;
|
|
25
|
+
hourTrading?: OptionHourTrading | null;
|
|
13
26
|
symbol: string;
|
|
14
27
|
open?: number;
|
|
15
28
|
high?: number;
|
|
@@ -103,6 +116,9 @@ export interface OptionExpiration {
|
|
|
103
116
|
counts?: number[];
|
|
104
117
|
}
|
|
105
118
|
export interface OptionLeg {
|
|
119
|
+
cumVolume?: number;
|
|
120
|
+
cumAmount?: number;
|
|
121
|
+
hourTrading?: OptionHourTrading | null;
|
|
106
122
|
identifier: string;
|
|
107
123
|
strike: string;
|
|
108
124
|
right: string;
|
|
@@ -36,7 +36,8 @@ export interface GetOrderRequest {
|
|
|
36
36
|
account?: string;
|
|
37
37
|
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
38
38
|
secretKey?: string;
|
|
39
|
-
|
|
39
|
+
/** Global order ID; use a string for values above Number.MAX_SAFE_INTEGER. */
|
|
40
|
+
id?: number | string;
|
|
40
41
|
orderId?: number;
|
|
41
42
|
isBrief?: boolean;
|
|
42
43
|
showCharges?: boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
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';
|
|
14
|
+
import type { ClientConfig } from '../config/client-config';
|
|
15
|
+
import type { NewsPage } from '../model/news';
|
|
16
|
+
import type { NewsStockListRequest, NewsHighlightListRequest } from '../model/news-requests';
|
|
17
|
+
/** NewsClient construction options. */
|
|
18
|
+
export interface NewsClientOptions {
|
|
19
|
+
/**
|
|
20
|
+
* 默认语言('zh_CN' / 'zh_TW' / 'en_US'):请求未显携带 lang 时注入
|
|
21
|
+
* biz_content。fromConfig 自动取 config.language。
|
|
22
|
+
*/
|
|
23
|
+
lang?: string;
|
|
24
|
+
}
|
|
25
|
+
/** 资讯客户端:个股新闻列表与市场要闻列表。 */
|
|
26
|
+
export declare class NewsClient {
|
|
27
|
+
private httpClient;
|
|
28
|
+
private defaultLang;
|
|
29
|
+
constructor(httpClient: HttpClient, options?: NewsClientOptions);
|
|
30
|
+
/**
|
|
31
|
+
* 从 ClientConfig 直接创建 NewsClient——主网关路由,默认语言取
|
|
32
|
+
* config.language。
|
|
33
|
+
*/
|
|
34
|
+
static fromConfig(config: ClientConfig): NewsClient;
|
|
35
|
+
/**
|
|
36
|
+
* 查询个股新闻列表(wire: news_stock_list)。
|
|
37
|
+
*
|
|
38
|
+
* @param req - symbol 必填(单标的,该接口不支持批量查询);
|
|
39
|
+
* pageCount / pageSize 可选(缺省服务端默认 1 / 20);
|
|
40
|
+
* lang 可选('zh_CN' / 'zh_TW' / 'en_US')
|
|
41
|
+
* @returns 分页信封 NewsPage;空列表属正常成功返回
|
|
42
|
+
*/
|
|
43
|
+
getStockNews(req: NewsStockListRequest): Promise<NewsPage>;
|
|
44
|
+
/**
|
|
45
|
+
* 查询市场要闻列表(wire: news_highlight_list)。
|
|
46
|
+
*
|
|
47
|
+
* 翻页只走 lastId 游标:把上一页 items 最后一条的 id 作为 lastId 传入
|
|
48
|
+
* 即取下一页;不传从最新开始。本接口无 page_count / page_size,响应
|
|
49
|
+
* pageCount 恒为 1。
|
|
50
|
+
*
|
|
51
|
+
* @param req - 全部字段可选,不传即从最新开始
|
|
52
|
+
* @returns 分页信封 NewsPage;空列表属正常成功返回
|
|
53
|
+
*/
|
|
54
|
+
getMarketNews(req?: NewsHighlightListRequest): Promise<NewsPage>;
|
|
55
|
+
/**
|
|
56
|
+
* 解析生效的 lang:显式传值原样透传,缺省回退客户端默认语言。
|
|
57
|
+
*/
|
|
58
|
+
private resolveLang;
|
|
59
|
+
private callInto;
|
|
60
|
+
}
|
|
@@ -12,15 +12,15 @@ export interface QuoteBasicData {
|
|
|
12
12
|
avgPrice?: number | undefined;
|
|
13
13
|
/** */
|
|
14
14
|
latestPrice?: number | undefined;
|
|
15
|
-
/**
|
|
15
|
+
/** Actual last-trade time (epoch ms) for the quoted session; 0 means no trade. */
|
|
16
16
|
latestPriceTimestamp?: number | undefined;
|
|
17
17
|
/** */
|
|
18
18
|
latestTime?: string | undefined;
|
|
19
19
|
/** */
|
|
20
20
|
preClose?: number | undefined;
|
|
21
|
-
/**
|
|
21
|
+
/** Volume of the quoted session; cumulative option volume is cumVolume. */
|
|
22
22
|
volume?: number | undefined;
|
|
23
|
-
/**
|
|
23
|
+
/** Amount of the quoted session; cumulative option amount is cumAmount. */
|
|
24
24
|
amount?: number | undefined;
|
|
25
25
|
/** Pre/Post-Mkt data not support */
|
|
26
26
|
open?: number | undefined;
|
|
@@ -28,7 +28,7 @@ export interface QuoteBasicData {
|
|
|
28
28
|
high?: number | undefined;
|
|
29
29
|
/** Pre/Post-Mkt data not support */
|
|
30
30
|
low?: number | undefined;
|
|
31
|
-
/**
|
|
31
|
+
/** Extended-session marker: PreMarket / AfterHours; absent for RTH. */
|
|
32
32
|
hourTradingTag?: string | undefined;
|
|
33
33
|
marketStatus?: string | undefined;
|
|
34
34
|
/** only Options support */
|
|
@@ -43,8 +43,17 @@ export interface QuoteBasicData {
|
|
|
43
43
|
minTick?: number | undefined;
|
|
44
44
|
/** minute data: price, average price, time, volume */
|
|
45
45
|
mi?: QuoteData_Minute | undefined;
|
|
46
|
-
/**
|
|
46
|
+
/** Trading volume encoded as a double; precision may be lost for large or fractional values. */
|
|
47
47
|
volumeDecimal?: number | undefined;
|
|
48
|
+
/** cumulative volume of CURB + RTH + GTH, only Options support */
|
|
49
|
+
cumVolume?: number | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Cumulative quote amount across CURB + RTH + GTH; same units as amount.
|
|
52
|
+
* Encoded as double; values may be rounded. Do not use for exact accounting.
|
|
53
|
+
*/
|
|
54
|
+
cumAmount?: number | undefined;
|
|
55
|
+
/** Quoted option session (GTH / CURB); absent when not provided. */
|
|
56
|
+
session?: string | undefined;
|
|
48
57
|
}
|
|
49
58
|
export declare const QuoteBasicData: MessageFns<QuoteBasicData>;
|
|
50
59
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
@@ -11,15 +11,15 @@ export interface QuoteData {
|
|
|
11
11
|
avgPrice?: number | undefined;
|
|
12
12
|
/** required when type is 'BASIC' */
|
|
13
13
|
latestPrice?: number | undefined;
|
|
14
|
-
/**
|
|
14
|
+
/** Actual last-trade time (epoch ms) for the quoted session; 0 means no trade. */
|
|
15
15
|
latestPriceTimestamp?: number | undefined;
|
|
16
16
|
/** required when type is 'BASIC' */
|
|
17
17
|
latestTime?: string | undefined;
|
|
18
18
|
/** required when type is 'BASIC' */
|
|
19
19
|
preClose?: number | undefined;
|
|
20
|
-
/**
|
|
20
|
+
/** Volume of the quoted session; cumulative option volume is cumVolume. */
|
|
21
21
|
volume?: number | undefined;
|
|
22
|
-
/**
|
|
22
|
+
/** Amount of the quoted session; cumulative option amount is cumAmount. */
|
|
23
23
|
amount?: number | undefined;
|
|
24
24
|
/** required when symbol in HK market */
|
|
25
25
|
open?: number | undefined;
|
|
@@ -27,7 +27,7 @@ export interface QuoteData {
|
|
|
27
27
|
high?: number | undefined;
|
|
28
28
|
/** required when symbol in HK market */
|
|
29
29
|
low?: number | undefined;
|
|
30
|
-
/**
|
|
30
|
+
/** Extended-session marker: PreMarket / AfterHours; absent for RTH. */
|
|
31
31
|
hourTradingTag?: string | undefined;
|
|
32
32
|
marketStatus?: string | undefined;
|
|
33
33
|
/** required when type is 'BBO' */
|
|
@@ -54,8 +54,17 @@ export interface QuoteData {
|
|
|
54
54
|
minTick?: number | undefined;
|
|
55
55
|
/** minute data: price, average price, time, volume */
|
|
56
56
|
mi?: QuoteData_Minute | undefined;
|
|
57
|
-
/**
|
|
57
|
+
/** Trading volume encoded as a double; precision may be lost for large or fractional values. */
|
|
58
58
|
volumeDecimal?: number | undefined;
|
|
59
|
+
/** cumulative volume of CURB + RTH + GTH, only Options support */
|
|
60
|
+
cumVolume?: number | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Cumulative quote amount across CURB + RTH + GTH; same units as amount.
|
|
63
|
+
* Encoded as double; values may be rounded. Do not use for exact accounting.
|
|
64
|
+
*/
|
|
65
|
+
cumAmount?: number | undefined;
|
|
66
|
+
/** Quoted option session (GTH / CURB); absent when not provided. */
|
|
67
|
+
session?: string | undefined;
|
|
59
68
|
}
|
|
60
69
|
export interface QuoteData_Minute {
|
|
61
70
|
/** last price of the minute bar */
|
|
@@ -79,8 +79,9 @@ export declare class QuoteClient {
|
|
|
79
79
|
* If omitted, defaults to America/New_York for US symbols and Asia/Hong_Kong for .HK symbols.
|
|
80
80
|
* @param limit - Maximum number of bars to return.
|
|
81
81
|
* @param sortDir - Sort direction ('asc' or 'desc').
|
|
82
|
+
* @param withHourTrading - Include GTH/CURB minute bars; omitted preserves the server default.
|
|
82
83
|
*/
|
|
83
|
-
getOptionKline(identifiers: string[], period: string, beginTime?: number, endTime?: number, timezone?: string, limit?: number, sortDir?: string): Promise<Kline[]>;
|
|
84
|
+
getOptionKline(identifiers: string[], period: string, beginTime?: number, endTime?: number, timezone?: string, limit?: number, sortDir?: string, withHourTrading?: boolean): Promise<Kline[]>;
|
|
84
85
|
/**
|
|
85
86
|
* Real-time option quotes by OCC-style identifier.
|
|
86
87
|
*
|
|
@@ -96,7 +96,8 @@ export declare class TradeClient {
|
|
|
96
96
|
getFilledOrders(req?: OrdersRequest): Promise<Order[]>;
|
|
97
97
|
/**
|
|
98
98
|
* Get a single order by ID (v0.4.0 new).
|
|
99
|
-
*
|
|
99
|
+
* Wire method: `orders` with `id` / `order_id` parameters.
|
|
100
|
+
* Returns `undefined` if no match or the result contains multiple orders.
|
|
100
101
|
*/
|
|
101
102
|
getOrder(req: GetOrderRequest): Promise<Order | undefined>;
|
|
102
103
|
/**
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.5.
|
|
1
|
+
export declare const SDK_VERSION = "0.5.8";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tigeropen",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "Tiger Brokers OpenAPI TypeScript SDK for market data, trading, and real-time push",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@bufbuild/protobuf": "^2.12.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "25b76514df4cb4f6668bf9ef95b76180abadc28e"
|
|
64
64
|
}
|