@tigeropenapi/tigeropen 0.5.4 → 0.5.7
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 +80 -0
- package/dist/cjs/auth/authentication.js +74 -0
- package/dist/cjs/auth/index.js +24 -0
- package/dist/cjs/auth/oauth2/client-registration.js +44 -0
- package/dist/cjs/auth/oauth2/device-authorization.js +40 -0
- package/dist/cjs/auth/oauth2/errors.js +64 -0
- package/dist/cjs/auth/oauth2/http-utils.js +112 -0
- package/dist/cjs/auth/oauth2/index.js +42 -0
- package/dist/cjs/auth/oauth2/loopback-receiver.js +215 -0
- package/dist/cjs/auth/oauth2/metadata.js +34 -0
- package/dist/cjs/auth/oauth2/oauth2-authentication.js +74 -0
- package/dist/cjs/auth/oauth2/session-manager.js +762 -0
- package/dist/cjs/auth/oauth2/token-store.js +252 -0
- package/dist/cjs/auth/oauth2/token.js +76 -0
- package/dist/cjs/push/index.js +1 -0
- 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 +34 -16
- package/dist/cjs/push/tick-util.js +172 -0
- package/dist/cjs/quote/quote-client.js +59 -12
- package/dist/cjs/trade/trade-client.js +55 -6
- package/dist/cjs/version.js +1 -1
- package/dist/esm/auth/authentication.js +68 -0
- package/dist/esm/auth/index.js +3 -0
- package/dist/esm/auth/oauth2/client-registration.js +40 -0
- package/dist/esm/auth/oauth2/device-authorization.js +36 -0
- package/dist/esm/auth/oauth2/errors.js +59 -0
- package/dist/esm/auth/oauth2/http-utils.js +105 -0
- package/dist/esm/auth/oauth2/index.js +11 -0
- package/dist/esm/auth/oauth2/loopback-receiver.js +178 -0
- package/dist/esm/auth/oauth2/metadata.js +30 -0
- package/dist/esm/auth/oauth2/oauth2-authentication.js +70 -0
- package/dist/esm/auth/oauth2/session-manager.js +725 -0
- package/dist/esm/auth/oauth2/token-store.js +214 -0
- package/dist/esm/auth/oauth2/token.js +71 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/push/index.js +1 -0
- 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 +34 -16
- package/dist/esm/push/tick-util.js +165 -0
- package/dist/esm/quote/quote-client.js +59 -12
- package/dist/esm/trade/trade-client.js +55 -6
- package/dist/esm/version.js +1 -1
- package/dist/types/auth/authentication.d.ts +98 -0
- package/dist/types/auth/index.d.ts +4 -0
- package/dist/types/auth/oauth2/client-registration.d.ts +32 -0
- package/dist/types/auth/oauth2/device-authorization.d.ts +40 -0
- package/dist/types/auth/oauth2/errors.d.ts +46 -0
- package/dist/types/auth/oauth2/http-utils.d.ts +21 -0
- package/dist/types/auth/oauth2/index.d.ts +16 -0
- package/dist/types/auth/oauth2/loopback-receiver.d.ts +29 -0
- package/dist/types/auth/oauth2/metadata.d.ts +32 -0
- package/dist/types/auth/oauth2/oauth2-authentication.d.ts +31 -0
- package/dist/types/auth/oauth2/session-manager.d.ts +241 -0
- package/dist/types/auth/oauth2/token-store.d.ts +49 -0
- package/dist/types/auth/oauth2/token.d.ts +56 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/model/order.d.ts +62 -11
- package/dist/types/model/quote-requests.d.ts +21 -2
- package/dist/types/model/quote.d.ts +72 -14
- package/dist/types/model/trade-requests.d.ts +17 -4
- package/dist/types/model/trade.d.ts +11 -1
- package/dist/types/push/callbacks.d.ts +3 -7
- package/dist/types/push/index.d.ts +2 -1
- 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/push/tick-util.d.ts +30 -0
- package/dist/types/quote/quote-client.d.ts +27 -6
- package/dist/types/trade/trade-client.d.ts +27 -3
- package/dist/types/version.d.ts +1 -1
- package/package.json +8 -4
|
@@ -23,6 +23,7 @@ export interface Brief {
|
|
|
23
23
|
bidPrice?: number;
|
|
24
24
|
bidSize?: number;
|
|
25
25
|
volume?: number;
|
|
26
|
+
amount?: number;
|
|
26
27
|
status?: string;
|
|
27
28
|
adjPreClose?: number;
|
|
28
29
|
change?: number;
|
|
@@ -37,6 +38,7 @@ export interface Brief {
|
|
|
37
38
|
export interface KlineItem {
|
|
38
39
|
time: number;
|
|
39
40
|
volume: number;
|
|
41
|
+
volumeDecimal?: number | null;
|
|
40
42
|
open: number;
|
|
41
43
|
close: number;
|
|
42
44
|
high: number;
|
|
@@ -52,6 +54,7 @@ export interface Kline {
|
|
|
52
54
|
export interface TimelineItem {
|
|
53
55
|
time: number;
|
|
54
56
|
volume: number;
|
|
57
|
+
volumeDecimal?: number | null;
|
|
55
58
|
price: number;
|
|
56
59
|
avgPrice: number;
|
|
57
60
|
}
|
|
@@ -71,6 +74,9 @@ export interface TradeTickItem {
|
|
|
71
74
|
volume: number;
|
|
72
75
|
price: number;
|
|
73
76
|
type: string;
|
|
77
|
+
partCode?: string;
|
|
78
|
+
partName?: string;
|
|
79
|
+
cond?: string;
|
|
74
80
|
}
|
|
75
81
|
export interface TradeTick {
|
|
76
82
|
symbol: string;
|
|
@@ -116,6 +122,12 @@ export interface OptionLeg {
|
|
|
116
122
|
theta?: number;
|
|
117
123
|
vega?: number;
|
|
118
124
|
rho?: number;
|
|
125
|
+
markPrice?: number;
|
|
126
|
+
preMarkPrice?: number;
|
|
127
|
+
markTimestamp?: number;
|
|
128
|
+
midPrice?: number;
|
|
129
|
+
preMidPrice?: number;
|
|
130
|
+
midTimestamp?: number;
|
|
119
131
|
}
|
|
120
132
|
export interface OptionChainRow {
|
|
121
133
|
put?: OptionLeg;
|
|
@@ -328,20 +340,39 @@ export interface FinancialDailyRequest {
|
|
|
328
340
|
beginDate: string;
|
|
329
341
|
endDate: string;
|
|
330
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Financial report request.
|
|
345
|
+
*
|
|
346
|
+
* **Wire types (breaking):** `beginDate` / `endDate` are epoch-ms integers,
|
|
347
|
+
* not date strings. Python SDK converts via `date_str_to_timestamp` before
|
|
348
|
+
* sending; sending raw strings makes the gateway reject with
|
|
349
|
+
* `biz param error(failed to parse parameters in 'biz_content')`.
|
|
350
|
+
*/
|
|
331
351
|
export interface FinancialReportRequest {
|
|
332
352
|
symbols: string[];
|
|
333
353
|
market: string;
|
|
334
354
|
fields: string[];
|
|
335
355
|
periodType: string;
|
|
336
|
-
|
|
337
|
-
|
|
356
|
+
/** epoch-ms start time */
|
|
357
|
+
beginDate?: number;
|
|
358
|
+
/** epoch-ms end time */
|
|
359
|
+
endDate?: number;
|
|
338
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Corporate action request.
|
|
363
|
+
*
|
|
364
|
+
* **Wire types (breaking):** `beginDate` / `endDate` are epoch-ms integers,
|
|
365
|
+
* matching `FinancialReportRequest`. Server rejects string dates with
|
|
366
|
+
* `biz param error(failed to parse parameters in 'biz_content')`.
|
|
367
|
+
*/
|
|
339
368
|
export interface CorporateActionRequest {
|
|
340
369
|
symbols: string[];
|
|
341
370
|
market: string;
|
|
342
371
|
actionType: string;
|
|
343
|
-
|
|
344
|
-
|
|
372
|
+
/** epoch-ms start time */
|
|
373
|
+
beginDate?: number;
|
|
374
|
+
/** epoch-ms end time */
|
|
375
|
+
endDate?: number;
|
|
345
376
|
}
|
|
346
377
|
export interface FutureKlineRequest {
|
|
347
378
|
contractCodes: string[];
|
|
@@ -552,10 +583,32 @@ export interface WarrantFilterResult {
|
|
|
552
583
|
pageSize?: number;
|
|
553
584
|
page?: number;
|
|
554
585
|
}
|
|
555
|
-
/**
|
|
586
|
+
/**
|
|
587
|
+
* Industry list row (industry_list).
|
|
588
|
+
*
|
|
589
|
+
* **Wire fields (breaking):** the server returns `nameCN` / `nameEN` /
|
|
590
|
+
* `industryLevel`, not `name` / `level` (matches Python SDK's
|
|
591
|
+
* `IndustryListResponse` which reads `ind.get('nameCN')`,
|
|
592
|
+
* `ind.get('nameEN')`, `ind.get('industryLevel')`).
|
|
593
|
+
* Since responses come back already-camelCase (no snake→camel step) and the
|
|
594
|
+
* server keeps `nameCN` / `nameEN` in mixed case, the fields are exposed
|
|
595
|
+
* exactly as sent.
|
|
596
|
+
*
|
|
597
|
+
* `name` and `level` are backwards-compat aliases populated by
|
|
598
|
+
* `getIndustryList` after the raw response is decoded — `name` mirrors
|
|
599
|
+
* `nameEN || nameCN`, `level` mirrors `industryLevel`.
|
|
600
|
+
*/
|
|
556
601
|
export interface IndustryItem {
|
|
557
602
|
id?: string;
|
|
603
|
+
/** Chinese name. Wire: `nameCN`. */
|
|
604
|
+
nameCN?: string;
|
|
605
|
+
/** English name. Wire: `nameEN`. */
|
|
606
|
+
nameEN?: string;
|
|
607
|
+
/** Industry level. Wire: `industryLevel`. */
|
|
608
|
+
industryLevel?: string;
|
|
609
|
+
/** Convenience alias: `nameEN || nameCN`. Populated by `getIndustryList`. */
|
|
558
610
|
name?: string;
|
|
611
|
+
/** @deprecated Use `industryLevel`. Mirrored by `getIndustryList` for back-compat. */
|
|
559
612
|
level?: string;
|
|
560
613
|
}
|
|
561
614
|
/** Stock belonging to an industry (industry_stock_list). */
|
|
@@ -573,12 +626,15 @@ export interface TradingCalendarItem {
|
|
|
573
626
|
isTrading?: boolean;
|
|
574
627
|
sessionType?: string;
|
|
575
628
|
}
|
|
629
|
+
/** Single day's FX rate value within an ExchangeRate.dailyValueList entry. */
|
|
630
|
+
export interface ExchangeRateDailyValue {
|
|
631
|
+
date?: number;
|
|
632
|
+
value?: number;
|
|
633
|
+
}
|
|
576
634
|
/** FX rate (financial_exchange_rate). */
|
|
577
635
|
export interface ExchangeRate {
|
|
578
636
|
currency?: string;
|
|
579
|
-
|
|
580
|
-
rate?: number;
|
|
581
|
-
baseCurrency?: string;
|
|
637
|
+
dailyValueList?: ExchangeRateDailyValue[];
|
|
582
638
|
}
|
|
583
639
|
/** Financial currency per symbol (financial_currency). */
|
|
584
640
|
export interface FinancialCurrency {
|
|
@@ -589,17 +645,19 @@ export interface FinancialCurrency {
|
|
|
589
645
|
/** Overnight quote (quote_overnight). */
|
|
590
646
|
export interface QuoteOvernight {
|
|
591
647
|
symbol?: string;
|
|
648
|
+
latestPrice?: number;
|
|
649
|
+
askPrice?: number;
|
|
650
|
+
askSize?: number;
|
|
651
|
+
bidPrice?: number;
|
|
652
|
+
bidSize?: number;
|
|
592
653
|
preClose?: number;
|
|
593
|
-
open?: number;
|
|
594
|
-
close?: number;
|
|
595
|
-
high?: number;
|
|
596
|
-
low?: number;
|
|
597
654
|
volume?: number;
|
|
598
655
|
amount?: number;
|
|
656
|
+
timestamp?: number;
|
|
657
|
+
tradingStatus?: number;
|
|
599
658
|
change?: number;
|
|
600
659
|
changeRate?: number;
|
|
601
|
-
|
|
602
|
-
endTime?: number;
|
|
660
|
+
amplitude?: number;
|
|
603
661
|
}
|
|
604
662
|
/** Single market-scanner tag. */
|
|
605
663
|
export interface MarketScannerTag {
|
|
@@ -72,6 +72,7 @@ export interface PositionsRequest {
|
|
|
72
72
|
expiry?: string;
|
|
73
73
|
strike?: string;
|
|
74
74
|
right?: string;
|
|
75
|
+
/** 资产行情类型枚举名: ETH / RTH / OVERNIGHT (wire: asset_quote_type) */
|
|
75
76
|
assetQuoteType?: string;
|
|
76
77
|
lang?: string;
|
|
77
78
|
}
|
|
@@ -82,6 +83,8 @@ export interface AssetsRequest {
|
|
|
82
83
|
subAccounts?: string[];
|
|
83
84
|
segment?: boolean;
|
|
84
85
|
marketValue?: boolean;
|
|
86
|
+
/** 资产行情类型枚举名: ETH / RTH / OVERNIGHT (wire: asset_quote_type) */
|
|
87
|
+
assetQuoteType?: string;
|
|
85
88
|
lang?: string;
|
|
86
89
|
}
|
|
87
90
|
export interface ManagedAccountsRequest {
|
|
@@ -115,6 +118,8 @@ export interface AggregateAssetsRequest {
|
|
|
115
118
|
secretKey?: string;
|
|
116
119
|
baseCurrency?: string;
|
|
117
120
|
segType?: string;
|
|
121
|
+
/** 资产行情类型枚举名: ETH / RTH / OVERNIGHT (wire: asset_quote_type) */
|
|
122
|
+
assetQuoteType?: string;
|
|
118
123
|
lang?: string;
|
|
119
124
|
}
|
|
120
125
|
export interface EstimateTradableQuantityRequest {
|
|
@@ -157,6 +162,14 @@ export interface SegmentFundRequest {
|
|
|
157
162
|
limit?: number;
|
|
158
163
|
lang?: string;
|
|
159
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Fund details request. wire: fund_details
|
|
167
|
+
*
|
|
168
|
+
* **Wire types (breaking):** `startDate` / `endDate` are yyyy-MM-dd date
|
|
169
|
+
* strings, not epoch-ms integers. Java's `FundDetailsModel` exposes them
|
|
170
|
+
* as `String startDate` / `String endDate`; sending epoch-ms causes
|
|
171
|
+
* `parse 'start_date' error, supported format: 'yyyy-MM-dd'`.
|
|
172
|
+
*/
|
|
160
173
|
export interface FundDetailsRequest {
|
|
161
174
|
account?: string;
|
|
162
175
|
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
@@ -164,10 +177,10 @@ export interface FundDetailsRequest {
|
|
|
164
177
|
segTypes?: string[];
|
|
165
178
|
fundType?: string;
|
|
166
179
|
currency?: string;
|
|
167
|
-
/**
|
|
168
|
-
startDate?:
|
|
169
|
-
/**
|
|
170
|
-
endDate?:
|
|
180
|
+
/** yyyy-MM-dd 日期字符串 */
|
|
181
|
+
startDate?: string;
|
|
182
|
+
/** yyyy-MM-dd 日期字符串 */
|
|
183
|
+
endDate?: string;
|
|
171
184
|
limit?: number;
|
|
172
185
|
pageToken?: string;
|
|
173
186
|
lang?: string;
|
|
@@ -160,8 +160,18 @@ export interface EstimateTradableQuantity {
|
|
|
160
160
|
cashBuyingPower?: number;
|
|
161
161
|
currency?: string;
|
|
162
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Forex order response.
|
|
165
|
+
*
|
|
166
|
+
* Server returns `id` as a JSON number (matches `PlaceOrderResult.id`).
|
|
167
|
+
* The Rust / Go SDKs confirmed this on live integ — earlier the type here
|
|
168
|
+
* was `string`, which the loose JS typing silently accepted while Rust /
|
|
169
|
+
* Go crashed on the mismatch. Kept as `number | string` for backward
|
|
170
|
+
* compatibility with any caller relying on the old typing.
|
|
171
|
+
*/
|
|
163
172
|
export interface ForexOrderResult {
|
|
164
|
-
|
|
173
|
+
/** int64 forex order ID; may be a string when exceeding Number.MAX_SAFE_INTEGER */
|
|
174
|
+
id?: number | string;
|
|
165
175
|
status?: string;
|
|
166
176
|
sourceCurrency?: string;
|
|
167
177
|
targetCurrency?: string;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 推送回调函数类型定义(Protobuf 协议)
|
|
3
|
-
*
|
|
4
|
-
* 每种推送类型独立回调,参数类型为 Protobuf 生成的类型。
|
|
5
|
-
* 连接状态回调独立管理。
|
|
6
|
-
*/
|
|
7
1
|
import type { QuoteData } from './pb/QuoteData';
|
|
8
2
|
import type { QuoteDepthData } from './pb/QuoteDepthData';
|
|
9
3
|
import type { TradeTickData } from './pb/TradeTickData';
|
|
@@ -15,10 +9,11 @@ import type { OrderTransactionData } from './pb/OrderTransactionData';
|
|
|
15
9
|
import type { StockTopData } from './pb/StockTopData';
|
|
16
10
|
import type { OptionTopData } from './pb/OptionTopData';
|
|
17
11
|
import type { KlineData } from './pb/KlineData';
|
|
12
|
+
import type { PushTradeTick } from './tick-util';
|
|
18
13
|
/** 所有回调函数的集合 */
|
|
19
14
|
export interface Callbacks {
|
|
20
15
|
onQuote?: (data: QuoteData) => void;
|
|
21
|
-
onTick?: (data:
|
|
16
|
+
onTick?: (data: PushTradeTick) => void;
|
|
22
17
|
onDepth?: (data: QuoteDepthData) => void;
|
|
23
18
|
onOption?: (data: QuoteData) => void;
|
|
24
19
|
onFuture?: (data: QuoteData) => void;
|
|
@@ -36,3 +31,4 @@ export interface Callbacks {
|
|
|
36
31
|
onError?: (err: Error) => void;
|
|
37
32
|
onKickout?: (message: string) => void;
|
|
38
33
|
}
|
|
34
|
+
export type { TradeTickData };
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export { SubjectType } from './push-message';
|
|
5
5
|
export * from './callbacks';
|
|
6
6
|
export * from './varint';
|
|
7
|
+
export * from './tick-util';
|
|
7
8
|
export * from './proto-message';
|
|
8
9
|
export { PushClient, ConnectionState } from './push-client';
|
|
9
|
-
export type { PushClientOptions, TLSSocketLike, TLSSocketFactory } from './push-client';
|
|
10
|
+
export type { PushClientOptions, AccountSubscribeOptions, TLSSocketLike, TLSSocketFactory, } from './push-client';
|
|
@@ -21,6 +21,7 @@ export interface Request_Subscribe {
|
|
|
21
21
|
symbols?: string | undefined;
|
|
22
22
|
account?: string | undefined;
|
|
23
23
|
market?: string | undefined;
|
|
24
|
+
assetQuoteType?: string | undefined;
|
|
24
25
|
}
|
|
25
26
|
export declare const Request: MessageFns<Request>;
|
|
26
27
|
export declare const Request_Connect: MessageFns<Request_Connect>;
|
|
@@ -17,8 +17,11 @@ export declare function buildConnectMessage(tigerId: string, sign: string, sdkVe
|
|
|
17
17
|
export declare function buildHeartBeatMessage(): Request;
|
|
18
18
|
/**
|
|
19
19
|
* 构建 SUBSCRIBE 请求消息
|
|
20
|
+
*
|
|
21
|
+
* @param assetQuoteType 资产行情类型枚举名(ETH / RTH / OVERNIGHT),
|
|
22
|
+
* 仅对 Asset / Position 两种订阅有意义,其余场景传 undefined
|
|
20
23
|
*/
|
|
21
|
-
export declare function buildSubscribeMessage(dataType: SocketCommon_DataType, symbols?: string, account?: string, market?: string): Request;
|
|
24
|
+
export declare function buildSubscribeMessage(dataType: SocketCommon_DataType, symbols?: string, account?: string, market?: string, assetQuoteType?: string): Request;
|
|
22
25
|
/**
|
|
23
26
|
* 构建 UNSUBSCRIBE 请求消息
|
|
24
27
|
*/
|
|
@@ -7,6 +7,18 @@ export declare enum ConnectionState {
|
|
|
7
7
|
Connecting = 1,
|
|
8
8
|
Connected = 2
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Options for account-level subscriptions (asset / position).
|
|
12
|
+
*
|
|
13
|
+
* `assetQuoteType` 用于选择资产/持仓推送的行情口径,通过重载传入,
|
|
14
|
+
* 老的 `subscribeAsset(account?)` / `subscribePosition(account?)` 签名保持不变。
|
|
15
|
+
*/
|
|
16
|
+
export interface AccountSubscribeOptions {
|
|
17
|
+
/** Account to subscribe; omit to use the account from ClientConfig. */
|
|
18
|
+
account?: string;
|
|
19
|
+
/** 资产行情类型枚举名: ETH / RTH / OVERNIGHT,省略则由服务端取默认值 */
|
|
20
|
+
assetQuoteType?: string;
|
|
21
|
+
}
|
|
10
22
|
/** PushClient configuration options */
|
|
11
23
|
export interface PushClientOptions {
|
|
12
24
|
pushHost?: string;
|
|
@@ -51,6 +63,8 @@ export declare class PushClient {
|
|
|
51
63
|
private subscriptions;
|
|
52
64
|
/** Account-level subscriptions: subject -> account string used at subscribe time */
|
|
53
65
|
private accountSubs;
|
|
66
|
+
/** Account-level subscriptions: subject -> assetQuoteType used at subscribe time (reconnect replay) */
|
|
67
|
+
private accountSubQuoteTypes;
|
|
54
68
|
private heartbeatTimer;
|
|
55
69
|
private reconnectTimer;
|
|
56
70
|
private stopped;
|
|
@@ -150,12 +164,31 @@ export declare class PushClient {
|
|
|
150
164
|
subscribeMarket(market: string): void;
|
|
151
165
|
/** Unsubscribe from market status (v0.4.0). */
|
|
152
166
|
unsubscribeMarket(market: string): void;
|
|
167
|
+
/**
|
|
168
|
+
* Shared implementation for the account/options overloads of
|
|
169
|
+
* subscribeAsset / subscribePosition.
|
|
170
|
+
*/
|
|
171
|
+
private subscribeAccount;
|
|
153
172
|
/** Subscribe to asset changes */
|
|
154
173
|
subscribeAsset(account?: string): void;
|
|
174
|
+
/**
|
|
175
|
+
* Subscribe to asset changes with extra options.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* client.subscribeAsset({ assetQuoteType: 'OVERNIGHT' });
|
|
179
|
+
*/
|
|
180
|
+
subscribeAsset(options: AccountSubscribeOptions): void;
|
|
155
181
|
/** Unsubscribe from asset changes */
|
|
156
182
|
unsubscribeAsset(): void;
|
|
157
183
|
/** Subscribe to position changes */
|
|
158
184
|
subscribePosition(account?: string): void;
|
|
185
|
+
/**
|
|
186
|
+
* Subscribe to position changes with extra options.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* client.subscribePosition({ assetQuoteType: 'OVERNIGHT' });
|
|
190
|
+
*/
|
|
191
|
+
subscribePosition(options: AccountSubscribeOptions): void;
|
|
159
192
|
/** Unsubscribe from position changes */
|
|
160
193
|
unsubscribePosition(): void;
|
|
161
194
|
/** Subscribe to order status */
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { TradeTickData } from './pb/TradeTickData';
|
|
2
|
+
/** Returns the full exchange name for a partCode letter, or the raw code if unknown. */
|
|
3
|
+
export declare function getPartNameByCode(code: string): string;
|
|
4
|
+
/** Returns the short exchange name for a partCode letter, or the raw code if unknown. */
|
|
5
|
+
export declare function getPartShortNameByCode(code: string): string;
|
|
6
|
+
/** Resolves a raw cond character to a readable string. */
|
|
7
|
+
export declare function getTradeCondByCode(isUs: boolean, ch: string): string;
|
|
8
|
+
/** Reports whether symbol is a US stock (uppercase letters, optional dot suffix). */
|
|
9
|
+
export declare function isUsStockSymbol(symbol: string): boolean;
|
|
10
|
+
/** Single decoded tick from a push message. */
|
|
11
|
+
export interface PushTick {
|
|
12
|
+
sn: number;
|
|
13
|
+
time: number;
|
|
14
|
+
price: number;
|
|
15
|
+
volume: number;
|
|
16
|
+
tickType: string;
|
|
17
|
+
cond: string;
|
|
18
|
+
partCode: string;
|
|
19
|
+
partName: string;
|
|
20
|
+
}
|
|
21
|
+
/** Decoded push trade tick message — equivalent to Java TradeTick. */
|
|
22
|
+
export interface PushTradeTick {
|
|
23
|
+
symbol: string;
|
|
24
|
+
secType: string;
|
|
25
|
+
quoteLevel: string;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
ticks: PushTick[];
|
|
28
|
+
}
|
|
29
|
+
/** Decodes a TradeTickData pb message into a PushTradeTick with resolved partCode/partName. */
|
|
30
|
+
export declare function convertTradeTick(src: TradeTickData): PushTradeTick;
|
|
@@ -9,7 +9,7 @@ import { HttpClient } from '../client/http-client';
|
|
|
9
9
|
import type { ClientConfig } from '../config/client-config';
|
|
10
10
|
import type { TokenManager } from '../config/token-manager';
|
|
11
11
|
import type { MarketState, Brief, Kline, KlineItem, Timeline, TradeTick, Depth, OptionExpiration, OptionChain, OptionChainFilter, FutureExchange, FutureContractInfo, FutureQuote, FutureKline, FutureKlineItem, FinancialDailyItem, FinancialReportItem, CorporateAction, CorporateSymbolChange, CorporateDelisting, CorporateIPO, CapitalFlow, CapitalDistribution, ScannerResult, QuotePermission, MarketScannerRequest, SymbolName, TradeMeta, StockDetail, StockBroker, StockIndustry, TradeRankItem, ShortInterest, KlineQuota, OptionAnalysis, OptionSymbol, FutureMainContractHistory, FutureTradingTime, FutureTradeTickItem, FutureDepth, WarrantBrief, WarrantFilterResult, IndustryItem, IndustryStock, TradingCalendarItem, ExchangeRate, FinancialCurrency, QuoteOvernight, MarketScannerTagGroup, FundContractInfo, FundQuote, FundHistoryQuote, FinancialDailyRequest, FinancialReportRequest, CorporateActionRequest } from '../model/quote';
|
|
12
|
-
import type { BriefRequest, DepthQuoteRequest, TradeTickRequest, FutureBriefRequest, SymbolsRequest, TradeMetasRequest, StockDetailsRequest, StockDelayBriefsRequest, KlineRequest, KlineByPageRequest, TimelineHistoryRequest, TradeRankRequest, ShortInterestRequest, StockBrokerRequest, StockFundamentalRequest, StockIndustryRequest, KlineQuotaRequest, QuotePermissionRequest, OptionTradeTicksRequest, OptionTimelineRequest, OptionDepthRequest, OptionSymbolsRequest, OptionAnalysisRequest, FutureContractSingleRequest, AllFutureContractsRequest, FutureContinuousContractsRequest, FutureHistoryMainContractRequest, FutureKlineRequest, FutureKlineByPageRequest, FutureTradeTicksRequest, FutureDepthRequest, FutureTradingTimesRequest, FundSymbolsRequest, FundContractsRequest, FundQuoteRequest, FundHistoryQuoteRequest, WarrantBriefsRequest, WarrantFilterRequest, IndustryListRequest, IndustryStocksRequest, TradingCalendarRequest, FinancialExchangeRateRequest, FinancialCurrencyRequest, MarketScannerTagsRequest, QuoteOvernightRequest } from '../model/quote-requests';
|
|
12
|
+
import type { BriefRequest, DepthQuoteRequest, TradeTickRequest, FutureBriefRequest, SymbolsRequest, TradeMetasRequest, StockDetailsRequest, StockDelayBriefsRequest, KlineRequest, KlineByPageRequest, TimelineRequest, TimelineHistoryRequest, TradeRankRequest, ShortInterestRequest, StockBrokerRequest, StockFundamentalRequest, StockIndustryRequest, KlineQuotaRequest, QuotePermissionRequest, OptionTradeTicksRequest, OptionTimelineRequest, OptionDepthRequest, OptionSymbolsRequest, OptionAnalysisRequest, FutureContractSingleRequest, AllFutureContractsRequest, FutureContinuousContractsRequest, FutureHistoryMainContractRequest, FutureKlineRequest, FutureKlineByPageRequest, FutureTradeTicksRequest, FutureDepthRequest, FutureTradingTimesRequest, FundSymbolsRequest, FundContractsRequest, FundQuoteRequest, FundHistoryQuoteRequest, WarrantBriefsRequest, WarrantFilterRequest, IndustryListRequest, IndustryStocksRequest, TradingCalendarRequest, FinancialExchangeRateRequest, FinancialCurrencyRequest, MarketScannerTagsRequest, QuoteOvernightRequest } from '../model/quote-requests';
|
|
13
13
|
/**
|
|
14
14
|
* Parse an OCC-style option identifier like "AAPL 260619C00150000"
|
|
15
15
|
* into its component parts.
|
|
@@ -57,6 +57,7 @@ export declare class QuoteClient {
|
|
|
57
57
|
getBrief(req: BriefRequest): Promise<Brief[]>;
|
|
58
58
|
getKline(req: KlineRequest): Promise<Kline[]>;
|
|
59
59
|
getTimeline(symbols: string[]): Promise<Timeline[]>;
|
|
60
|
+
getTimeline(req: TimelineRequest): Promise<Timeline[]>;
|
|
60
61
|
/** Tick-by-tick trades. wire: trade_tick */
|
|
61
62
|
getTradeTick(req: TradeTickRequest): Promise<TradeTick[]>;
|
|
62
63
|
/** Depth snapshot. wire: quote_depth */
|
|
@@ -129,11 +130,18 @@ export declare class QuoteClient {
|
|
|
129
130
|
getStockFundamental(req: StockFundamentalRequest): Promise<Record<string, unknown>>;
|
|
130
131
|
/** Stock industry classification (array). wire: stock_industry */
|
|
131
132
|
getStockIndustry(req: StockIndustryRequest): Promise<StockIndustry[]>;
|
|
132
|
-
/**
|
|
133
|
+
/** Market data permission entries. wire: get_quote_permission */
|
|
133
134
|
getQuotePermission(req: QuotePermissionRequest): Promise<QuotePermission[]>;
|
|
134
135
|
/** K-line quota usage. wire: kline_quota */
|
|
135
136
|
getKlineQuota(req: KlineQuotaRequest): Promise<KlineQuota[]>;
|
|
136
|
-
/** Option tick trades. wire: option_trade_tick
|
|
137
|
+
/** Option tick trades. wire: option_trade_tick
|
|
138
|
+
*
|
|
139
|
+
* Server expects `biz_content` as a top-level JSON array (matches Java's
|
|
140
|
+
* `BatchApiModel` and Python's `MultipleContractParams.to_openapi_dict`).
|
|
141
|
+
* We unwrap the request here so the array is emitted directly instead of
|
|
142
|
+
* `{"contracts": [...]}`. Sending it as an object triggers
|
|
143
|
+
* `biz param error(failed to parse parameters in 'biz_content')`.
|
|
144
|
+
*/
|
|
137
145
|
getOptionTradeTicks(req: OptionTradeTicksRequest): Promise<TradeTick[]>;
|
|
138
146
|
/** Option intraday timeline. wire: option_timeline */
|
|
139
147
|
getOptionTimeline(req: OptionTimelineRequest): Promise<Timeline[]>;
|
|
@@ -154,7 +162,9 @@ export declare class QuoteClient {
|
|
|
154
162
|
/** Historical main contracts. wire: future_main_contract */
|
|
155
163
|
getFutureHistoryMainContract(req: FutureHistoryMainContractRequest): Promise<FutureMainContractHistory[]>;
|
|
156
164
|
/** Futures K-line. wire: future_kline
|
|
157
|
-
* beginTime / endTime default to -1 when unset (server requires them present).
|
|
165
|
+
* beginTime / endTime default to -1 when unset (server requires them present).
|
|
166
|
+
* Server expects `contract_codes` (plural) — normalize singular `contractCode`
|
|
167
|
+
* to the plural form so callers can pass either shape. */
|
|
158
168
|
getFutureKline(req: FutureKlineRequest): Promise<FutureKline[]>;
|
|
159
169
|
/** Client-side paginated futures K-line fetch. */
|
|
160
170
|
getFutureKlineByPage(req: FutureKlineByPageRequest): Promise<FutureKlineItem[]>;
|
|
@@ -180,8 +190,19 @@ export declare class QuoteClient {
|
|
|
180
190
|
getWarrantBriefs(req: WarrantBriefsRequest): Promise<WarrantBrief[]>;
|
|
181
191
|
/** Warrant filter (paged). wire: warrant_filter */
|
|
182
192
|
getWarrantFilter(req: WarrantFilterRequest): Promise<WarrantFilterResult | undefined>;
|
|
183
|
-
/** Industry list. wire: industry_list
|
|
184
|
-
|
|
193
|
+
/** Industry list. wire: industry_list
|
|
194
|
+
*
|
|
195
|
+
* `industryLevel` is required by the server — omitting it returns
|
|
196
|
+
* `industry level error, all supported is: [GSECTOR, GGROUP, GIND, GSUBIND]`.
|
|
197
|
+
* Defaults to `GGROUP` when unset, matching Python SDK's
|
|
198
|
+
* `IndustryLevel.GGROUP` default.
|
|
199
|
+
*
|
|
200
|
+
* Wire fields differ from other endpoints (see `IndustryItem`): server sends
|
|
201
|
+
* `nameCN` / `nameEN` / `industryLevel`. This method hydrates the
|
|
202
|
+
* backwards-compat `name` (from `nameEN || nameCN`) and mirrors
|
|
203
|
+
* `industryLevel` to `level` so existing callers keep working.
|
|
204
|
+
*/
|
|
205
|
+
getIndustryList(req?: IndustryListRequest): Promise<IndustryItem[]>;
|
|
185
206
|
/** Stocks inside an industry. wire: industry_stock_list */
|
|
186
207
|
getIndustryStocks(req: IndustryStocksRequest): Promise<IndustryStock[]>;
|
|
187
208
|
/** Corporate split (flattened). wire: corporate_action (action_type=split) */
|
|
@@ -51,6 +51,21 @@ export declare class TradeClient {
|
|
|
51
51
|
* `symbol` is the underlying (e.g. "AAPL"); `expiry` is "YYYYMMDD".
|
|
52
52
|
*/
|
|
53
53
|
getQuoteContract(symbol: string, secType: string, expiry: string): Promise<Contract[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Prepare an order request for the wire.
|
|
56
|
+
*
|
|
57
|
+
* The gateway expects `algo_params` as a `[{tag, value}, ...]` array
|
|
58
|
+
* (matching the Python SDK's AlgoParams.to_dict serialization), not the
|
|
59
|
+
* plain object shape that reads naturally in TypeScript. This helper
|
|
60
|
+
* normalizes the object form into the array form on outbound payloads
|
|
61
|
+
* so callers can pass the natural object and TWAP/VWAP orders work end
|
|
62
|
+
* to end without wire-format workarounds.
|
|
63
|
+
*
|
|
64
|
+
* Fields with undefined/null values are dropped; empty algoParams
|
|
65
|
+
* becomes an empty array rather than being stripped, matching the
|
|
66
|
+
* Python SDK behavior when the user passes an empty AlgoParams().
|
|
67
|
+
*/
|
|
68
|
+
private marshalOrderForWire;
|
|
54
69
|
placeOrder(order: OrderRequest): Promise<PlaceOrderResult | undefined>;
|
|
55
70
|
previewOrder(order: OrderRequest): Promise<PreviewResult | undefined>;
|
|
56
71
|
modifyOrder(id: number | string, order: OrderRequest): Promise<OrderIdResult | undefined>;
|
|
@@ -91,9 +106,15 @@ export declare class TradeClient {
|
|
|
91
106
|
getOrderTransactions(req: OrderTransactionsRequest): Promise<Transaction[]>;
|
|
92
107
|
/** Query positions. v0.4.0: supports Symbol / SecType / Currency / Market filters. */
|
|
93
108
|
getPositions(req?: PositionsRequest): Promise<Position[]>;
|
|
94
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Query assets. v0.4.0: supports sub-account list and aggregation options.
|
|
111
|
+
* `assetQuoteType`(ETH / RTH / OVERNIGHT) 选择资产行情口径。
|
|
112
|
+
*/
|
|
95
113
|
getAssets(req?: AssetsRequest): Promise<Asset[]>;
|
|
96
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* Query prime assets. v0.4.0: takes AssetsRequest for filters.
|
|
116
|
+
* `assetQuoteType`(ETH / RTH / OVERNIGHT) 选择资产行情口径。
|
|
117
|
+
*/
|
|
97
118
|
getPrimeAssets(req?: AssetsRequest): Promise<PrimeAsset | undefined>;
|
|
98
119
|
/** Query managed sub-accounts (institutional). */
|
|
99
120
|
getManagedAccounts(req?: ManagedAccountsRequest): Promise<ManagedAccount[]>;
|
|
@@ -104,7 +125,10 @@ export declare class TradeClient {
|
|
|
104
125
|
getDerivativeContracts(req: DerivativeContractsRequest): Promise<Contract[]>;
|
|
105
126
|
/** Daily P&L / net-value / holding-value analytics. */
|
|
106
127
|
getAnalyticsAsset(req: AnalyticsAssetRequest): Promise<AnalyticsAsset[]>;
|
|
107
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* Aggregate assets (prime) by base currency.
|
|
130
|
+
* `assetQuoteType`(ETH / RTH / OVERNIGHT) 选择资产行情口径。
|
|
131
|
+
*/
|
|
108
132
|
getAggregateAssets(req?: AggregateAssetsRequest): Promise<AggregateAssets | undefined>;
|
|
109
133
|
/** Estimate tradable quantity given order parameters. */
|
|
110
134
|
getEstimateTradableQuantity(req: EstimateTradableQuantityRequest): Promise<EstimateTradableQuantity | undefined>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.5.7";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tigeropenapi/tigeropen",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
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",
|
|
@@ -24,13 +24,16 @@
|
|
|
24
24
|
"url": "https://github.com/tigerfintech/openapi-typescript-sdk/issues"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && node scripts/fix-esm-imports.mjs",
|
|
28
|
-
"build:esm": "tsc -p tsconfig.json",
|
|
27
|
+
"build": "node scripts/sync-version.mjs && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && node scripts/fix-esm-imports.mjs",
|
|
28
|
+
"build:esm": "tsc -p tsconfig.json && node scripts/fix-esm-imports.mjs",
|
|
29
29
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
30
30
|
"prepublishOnly": "npm run build",
|
|
31
31
|
"publish:all": "npm run build && npm publish --registry https://registry.npmjs.org --access public && npm pkg set name=tigeropen && npm publish --registry https://registry.npmjs.org && npm pkg set name=@tigeropenapi/tigeropen",
|
|
32
32
|
"test": "vitest run",
|
|
33
|
+
"test:unit": "vitest run --config vitest.config.ts",
|
|
34
|
+
"test:integ": "TIGER_RUN_INTEG=true vitest run --config vitest.integ.config.ts",
|
|
33
35
|
"test:watch": "vitest",
|
|
36
|
+
"sync-version": "node scripts/sync-version.mjs",
|
|
34
37
|
"clean": "rm -rf dist",
|
|
35
38
|
"proto:generate": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/push/pb --ts_proto_opt=esModuleInterop=true,outputEncodeMethods=true,outputJsonMethods=false,outputClientImpl=false -I=./proto ./proto/*.proto"
|
|
36
39
|
},
|
|
@@ -56,5 +59,6 @@
|
|
|
56
59
|
},
|
|
57
60
|
"dependencies": {
|
|
58
61
|
"@bufbuild/protobuf": "^2.12.0"
|
|
59
|
-
}
|
|
62
|
+
},
|
|
63
|
+
"gitHead": "3655981845c4255e6b9f48d629e874dc3b0b699b"
|
|
60
64
|
}
|