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
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ TypeScript SDK for Tiger Brokers OpenAPI — market data, trading, account manag
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
10
|
- Market data queries (quotes, klines, depth, options, futures)
|
|
11
|
+
- News queries for a single stock and market highlights
|
|
11
12
|
- Order placement, modification, cancellation, and account queries
|
|
12
13
|
- Real-time push via TCP + TLS + Protobuf (quotes, trades, account events)
|
|
13
14
|
- RSA request signing and Tiger public key response verification
|
|
@@ -207,6 +208,77 @@ const positions = await tc.positions();
|
|
|
207
208
|
const assets = await tc.assets();
|
|
208
209
|
```
|
|
209
210
|
|
|
211
|
+
## News
|
|
212
|
+
|
|
213
|
+
The SDK exposes two news query APIs. Both are routed to the **main gateway** (never the quote server):
|
|
214
|
+
|
|
215
|
+
| API | method | Description |
|
|
216
|
+
|-----|--------|-------------|
|
|
217
|
+
| Stock news | `news_stock_list` | News list for a single symbol, paged by `pageCount` / `pageSize` |
|
|
218
|
+
| Market highlights | `news_highlight_list` | Market highlights, paged by the `lastId` cursor |
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
import { createClientConfig } from '@tigeropenapi/tigeropen';
|
|
222
|
+
import { NewsClient } from '@tigeropenapi/tigeropen';
|
|
223
|
+
|
|
224
|
+
const config = createClientConfig();
|
|
225
|
+
const nc = NewsClient.fromConfig(config); // main-gateway routing
|
|
226
|
+
|
|
227
|
+
// Stock news for a single symbol
|
|
228
|
+
const page = await nc.getStockNews({ symbol: 'AAPL', lang: 'zh_CN', pageCount: 1, pageSize: 20 });
|
|
229
|
+
for (const item of page.items) {
|
|
230
|
+
console.log(item.title, '—', item.url);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Market highlights (first page starts from the newest)
|
|
234
|
+
const highlights = await nc.getMarketNews({ lang: 'zh_CN' });
|
|
235
|
+
// Next page: pass the id of the last item back as lastId
|
|
236
|
+
const lastId = highlights.items[highlights.items.length - 1]?.id;
|
|
237
|
+
const nextPage = await nc.getMarketNews({ lastId });
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Stock News
|
|
241
|
+
|
|
242
|
+
Parameters:
|
|
243
|
+
|
|
244
|
+
| Parameter | Required | Description |
|
|
245
|
+
|-----------|:--------:|-------------|
|
|
246
|
+
| `symbol` | Yes | Stock symbol. **Single symbol only** (batch queries are not supported) |
|
|
247
|
+
| `lang` | No | `zh_CN` / `zh_TW` / `en_US` |
|
|
248
|
+
| `pageCount` | No | Page number, default 1, must be >= 1 |
|
|
249
|
+
| `pageSize` | No | Page size, default 20, range 1–50 |
|
|
250
|
+
|
|
251
|
+
### Market Highlights
|
|
252
|
+
|
|
253
|
+
Parameters:
|
|
254
|
+
|
|
255
|
+
| Parameter | Required | Description |
|
|
256
|
+
|-----------|:--------:|-------------|
|
|
257
|
+
| `lang` | No | Same as above |
|
|
258
|
+
| `lastId` | No | Cursor. Omit to start from the newest; pass the `id` of the last item of the current page to get the next page. This is the only pagination path (the API has no `pageCount` / `pageSize`) |
|
|
259
|
+
|
|
260
|
+
### Response Structure
|
|
261
|
+
|
|
262
|
+
Both APIs return the same `NewsPage` shape:
|
|
263
|
+
|
|
264
|
+
| Field | Type | Description |
|
|
265
|
+
|-------|------|-------------|
|
|
266
|
+
| `items` | `NewsItem[]` | News items on the current page (empty items is a successful response) |
|
|
267
|
+
| `pageCount` | number | Current page number (always 1 for market highlights) |
|
|
268
|
+
| `pageSize` | number | Page size |
|
|
269
|
+
| `totalPage` | number | Total number of pages |
|
|
270
|
+
| `totalSize` | number | Total number of items |
|
|
271
|
+
|
|
272
|
+
`NewsItem`:
|
|
273
|
+
|
|
274
|
+
| Field | Type | Description |
|
|
275
|
+
|-------|------|-------------|
|
|
276
|
+
| `id` | string | News ID (also the `lastId` cursor source for highlights) |
|
|
277
|
+
| `title` | string | Title |
|
|
278
|
+
| `summary` | string | Summary |
|
|
279
|
+
| `pubTimestamp` | number | Publish timestamp in seconds |
|
|
280
|
+
| `url` | string | Link to the original article |
|
|
281
|
+
|
|
210
282
|
## Generic Execute
|
|
211
283
|
|
|
212
284
|
For APIs not yet wrapped by the SDK, use `HttpClient.execute` directly:
|
|
@@ -276,10 +348,24 @@ pc.disconnect();
|
|
|
276
348
|
| `subscribeFuture(symbols)` | Futures quotes | `onFuture(QuoteData)` |
|
|
277
349
|
| `subscribeKline(symbols)` | K-line data | `onKline(KlineData)` |
|
|
278
350
|
| `subscribeAsset(account?)` | Asset changes | `onAsset(AssetData)` |
|
|
351
|
+
| `subscribeAsset(options)` | Asset changes, `{ account?, assetQuoteType? }` | `onAsset(AssetData)` |
|
|
279
352
|
| `subscribePosition(account?)` | Position changes | `onPosition(PositionData)` |
|
|
353
|
+
| `subscribePosition(options)` | Position changes, `{ account?, assetQuoteType? }` | `onPosition(PositionData)` |
|
|
280
354
|
| `subscribeOrder(account?)` | Order status | `onOrder(OrderStatusData)` |
|
|
281
355
|
| `subscribeTransaction(account?)` | Transactions | `onTransaction(OrderTransactionData)` |
|
|
282
356
|
|
|
357
|
+
`assetQuoteType` selects the quote basis of the pushed asset / position data —
|
|
358
|
+
`'ETH'`, `'RTH'` or `'OVERNIGHT'`. Omit it to keep the server default.
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
pc.subscribeAsset({ assetQuoteType: 'OVERNIGHT' });
|
|
362
|
+
pc.subscribePosition({ account: 'U1234567', assetQuoteType: 'RTH' });
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
The same enum name is accepted as `assetQuoteType` on the HTTP side by
|
|
366
|
+
`getPositions` / `getAssets` / `getPrimeAssets` / `getAggregateAssets`
|
|
367
|
+
(wire name `asset_quote_type`).
|
|
368
|
+
|
|
283
369
|
## Project Structure
|
|
284
370
|
|
|
285
371
|
```
|
|
@@ -291,6 +377,7 @@ openapi-typescript-sdk/
|
|
|
291
377
|
│ ├── model/ # Data models and order helpers
|
|
292
378
|
│ ├── quote/ # Quote client (market data)
|
|
293
379
|
│ ├── trade/ # Trade client (orders, positions, assets)
|
|
380
|
+
│ ├── news/ # News client (stock news, market highlights)
|
|
294
381
|
│ ├── push/ # TCP+TLS push client (Protobuf)
|
|
295
382
|
│ ├── logger/ # Logger
|
|
296
383
|
│ └── index.ts # Public exports
|
|
@@ -331,6 +418,7 @@ const { createClientConfig } = require('@tigeropenapi/tigeropen');
|
|
|
331
418
|
## 功能特性
|
|
332
419
|
|
|
333
420
|
- 行情查询(报价、K 线、深度、期权、期货)
|
|
421
|
+
- 资讯查询(个股新闻、市场要闻)
|
|
334
422
|
- 订单操作(下单、改单、撤单)和账户查询
|
|
335
423
|
- 实时推送:TCP + TLS + Protobuf(行情、成交、账户事件)
|
|
336
424
|
- RSA 请求签名和老虎公钥响应验签
|
|
@@ -583,6 +671,77 @@ const positions = await tc.positions();
|
|
|
583
671
|
const assets = await tc.assets();
|
|
584
672
|
```
|
|
585
673
|
|
|
674
|
+
## 资讯查询
|
|
675
|
+
|
|
676
|
+
SDK 提供两个资讯查询接口,均路由到**主网关**(不走行情域名):
|
|
677
|
+
|
|
678
|
+
| 接口 | method | 说明 |
|
|
679
|
+
|------|--------|------|
|
|
680
|
+
| 个股新闻 | `news_stock_list` | 查询单只股票的资讯列表,按 `pageCount` / `pageSize` 翻页 |
|
|
681
|
+
| 市场要闻 | `news_highlight_list` | 查询市场要闻列表,按 `lastId` 游标翻页 |
|
|
682
|
+
|
|
683
|
+
```typescript
|
|
684
|
+
import { createClientConfig } from '@tigeropenapi/tigeropen';
|
|
685
|
+
import { NewsClient } from '@tigeropenapi/tigeropen';
|
|
686
|
+
|
|
687
|
+
const config = createClientConfig();
|
|
688
|
+
const nc = NewsClient.fromConfig(config); // 主网关路由
|
|
689
|
+
|
|
690
|
+
// 个股新闻(单标的)
|
|
691
|
+
const page = await nc.getStockNews({ symbol: 'AAPL', lang: 'zh_CN', pageCount: 1, pageSize: 20 });
|
|
692
|
+
for (const item of page.items) {
|
|
693
|
+
console.log(item.title, '—', item.url);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// 市场要闻(不传 lastId 从最新开始)
|
|
697
|
+
const highlights = await nc.getMarketNews({ lang: 'zh_CN' });
|
|
698
|
+
// 下一页:把本页最后一条的 id 作为 lastId 传回
|
|
699
|
+
const lastId = highlights.items[highlights.items.length - 1]?.id;
|
|
700
|
+
const nextPage = await nc.getMarketNews({ lastId });
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
### 个股新闻
|
|
704
|
+
|
|
705
|
+
参数说明:
|
|
706
|
+
|
|
707
|
+
| 参数 | 必填 | 说明 |
|
|
708
|
+
|------|:----:|------|
|
|
709
|
+
| `symbol` | 是 | 股票代码,**仅支持单只**(该接口不支持批量查询) |
|
|
710
|
+
| `lang` | 否 | 语言枚举:`zh_CN` / `zh_TW` / `en_US` |
|
|
711
|
+
| `pageCount` | 否 | 页码,默认 1,取值 >= 1 |
|
|
712
|
+
| `pageSize` | 否 | 每页条数,默认 20,取值 1–50 |
|
|
713
|
+
|
|
714
|
+
### 市场要闻
|
|
715
|
+
|
|
716
|
+
参数说明:
|
|
717
|
+
|
|
718
|
+
| 参数 | 必填 | 说明 |
|
|
719
|
+
|------|:----:|------|
|
|
720
|
+
| `lang` | 否 | 同上 |
|
|
721
|
+
| `lastId` | 否 | 游标。不传从最新开始;下一页传本页 `items` 最后一条的 `id`。这是唯一的翻页方式(该接口无 `pageCount` / `pageSize`) |
|
|
722
|
+
|
|
723
|
+
### 响应结构
|
|
724
|
+
|
|
725
|
+
两个接口返回同一 `NewsPage` 结构:
|
|
726
|
+
|
|
727
|
+
| 字段 | 类型 | 说明 |
|
|
728
|
+
|------|------|------|
|
|
729
|
+
| `items` | `NewsItem[]` | 当前页资讯列表(空 items 属正常成功返回) |
|
|
730
|
+
| `pageCount` | number | 当前页码(要闻接口恒为 1) |
|
|
731
|
+
| `pageSize` | number | 每页条数 |
|
|
732
|
+
| `totalPage` | number | 总页数 |
|
|
733
|
+
| `totalSize` | number | 总条数 |
|
|
734
|
+
|
|
735
|
+
`NewsItem`:
|
|
736
|
+
|
|
737
|
+
| 字段 | 类型 | 说明 |
|
|
738
|
+
|------|------|------|
|
|
739
|
+
| `id` | string | 资讯 ID(同时是要闻 `lastId` 游标的取值来源) |
|
|
740
|
+
| `title` | string | 标题 |
|
|
741
|
+
| `summary` | string | 摘要 |
|
|
742
|
+
| `pubTimestamp` | number | 发布时间戳(秒级) |
|
|
743
|
+
| `url` | string | 原文链接 |
|
|
744
|
+
|
|
586
745
|
## 通用执行
|
|
587
746
|
|
|
588
747
|
对于 SDK 尚未封装的 API,可直接使用 `HttpClient.execute`:
|
|
@@ -652,10 +811,23 @@ pc.disconnect();
|
|
|
652
811
|
| `subscribeFuture(symbols)` | 期货行情 | `onFuture(QuoteData)` |
|
|
653
812
|
| `subscribeKline(symbols)` | K 线数据 | `onKline(KlineData)` |
|
|
654
813
|
| `subscribeAsset(account?)` | 资产变动 | `onAsset(AssetData)` |
|
|
814
|
+
| `subscribeAsset(options)` | 资产变动,`{ account?, assetQuoteType? }` | `onAsset(AssetData)` |
|
|
655
815
|
| `subscribePosition(account?)` | 持仓变动 | `onPosition(PositionData)` |
|
|
816
|
+
| `subscribePosition(options)` | 持仓变动,`{ account?, assetQuoteType? }` | `onPosition(PositionData)` |
|
|
656
817
|
| `subscribeOrder(account?)` | 订单状态 | `onOrder(OrderStatusData)` |
|
|
657
818
|
| `subscribeTransaction(account?)` | 成交明细 | `onTransaction(OrderTransactionData)` |
|
|
658
819
|
|
|
820
|
+
`assetQuoteType` 用于选择推送的资产/持仓行情口径,取值为枚举名
|
|
821
|
+
`'ETH'` / `'RTH'` / `'OVERNIGHT'`,不传则用服务端默认值。
|
|
822
|
+
|
|
823
|
+
```typescript
|
|
824
|
+
pc.subscribeAsset({ assetQuoteType: 'OVERNIGHT' });
|
|
825
|
+
pc.subscribePosition({ account: 'U1234567', assetQuoteType: 'RTH' });
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
拉取侧 `getPositions` / `getAssets` / `getPrimeAssets` / `getAggregateAssets`
|
|
829
|
+
同样接受 `assetQuoteType` 字段(wire 名 `asset_quote_type`)。
|
|
830
|
+
|
|
659
831
|
## 项目结构
|
|
660
832
|
|
|
661
833
|
```
|
|
@@ -667,6 +839,7 @@ openapi-typescript-sdk/
|
|
|
667
839
|
│ ├── model/ # 数据模型和订单辅助函数
|
|
668
840
|
│ ├── quote/ # 行情客户端
|
|
669
841
|
│ ├── trade/ # 交易客户端(订单、持仓、资产)
|
|
842
|
+
│ ├── news/ # 资讯客户端(个股新闻、市场要闻)
|
|
670
843
|
│ ├── push/ # TCP+TLS 推送客户端(Protobuf)
|
|
671
844
|
│ ├── logger/ # 日志
|
|
672
845
|
│ └── index.ts # 公共导出
|
|
@@ -7,10 +7,9 @@ exports.unmarshalData = unmarshalData;
|
|
|
7
7
|
*/
|
|
8
8
|
const errors_1 = require("./errors");
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* so 16-digit microsecond timestamps remain as numbers.
|
|
10
|
+
* Quotes bare integers outside Number's safe range before JSON.parse.
|
|
11
|
+
* Values are checked by range, including 16-digit order IDs; safe integers
|
|
12
|
+
* such as microsecond timestamps remain numbers. Floats are left unchanged.
|
|
14
13
|
*/
|
|
15
14
|
function patchLargeIntegers(text) {
|
|
16
15
|
const strings = [];
|
|
@@ -21,7 +20,9 @@ function patchLargeIntegers(text) {
|
|
|
21
20
|
// Match bare integers preceded by a JSON structural character or line start,
|
|
22
21
|
// not followed by decimal point or exponent (avoids matching float components).
|
|
23
22
|
// The `m` flag makes `^` match line-start for multi-line JSON.
|
|
24
|
-
const patched = masked.replace(/([:,\[{]|^)\s*(-?\d{
|
|
23
|
+
const patched = masked.replace(/([:,\[{]|^)\s*(-?\d{16,})(?![.\deE])/gm, (full, prefix, num) => {
|
|
24
|
+
if (Number.isSafeInteger(Number(num)))
|
|
25
|
+
return full;
|
|
25
26
|
return prefix + '"' + num + '"';
|
|
26
27
|
});
|
|
27
28
|
return patched.replace(/\x01(\d+)\x01/g, (_, i) => strings[parseInt(i, 10)]);
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
* - 配置层(config):ClientConfig、ConfigParser
|
|
11
11
|
* - 认证层(signer):RSA 签名
|
|
12
12
|
* - 传输层(client):HttpClient、重试策略
|
|
13
|
-
* - 业务层(quote/trade):QuoteClient、TradeClient
|
|
13
|
+
* - 业务层(quote/trade/news):QuoteClient、TradeClient、NewsClient
|
|
14
14
|
* - 推送层(push):PushClient
|
|
15
15
|
*
|
|
16
16
|
* @packageDocumentation
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.orderStatusCode = exports.BarPeriod = exports.License = exports.Language = exports.FinancialReportPeriod = exports.OptionAnalysisPeriod = exports.SortDirection = exports.IndustryLevel = exports.CorporateActionType = exports.OrderSortBy = exports.SegmentType = exports.QuoteRight = exports.Currency = exports.Market = exports.TimeInForce = exports.OrderType = exports.SecurityType = exports.OrderStatus = exports.normalizeOrderStatus = exports.stopLimitOrder = exports.stopOrder = exports.limitOrder = exports.marketOrder = exports.SubjectType = exports.ConnectionState = exports.PushClient = exports.TradeClient = exports.parseOptionIdentifier = exports.QuoteClient = exports.classifyErrorCode = exports.TigerError = exports.HttpClient = exports.TokenManager = exports.SANDBOX_TIGER_PUBLIC_KEY = exports.loadPropertiesFile = exports.createClientConfig = exports.VERSION = void 0;
|
|
19
|
+
exports.orderStatusCode = exports.BarPeriod = exports.License = exports.Language = exports.FinancialReportPeriod = exports.OptionAnalysisPeriod = exports.SortDirection = exports.IndustryLevel = exports.CorporateActionType = exports.OrderSortBy = exports.SegmentType = exports.QuoteRight = exports.Currency = exports.Market = exports.TimeInForce = exports.OrderType = exports.SecurityType = exports.OrderStatus = exports.normalizeOrderStatus = exports.stopLimitOrder = exports.stopOrder = exports.limitOrder = exports.marketOrder = exports.SubjectType = exports.ConnectionState = exports.PushClient = exports.NewsClient = exports.TradeClient = exports.parseOptionIdentifier = exports.QuoteClient = exports.classifyErrorCode = exports.TigerError = exports.HttpClient = exports.TokenManager = exports.SANDBOX_TIGER_PUBLIC_KEY = exports.loadPropertiesFile = exports.createClientConfig = exports.VERSION = void 0;
|
|
20
20
|
/** SDK 版本号 */
|
|
21
21
|
var version_1 = require("./version");
|
|
22
22
|
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.SDK_VERSION; } });
|
|
@@ -39,6 +39,8 @@ Object.defineProperty(exports, "QuoteClient", { enumerable: true, get: function
|
|
|
39
39
|
Object.defineProperty(exports, "parseOptionIdentifier", { enumerable: true, get: function () { return quote_1.parseOptionIdentifier; } });
|
|
40
40
|
var trade_1 = require("./trade");
|
|
41
41
|
Object.defineProperty(exports, "TradeClient", { enumerable: true, get: function () { return trade_1.TradeClient; } });
|
|
42
|
+
var news_1 = require("./news");
|
|
43
|
+
Object.defineProperty(exports, "NewsClient", { enumerable: true, get: function () { return news_1.NewsClient; } });
|
|
42
44
|
var push_1 = require("./push");
|
|
43
45
|
Object.defineProperty(exports, "PushClient", { enumerable: true, get: function () { return push_1.PushClient; } });
|
|
44
46
|
Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return push_1.ConnectionState; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 资讯请求参数模型(wire: news_stock_list / news_highlight_list)。
|
|
4
|
+
*
|
|
5
|
+
* TypeScript 侧使用 camelCase,序列化时由 createApiRequest 自动转为
|
|
6
|
+
* snake_case(契约决策 #13:入参 snake_case)。可选字段不传时不出现在
|
|
7
|
+
* biz_content 中,由服务端取缺省值。
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NewsClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 资讯模块导出
|
|
6
|
+
*/
|
|
7
|
+
var news_client_1 = require("./news-client");
|
|
8
|
+
Object.defineProperty(exports, "NewsClient", { enumerable: true, get: function () { return news_client_1.NewsClient; } });
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NewsClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* NewsClient — 资讯客户端(news_stock_list / news_highlight_list)。
|
|
6
|
+
*
|
|
7
|
+
* 路由约定(对齐 Java SDK 的 MethodType.NEWS):
|
|
8
|
+
* 资讯接口走主网关(config.serverUrl,与交易域同一路由),**不走行情域名**
|
|
9
|
+
* (config.quoteServerUrl)。本 SDK 的路由在 HttpClient 构造期决定——
|
|
10
|
+
* QuoteClient 以 useQuoteServerUrl 指向行情域名,其余客户端(TradeClient、
|
|
11
|
+
* NewsClient)默认指向主网关——因此 NewsClient 永远不传 useQuoteServerUrl。
|
|
12
|
+
*
|
|
13
|
+
* 请求参数 TypeScript 侧 camelCase,自动转为 wire snake_case;响应出参为
|
|
14
|
+
* camelCase,无需转换。
|
|
15
|
+
*/
|
|
16
|
+
const http_client_1 = require("../client/http-client");
|
|
17
|
+
const api_request_1 = require("../client/api-request");
|
|
18
|
+
const api_response_1 = require("../client/api-response");
|
|
19
|
+
/** 资讯客户端:个股新闻列表与市场要闻列表。 */
|
|
20
|
+
class NewsClient {
|
|
21
|
+
constructor(httpClient, options) {
|
|
22
|
+
this.httpClient = httpClient;
|
|
23
|
+
this.defaultLang = options?.lang || undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 从 ClientConfig 直接创建 NewsClient——主网关路由,默认语言取
|
|
27
|
+
* config.language。
|
|
28
|
+
*/
|
|
29
|
+
static fromConfig(config) {
|
|
30
|
+
// 资讯走主网关:不传 useQuoteServerUrl(对照 QuoteClient 的构造方式)。
|
|
31
|
+
return new NewsClient(new http_client_1.HttpClient(config), { lang: config.language });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 查询个股新闻列表(wire: news_stock_list)。
|
|
35
|
+
*
|
|
36
|
+
* @param req - symbol 必填(单标的,该接口不支持批量查询);
|
|
37
|
+
* pageCount / pageSize 可选(缺省服务端默认 1 / 20);
|
|
38
|
+
* lang 可选('zh_CN' / 'zh_TW' / 'en_US')
|
|
39
|
+
* @returns 分页信封 NewsPage;空列表属正常成功返回
|
|
40
|
+
*/
|
|
41
|
+
async getStockNews(req) {
|
|
42
|
+
const page = await this.callInto('news_stock_list', {
|
|
43
|
+
symbol: req.symbol,
|
|
44
|
+
pageCount: req.pageCount,
|
|
45
|
+
pageSize: req.pageSize,
|
|
46
|
+
lang: this.resolveLang(req.lang),
|
|
47
|
+
});
|
|
48
|
+
return page ?? { items: [] };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 查询市场要闻列表(wire: news_highlight_list)。
|
|
52
|
+
*
|
|
53
|
+
* 翻页只走 lastId 游标:把上一页 items 最后一条的 id 作为 lastId 传入
|
|
54
|
+
* 即取下一页;不传从最新开始。本接口无 page_count / page_size,响应
|
|
55
|
+
* pageCount 恒为 1。
|
|
56
|
+
*
|
|
57
|
+
* @param req - 全部字段可选,不传即从最新开始
|
|
58
|
+
* @returns 分页信封 NewsPage;空列表属正常成功返回
|
|
59
|
+
*/
|
|
60
|
+
async getMarketNews(req) {
|
|
61
|
+
const body = {};
|
|
62
|
+
if (req?.lastId !== undefined) {
|
|
63
|
+
body['lastId'] = req.lastId;
|
|
64
|
+
}
|
|
65
|
+
const lang = this.resolveLang(req?.lang);
|
|
66
|
+
if (lang !== undefined) {
|
|
67
|
+
body['lang'] = lang;
|
|
68
|
+
}
|
|
69
|
+
const page = await this.callInto('news_highlight_list', body);
|
|
70
|
+
return page ?? { items: [] };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 解析生效的 lang:显式传值原样透传,缺省回退客户端默认语言。
|
|
74
|
+
*/
|
|
75
|
+
resolveLang(lang) {
|
|
76
|
+
return lang !== undefined ? lang : this.defaultLang;
|
|
77
|
+
}
|
|
78
|
+
async callInto(method, bizParams) {
|
|
79
|
+
const request = (0, api_request_1.createApiRequest)(method, bizParams);
|
|
80
|
+
const response = await this.httpClient.executeRequest(request);
|
|
81
|
+
return (0, api_response_1.unmarshalData)(response.data);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.NewsClient = NewsClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.8
|
|
5
5
|
// protoc v5.28.3
|
|
6
6
|
// source: QuoteBasicData.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -35,6 +35,9 @@ function createBaseQuoteBasicData() {
|
|
|
35
35
|
minTick: undefined,
|
|
36
36
|
mi: undefined,
|
|
37
37
|
volumeDecimal: undefined,
|
|
38
|
+
cumVolume: undefined,
|
|
39
|
+
cumAmount: undefined,
|
|
40
|
+
session: undefined,
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
exports.QuoteBasicData = {
|
|
@@ -108,6 +111,15 @@ exports.QuoteBasicData = {
|
|
|
108
111
|
if (message.volumeDecimal !== undefined) {
|
|
109
112
|
writer.uint32(233).double(message.volumeDecimal);
|
|
110
113
|
}
|
|
114
|
+
if (message.cumVolume !== undefined) {
|
|
115
|
+
writer.uint32(240).sint64(message.cumVolume);
|
|
116
|
+
}
|
|
117
|
+
if (message.cumAmount !== undefined) {
|
|
118
|
+
writer.uint32(249).double(message.cumAmount);
|
|
119
|
+
}
|
|
120
|
+
if (message.session !== undefined) {
|
|
121
|
+
writer.uint32(258).string(message.session);
|
|
122
|
+
}
|
|
111
123
|
return writer;
|
|
112
124
|
},
|
|
113
125
|
decode(input, length) {
|
|
@@ -278,6 +290,27 @@ exports.QuoteBasicData = {
|
|
|
278
290
|
message.volumeDecimal = reader.double();
|
|
279
291
|
continue;
|
|
280
292
|
}
|
|
293
|
+
case 30: {
|
|
294
|
+
if (tag !== 240) {
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
message.cumVolume = longToNumber(reader.sint64());
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
case 31: {
|
|
301
|
+
if (tag !== 249) {
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
message.cumAmount = reader.double();
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
case 32: {
|
|
308
|
+
if (tag !== 258) {
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
message.session = reader.string();
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
281
314
|
}
|
|
282
315
|
if ((tag & 7) === 4 || tag === 0) {
|
|
283
316
|
break;
|
|
@@ -314,6 +347,9 @@ exports.QuoteBasicData = {
|
|
|
314
347
|
message.minTick = object.minTick ?? undefined;
|
|
315
348
|
message.mi = (object.mi !== undefined && object.mi !== null) ? QuoteData_1.QuoteData_Minute.fromPartial(object.mi) : undefined;
|
|
316
349
|
message.volumeDecimal = object.volumeDecimal ?? undefined;
|
|
350
|
+
message.cumVolume = object.cumVolume ?? undefined;
|
|
351
|
+
message.cumAmount = object.cumAmount ?? undefined;
|
|
352
|
+
message.session = object.session ?? undefined;
|
|
317
353
|
return message;
|
|
318
354
|
},
|
|
319
355
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.8
|
|
5
5
|
// protoc v5.28.3
|
|
6
6
|
// source: QuoteData.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -40,6 +40,9 @@ function createBaseQuoteData() {
|
|
|
40
40
|
minTick: undefined,
|
|
41
41
|
mi: undefined,
|
|
42
42
|
volumeDecimal: undefined,
|
|
43
|
+
cumVolume: undefined,
|
|
44
|
+
cumAmount: undefined,
|
|
45
|
+
session: undefined,
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
48
|
exports.QuoteData = {
|
|
@@ -131,6 +134,15 @@ exports.QuoteData = {
|
|
|
131
134
|
if (message.volumeDecimal !== undefined) {
|
|
132
135
|
writer.uint32(233).double(message.volumeDecimal);
|
|
133
136
|
}
|
|
137
|
+
if (message.cumVolume !== undefined) {
|
|
138
|
+
writer.uint32(240).sint64(message.cumVolume);
|
|
139
|
+
}
|
|
140
|
+
if (message.cumAmount !== undefined) {
|
|
141
|
+
writer.uint32(249).double(message.cumAmount);
|
|
142
|
+
}
|
|
143
|
+
if (message.session !== undefined) {
|
|
144
|
+
writer.uint32(258).string(message.session);
|
|
145
|
+
}
|
|
134
146
|
return writer;
|
|
135
147
|
},
|
|
136
148
|
decode(input, length) {
|
|
@@ -343,6 +355,27 @@ exports.QuoteData = {
|
|
|
343
355
|
message.volumeDecimal = reader.double();
|
|
344
356
|
continue;
|
|
345
357
|
}
|
|
358
|
+
case 30: {
|
|
359
|
+
if (tag !== 240) {
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
message.cumVolume = longToNumber(reader.sint64());
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
case 31: {
|
|
366
|
+
if (tag !== 249) {
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
message.cumAmount = reader.double();
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
case 32: {
|
|
373
|
+
if (tag !== 258) {
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
message.session = reader.string();
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
346
379
|
}
|
|
347
380
|
if ((tag & 7) === 4 || tag === 0) {
|
|
348
381
|
break;
|
|
@@ -385,6 +418,9 @@ exports.QuoteData = {
|
|
|
385
418
|
message.minTick = object.minTick ?? undefined;
|
|
386
419
|
message.mi = (object.mi !== undefined && object.mi !== null) ? exports.QuoteData_Minute.fromPartial(object.mi) : undefined;
|
|
387
420
|
message.volumeDecimal = object.volumeDecimal ?? undefined;
|
|
421
|
+
message.cumVolume = object.cumVolume ?? undefined;
|
|
422
|
+
message.cumAmount = object.cumAmount ?? undefined;
|
|
423
|
+
message.session = object.session ?? undefined;
|
|
388
424
|
return message;
|
|
389
425
|
},
|
|
390
426
|
};
|
|
@@ -203,7 +203,7 @@ exports.Request_Connect = {
|
|
|
203
203
|
},
|
|
204
204
|
};
|
|
205
205
|
function createBaseRequest_Subscribe() {
|
|
206
|
-
return { dataType: 0, symbols: undefined, account: undefined, market: undefined };
|
|
206
|
+
return { dataType: 0, symbols: undefined, account: undefined, market: undefined, assetQuoteType: undefined };
|
|
207
207
|
}
|
|
208
208
|
exports.Request_Subscribe = {
|
|
209
209
|
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
@@ -219,6 +219,9 @@ exports.Request_Subscribe = {
|
|
|
219
219
|
if (message.market !== undefined) {
|
|
220
220
|
writer.uint32(34).string(message.market);
|
|
221
221
|
}
|
|
222
|
+
if (message.assetQuoteType !== undefined) {
|
|
223
|
+
writer.uint32(42).string(message.assetQuoteType);
|
|
224
|
+
}
|
|
222
225
|
return writer;
|
|
223
226
|
},
|
|
224
227
|
decode(input, length) {
|
|
@@ -256,6 +259,13 @@ exports.Request_Subscribe = {
|
|
|
256
259
|
message.market = reader.string();
|
|
257
260
|
continue;
|
|
258
261
|
}
|
|
262
|
+
case 5: {
|
|
263
|
+
if (tag !== 42) {
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
message.assetQuoteType = reader.string();
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
259
269
|
}
|
|
260
270
|
if ((tag & 7) === 4 || tag === 0) {
|
|
261
271
|
break;
|
|
@@ -273,6 +283,7 @@ exports.Request_Subscribe = {
|
|
|
273
283
|
message.symbols = object.symbols ?? undefined;
|
|
274
284
|
message.account = object.account ?? undefined;
|
|
275
285
|
message.market = object.market ?? undefined;
|
|
286
|
+
message.assetQuoteType = object.assetQuoteType ?? undefined;
|
|
276
287
|
return message;
|
|
277
288
|
},
|
|
278
289
|
};
|
|
@@ -53,8 +53,11 @@ function buildHeartBeatMessage() {
|
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* 构建 SUBSCRIBE 请求消息
|
|
56
|
+
*
|
|
57
|
+
* @param assetQuoteType 资产行情类型枚举名(ETH / RTH / OVERNIGHT),
|
|
58
|
+
* 仅对 Asset / Position 两种订阅有意义,其余场景传 undefined
|
|
56
59
|
*/
|
|
57
|
-
function buildSubscribeMessage(dataType, symbols, account, market) {
|
|
60
|
+
function buildSubscribeMessage(dataType, symbols, account, market, assetQuoteType) {
|
|
58
61
|
return Request_1.Request.fromPartial({
|
|
59
62
|
command: SocketCommon_1.SocketCommon_Command.SUBSCRIBE,
|
|
60
63
|
id: nextRequestId(),
|
|
@@ -63,6 +66,7 @@ function buildSubscribeMessage(dataType, symbols, account, market) {
|
|
|
63
66
|
symbols,
|
|
64
67
|
account,
|
|
65
68
|
market,
|
|
69
|
+
assetQuoteType,
|
|
66
70
|
}),
|
|
67
71
|
});
|
|
68
72
|
}
|