tigeropen 0.3.0 → 0.5.5
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 +55 -2
- package/dist/cjs/client/api-response.js +28 -7
- package/dist/cjs/client/case-convert.js +4 -3
- package/dist/cjs/client/http-client.js +124 -8
- package/dist/cjs/client/token-methods.js +42 -0
- package/dist/cjs/config/client-config.js +115 -16
- package/dist/cjs/config/config-parser.js +19 -9
- package/dist/cjs/config/index.js +4 -1
- package/dist/cjs/config/token-manager.js +54 -4
- package/dist/cjs/index.js +53 -2
- package/dist/cjs/model/enums.js +106 -7
- package/dist/cjs/model/order-helpers.js +149 -0
- package/dist/cjs/model/order-status.js +46 -0
- package/dist/cjs/model/quote-requests.js +11 -0
- package/dist/cjs/model/trade-requests.js +13 -0
- package/dist/cjs/push/index.js +1 -0
- package/dist/cjs/push/pb/OrderStatusData.js +24 -0
- package/dist/cjs/push/proto-message.js +6 -0
- package/dist/cjs/push/push-client.js +117 -19
- package/dist/cjs/push/push-message.js +4 -0
- package/dist/cjs/push/tick-util.js +172 -0
- package/dist/cjs/quote/quote-client.js +584 -42
- package/dist/cjs/trade/trade-client.js +334 -32
- package/dist/cjs/version.js +4 -0
- package/dist/esm/client/api-request.js +1 -1
- package/dist/esm/client/api-response.js +29 -8
- package/dist/esm/client/case-convert.js +4 -3
- package/dist/esm/client/http-client.js +128 -12
- package/dist/esm/client/index.js +6 -6
- package/dist/esm/client/token-methods.js +37 -0
- package/dist/esm/config/client-config.js +118 -20
- package/dist/esm/config/config-parser.js +19 -9
- package/dist/esm/config/index.js +4 -3
- package/dist/esm/config/token-manager.js +55 -5
- package/dist/esm/index.js +15 -1
- package/dist/esm/logger/index.js +1 -1
- package/dist/esm/model/contract-helpers.js +1 -1
- package/dist/esm/model/enums.js +104 -6
- package/dist/esm/model/order-helpers.js +142 -1
- package/dist/esm/model/order-status.js +43 -0
- package/dist/esm/model/quote-requests.js +10 -0
- package/dist/esm/model/trade-requests.js +12 -0
- package/dist/esm/push/index.js +6 -5
- package/dist/esm/push/pb/OrderStatusData.js +24 -0
- package/dist/esm/push/pb/PushData.js +11 -11
- package/dist/esm/push/pb/QuoteBasicData.js +1 -1
- package/dist/esm/push/pb/Response.js +1 -1
- package/dist/esm/push/pb/index.js +17 -17
- package/dist/esm/push/proto-message.js +9 -3
- package/dist/esm/push/push-client.js +124 -26
- package/dist/esm/push/push-message.js +4 -0
- package/dist/esm/push/tick-util.js +165 -0
- package/dist/esm/quote/index.js +1 -1
- package/dist/esm/quote/quote-client.js +553 -44
- package/dist/esm/signer/index.js +2 -2
- package/dist/esm/trade/index.js +1 -1
- package/dist/esm/trade/trade-client.js +303 -34
- package/dist/esm/version.js +1 -0
- package/dist/types/client/api-response.d.ts +6 -4
- package/dist/types/client/case-convert.d.ts +3 -1
- package/dist/types/client/http-client.d.ts +32 -1
- package/dist/types/client/token-methods.d.ts +34 -0
- package/dist/types/config/client-config.d.ts +22 -1
- package/dist/types/config/index.d.ts +3 -1
- package/dist/types/config/token-manager.d.ts +27 -3
- package/dist/types/index.d.ts +22 -1
- package/dist/types/model/enums.d.ts +77 -7
- package/dist/types/model/order-helpers.d.ts +52 -1
- package/dist/types/model/order-status.d.ts +14 -0
- package/dist/types/model/order.d.ts +127 -10
- package/dist/types/model/quote-requests.d.ts +356 -0
- package/dist/types/model/quote.d.ts +391 -4
- package/dist/types/model/trade-requests.d.ts +309 -0
- package/dist/types/model/trade.d.ts +231 -5
- package/dist/types/push/callbacks.d.ts +3 -7
- package/dist/types/push/index.d.ts +1 -0
- package/dist/types/push/pb/OrderStatusData.d.ts +4 -0
- package/dist/types/push/push-client.d.ts +36 -3
- package/dist/types/push/push-message.d.ts +4 -0
- package/dist/types/push/tick-util.d.ts +30 -0
- package/dist/types/quote/quote-client.d.ts +193 -15
- package/dist/types/trade/trade-client.d.ts +136 -18
- package/dist/types/version.d.ts +1 -0
- package/package.json +5 -2
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trade request interfaces (v0.4.0).
|
|
3
|
+
*
|
|
4
|
+
* 所有字段可选(用户调用时传一个空对象即可);字段名用 camelCase,
|
|
5
|
+
* client 层通过 keysToSnakeCase 转成服务端 wire 真名的 snake_case。
|
|
6
|
+
* **字段名设计规则:camelCase → snake_case 后必须等于服务端 wire 真名。**
|
|
7
|
+
* 比如 Trade 用 `startDate`/`endDate`(wire `start_date`/`end_date`),
|
|
8
|
+
* 不用 `startTime`/`endTime`(会被转成 `start_time`/`end_time`,与 wire 不符)。
|
|
9
|
+
*
|
|
10
|
+
* 参考 Go SDK model/trade_requests.go。
|
|
11
|
+
*/
|
|
12
|
+
export interface OrdersRequest {
|
|
13
|
+
account?: string;
|
|
14
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
15
|
+
secretKey?: string;
|
|
16
|
+
secType?: string;
|
|
17
|
+
market?: string;
|
|
18
|
+
symbol?: string;
|
|
19
|
+
/** 毫秒时间戳 (wire: start_date) */
|
|
20
|
+
startDate?: number;
|
|
21
|
+
/** 毫秒时间戳 (wire: end_date) */
|
|
22
|
+
endDate?: number;
|
|
23
|
+
limit?: number;
|
|
24
|
+
isBrief?: boolean;
|
|
25
|
+
/** 订单状态过滤: Invalid / Initial / PendingCancel / Cancelled / Submitted / Filled / Inactive / PendingSubmit */
|
|
26
|
+
states?: string[];
|
|
27
|
+
/** LATEST_CREATED / LATEST_STATUS_UPDATED */
|
|
28
|
+
sortBy?: string;
|
|
29
|
+
segType?: string;
|
|
30
|
+
lang?: string;
|
|
31
|
+
pageToken?: string;
|
|
32
|
+
/** 仅 ActiveOrders 使用,按父订单 ID 过滤附加订单 */
|
|
33
|
+
parentId?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface GetOrderRequest {
|
|
36
|
+
account?: string;
|
|
37
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
38
|
+
secretKey?: string;
|
|
39
|
+
id?: number;
|
|
40
|
+
orderId?: number;
|
|
41
|
+
isBrief?: boolean;
|
|
42
|
+
showCharges?: boolean;
|
|
43
|
+
lang?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface OrderTransactionsRequest {
|
|
46
|
+
account?: string;
|
|
47
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
48
|
+
secretKey?: string;
|
|
49
|
+
orderId?: number;
|
|
50
|
+
symbol?: string;
|
|
51
|
+
secType?: string;
|
|
52
|
+
/** 毫秒时间戳 */
|
|
53
|
+
startDate?: number;
|
|
54
|
+
/** 毫秒时间戳 */
|
|
55
|
+
endDate?: number;
|
|
56
|
+
limit?: number;
|
|
57
|
+
expiry?: string;
|
|
58
|
+
strike?: number;
|
|
59
|
+
putCall?: string;
|
|
60
|
+
lang?: string;
|
|
61
|
+
pageToken?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface PositionsRequest {
|
|
64
|
+
account?: string;
|
|
65
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
66
|
+
secretKey?: string;
|
|
67
|
+
secType?: string;
|
|
68
|
+
currency?: string;
|
|
69
|
+
market?: string;
|
|
70
|
+
symbol?: string;
|
|
71
|
+
subAccounts?: string[];
|
|
72
|
+
expiry?: string;
|
|
73
|
+
strike?: string;
|
|
74
|
+
right?: string;
|
|
75
|
+
assetQuoteType?: string;
|
|
76
|
+
lang?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface AssetsRequest {
|
|
79
|
+
account?: string;
|
|
80
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
81
|
+
secretKey?: string;
|
|
82
|
+
subAccounts?: string[];
|
|
83
|
+
segment?: boolean;
|
|
84
|
+
marketValue?: boolean;
|
|
85
|
+
lang?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ManagedAccountsRequest {
|
|
88
|
+
account?: string;
|
|
89
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
90
|
+
secretKey?: string;
|
|
91
|
+
lang?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface DerivativeContractsRequest {
|
|
94
|
+
account?: string;
|
|
95
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
96
|
+
secretKey?: string;
|
|
97
|
+
symbols: string[];
|
|
98
|
+
secType: string;
|
|
99
|
+
expiry?: string;
|
|
100
|
+
lang?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface AnalyticsAssetRequest {
|
|
103
|
+
account?: string;
|
|
104
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
105
|
+
secretKey?: string;
|
|
106
|
+
segType?: string;
|
|
107
|
+
/** 格式 "YYYY-MM-DD" */
|
|
108
|
+
startDate?: string;
|
|
109
|
+
endDate?: string;
|
|
110
|
+
lang?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface AggregateAssetsRequest {
|
|
113
|
+
account?: string;
|
|
114
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
115
|
+
secretKey?: string;
|
|
116
|
+
baseCurrency?: string;
|
|
117
|
+
segType?: string;
|
|
118
|
+
lang?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface EstimateTradableQuantityRequest {
|
|
121
|
+
account?: string;
|
|
122
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
123
|
+
secretKey?: string;
|
|
124
|
+
symbol: string;
|
|
125
|
+
secType: string;
|
|
126
|
+
action: string;
|
|
127
|
+
orderType?: string;
|
|
128
|
+
limitPrice?: number;
|
|
129
|
+
market?: string;
|
|
130
|
+
currency?: string;
|
|
131
|
+
expiry?: string;
|
|
132
|
+
strike?: string;
|
|
133
|
+
right?: string;
|
|
134
|
+
lang?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface ForexOrderRequest {
|
|
137
|
+
account?: string;
|
|
138
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
139
|
+
secretKey?: string;
|
|
140
|
+
segType?: string;
|
|
141
|
+
sourceCurrency: string;
|
|
142
|
+
targetCurrency: string;
|
|
143
|
+
sourceAmount?: number;
|
|
144
|
+
targetAmount?: number;
|
|
145
|
+
orderType?: string;
|
|
146
|
+
lang?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface SegmentFundRequest {
|
|
149
|
+
account?: string;
|
|
150
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
151
|
+
secretKey?: string;
|
|
152
|
+
id?: string;
|
|
153
|
+
fromSegment?: string;
|
|
154
|
+
toSegment?: string;
|
|
155
|
+
currency?: string;
|
|
156
|
+
amount?: number;
|
|
157
|
+
limit?: number;
|
|
158
|
+
lang?: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Fund details request. wire: fund_details
|
|
162
|
+
*
|
|
163
|
+
* **Wire types (breaking):** `startDate` / `endDate` are yyyy-MM-dd date
|
|
164
|
+
* strings, not epoch-ms integers. Java's `FundDetailsModel` exposes them
|
|
165
|
+
* as `String startDate` / `String endDate`; sending epoch-ms causes
|
|
166
|
+
* `parse 'start_date' error, supported format: 'yyyy-MM-dd'`.
|
|
167
|
+
*/
|
|
168
|
+
export interface FundDetailsRequest {
|
|
169
|
+
account?: string;
|
|
170
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
171
|
+
secretKey?: string;
|
|
172
|
+
segTypes?: string[];
|
|
173
|
+
fundType?: string;
|
|
174
|
+
currency?: string;
|
|
175
|
+
/** yyyy-MM-dd 日期字符串 */
|
|
176
|
+
startDate?: string;
|
|
177
|
+
/** yyyy-MM-dd 日期字符串 */
|
|
178
|
+
endDate?: string;
|
|
179
|
+
limit?: number;
|
|
180
|
+
pageToken?: string;
|
|
181
|
+
lang?: string;
|
|
182
|
+
}
|
|
183
|
+
export interface FundingHistoryRequest {
|
|
184
|
+
account?: string;
|
|
185
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
186
|
+
secretKey?: string;
|
|
187
|
+
segType?: string;
|
|
188
|
+
currency?: string;
|
|
189
|
+
/** 毫秒时间戳 */
|
|
190
|
+
startDate?: number;
|
|
191
|
+
/** 毫秒时间戳 */
|
|
192
|
+
endDate?: number;
|
|
193
|
+
limit?: number;
|
|
194
|
+
lang?: string;
|
|
195
|
+
}
|
|
196
|
+
export interface PositionTransferRequest {
|
|
197
|
+
fromAccount?: string;
|
|
198
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
199
|
+
secretKey?: string;
|
|
200
|
+
toAccount: string;
|
|
201
|
+
market?: string;
|
|
202
|
+
transfers: Array<{
|
|
203
|
+
symbol?: string;
|
|
204
|
+
quantity?: number;
|
|
205
|
+
expiry?: string;
|
|
206
|
+
strike?: string;
|
|
207
|
+
right?: string;
|
|
208
|
+
secType?: string;
|
|
209
|
+
}>;
|
|
210
|
+
lang?: string;
|
|
211
|
+
}
|
|
212
|
+
export interface PositionTransferRecordsRequest {
|
|
213
|
+
/** wire: account_id */
|
|
214
|
+
accountId?: string;
|
|
215
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
216
|
+
secretKey?: string;
|
|
217
|
+
sinceDate?: string;
|
|
218
|
+
toDate?: string;
|
|
219
|
+
market?: string;
|
|
220
|
+
limit?: number;
|
|
221
|
+
lang?: string;
|
|
222
|
+
}
|
|
223
|
+
export interface PositionTransferDetailRequest {
|
|
224
|
+
accountId?: string;
|
|
225
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
226
|
+
secretKey?: string;
|
|
227
|
+
id: string;
|
|
228
|
+
lang?: string;
|
|
229
|
+
}
|
|
230
|
+
export interface PositionTransferExternalRecordsRequest {
|
|
231
|
+
accountId?: string;
|
|
232
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
233
|
+
secretKey?: string;
|
|
234
|
+
sinceDate?: string;
|
|
235
|
+
toDate?: string;
|
|
236
|
+
market?: string;
|
|
237
|
+
limit?: number;
|
|
238
|
+
lang?: string;
|
|
239
|
+
}
|
|
240
|
+
/** 行权检验请求 (wire: option_exercise_check) */
|
|
241
|
+
export interface OptionExerciseCheckRequest {
|
|
242
|
+
account?: string;
|
|
243
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
244
|
+
secretKey?: string;
|
|
245
|
+
/** 期权合约 ID */
|
|
246
|
+
contractId: number;
|
|
247
|
+
/** Exercise | Expire */
|
|
248
|
+
type: string;
|
|
249
|
+
quantity?: number;
|
|
250
|
+
/** yyyy-MM-dd,Exercise 类型建议填 */
|
|
251
|
+
executingDate?: string;
|
|
252
|
+
/** Exercise 类型建议填 */
|
|
253
|
+
isForce?: boolean;
|
|
254
|
+
/** 0–10,Expire 类型专用 */
|
|
255
|
+
itmRate?: number;
|
|
256
|
+
lang?: string;
|
|
257
|
+
}
|
|
258
|
+
/** 查询可行权持仓请求 (wire: option_exercise_position) */
|
|
259
|
+
export interface OptionExercisePositionRequest {
|
|
260
|
+
account?: string;
|
|
261
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
262
|
+
secretKey?: string;
|
|
263
|
+
/** Exercise | Expire */
|
|
264
|
+
type: string;
|
|
265
|
+
lang?: string;
|
|
266
|
+
}
|
|
267
|
+
/** 提交行权申请请求 (wire: option_exercise_submit) */
|
|
268
|
+
export interface OptionExerciseSubmitRequest {
|
|
269
|
+
account?: string;
|
|
270
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
271
|
+
secretKey?: string;
|
|
272
|
+
contractId: number;
|
|
273
|
+
/** Exercise | Expire */
|
|
274
|
+
type: string;
|
|
275
|
+
quantity: number;
|
|
276
|
+
/** Exercise 必填,yyyy-MM-dd */
|
|
277
|
+
executingDate?: string;
|
|
278
|
+
/** Exercise 必填 */
|
|
279
|
+
isForce?: boolean;
|
|
280
|
+
/** 0–10,Expire 专用 */
|
|
281
|
+
itmRate?: number;
|
|
282
|
+
lang?: string;
|
|
283
|
+
}
|
|
284
|
+
/** 分页查询行权记录请求 (wire: option_exercise_record) */
|
|
285
|
+
export interface OptionExerciseRecordsRequest {
|
|
286
|
+
account?: string;
|
|
287
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
288
|
+
secretKey?: string;
|
|
289
|
+
/** 从 1 开始,默认 1 */
|
|
290
|
+
page?: number;
|
|
291
|
+
/** 1–100,默认 20 */
|
|
292
|
+
size?: number;
|
|
293
|
+
/** New | Cancel | Success | Fail */
|
|
294
|
+
status?: string;
|
|
295
|
+
/** Exercise | Expire */
|
|
296
|
+
type?: string;
|
|
297
|
+
symbol?: string;
|
|
298
|
+
/** symbol | expire_date | strike | is_call */
|
|
299
|
+
orderBy?: string;
|
|
300
|
+
lang?: string;
|
|
301
|
+
}
|
|
302
|
+
/** 撤销行权申请请求 (wire: option_exercise_cancel) */
|
|
303
|
+
export interface OptionExerciseCancelRequest {
|
|
304
|
+
account?: string;
|
|
305
|
+
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
306
|
+
secretKey?: string;
|
|
307
|
+
id: number;
|
|
308
|
+
lang?: string;
|
|
309
|
+
}
|
|
@@ -84,18 +84,22 @@ export interface PreviewResult {
|
|
|
84
84
|
message?: string;
|
|
85
85
|
}
|
|
86
86
|
export interface PlaceOrderResult {
|
|
87
|
-
|
|
87
|
+
/** int64 order ID — may be a string when it exceeds Number.MAX_SAFE_INTEGER */
|
|
88
|
+
id: number | string;
|
|
88
89
|
/** Account-level order ID; the server returns snake_case `order_id` */
|
|
89
|
-
order_id?: number;
|
|
90
|
-
subIds?: number[];
|
|
90
|
+
order_id?: number | string;
|
|
91
|
+
subIds?: (number | string)[];
|
|
91
92
|
orders?: Order[];
|
|
92
93
|
}
|
|
93
94
|
export interface OrderIdResult {
|
|
94
|
-
|
|
95
|
+
/** int64 order ID — may be a string when it exceeds Number.MAX_SAFE_INTEGER */
|
|
96
|
+
id: number | string;
|
|
95
97
|
}
|
|
96
98
|
export interface Transaction {
|
|
97
99
|
id?: number;
|
|
98
100
|
orderId?: number;
|
|
101
|
+
/** Numeric account ID (wire: accountId). */
|
|
102
|
+
accountId?: number;
|
|
99
103
|
account?: string;
|
|
100
104
|
symbol?: string;
|
|
101
105
|
secType?: string;
|
|
@@ -103,11 +107,233 @@ export interface Transaction {
|
|
|
103
107
|
currency?: string;
|
|
104
108
|
identifier?: string;
|
|
105
109
|
action?: string;
|
|
110
|
+
/** Order/commission price. */
|
|
106
111
|
price?: number;
|
|
112
|
+
/** Fill price (wire: filledPrice). */
|
|
113
|
+
filledPrice?: number;
|
|
107
114
|
quantity?: number;
|
|
108
115
|
filledQuantity?: number;
|
|
116
|
+
/** Scale for filledQuantity (wire: filledQuantityScale). */
|
|
117
|
+
filledQuantityScale?: number;
|
|
118
|
+
/** Order amount. */
|
|
109
119
|
amount?: number;
|
|
120
|
+
/** Fill amount (wire: filledAmount). */
|
|
121
|
+
filledAmount?: number;
|
|
110
122
|
commission?: number;
|
|
111
|
-
|
|
123
|
+
/** Fill timestamp string, format "YYYY-MM-DD HH:MM:SS" (server returns string, not number). */
|
|
124
|
+
transactedAt?: string;
|
|
125
|
+
/** Fill time as Unix millisecond timestamp (wire: transactionTime). */
|
|
126
|
+
transactionTime?: number;
|
|
127
|
+
/** Legacy time field. */
|
|
112
128
|
time?: number;
|
|
113
129
|
}
|
|
130
|
+
export interface ManagedAccount {
|
|
131
|
+
account?: string;
|
|
132
|
+
accountType?: string;
|
|
133
|
+
capability?: string;
|
|
134
|
+
status?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface AnalyticsAsset {
|
|
137
|
+
date?: string;
|
|
138
|
+
holdingValue?: number;
|
|
139
|
+
cashBalance?: number;
|
|
140
|
+
pnl?: number;
|
|
141
|
+
pnlRate?: number;
|
|
142
|
+
netValueIndex?: number;
|
|
143
|
+
currency?: string;
|
|
144
|
+
segType?: string;
|
|
145
|
+
}
|
|
146
|
+
export interface AggregateAssets {
|
|
147
|
+
accountId?: string;
|
|
148
|
+
netLiquidation?: number;
|
|
149
|
+
grossPositionValue?: number;
|
|
150
|
+
cashBalance?: number;
|
|
151
|
+
baseCurrency?: string;
|
|
152
|
+
currencyAssets?: CurrencyAsset[];
|
|
153
|
+
}
|
|
154
|
+
export interface EstimateTradableQuantity {
|
|
155
|
+
tradableQuantity?: number;
|
|
156
|
+
maxCashBuyQuantity?: number;
|
|
157
|
+
maxMarginBuyQuantity?: number;
|
|
158
|
+
maxShortSellQuantity?: number;
|
|
159
|
+
maxPositionSellQuantity?: number;
|
|
160
|
+
cashBuyingPower?: number;
|
|
161
|
+
currency?: string;
|
|
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
|
+
*/
|
|
172
|
+
export interface ForexOrderResult {
|
|
173
|
+
/** int64 forex order ID; may be a string when exceeding Number.MAX_SAFE_INTEGER */
|
|
174
|
+
id?: number | string;
|
|
175
|
+
status?: string;
|
|
176
|
+
sourceCurrency?: string;
|
|
177
|
+
targetCurrency?: string;
|
|
178
|
+
sourceAmount?: number;
|
|
179
|
+
targetAmount?: number;
|
|
180
|
+
rate?: number;
|
|
181
|
+
submitTime?: number;
|
|
182
|
+
}
|
|
183
|
+
/** Segment fund available item (segment_fund_available response). */
|
|
184
|
+
export interface SegmentFundAvailableItem {
|
|
185
|
+
fromSegment?: string;
|
|
186
|
+
currency?: string;
|
|
187
|
+
amount?: number;
|
|
188
|
+
}
|
|
189
|
+
/** Segment fund transfer/cancel response. */
|
|
190
|
+
export interface SegmentFund {
|
|
191
|
+
id?: string | number;
|
|
192
|
+
fromSegment?: string;
|
|
193
|
+
toSegment?: string;
|
|
194
|
+
currency?: string;
|
|
195
|
+
amount?: number;
|
|
196
|
+
status?: string;
|
|
197
|
+
statusDesc?: string;
|
|
198
|
+
message?: string;
|
|
199
|
+
settledAt?: number;
|
|
200
|
+
createdAt?: number;
|
|
201
|
+
updatedAt?: number;
|
|
202
|
+
}
|
|
203
|
+
export interface SegmentFundHistoryItem {
|
|
204
|
+
id?: number;
|
|
205
|
+
fromSegment?: string;
|
|
206
|
+
toSegment?: string;
|
|
207
|
+
currency?: string;
|
|
208
|
+
amount?: number;
|
|
209
|
+
status?: string;
|
|
210
|
+
statusDesc?: string;
|
|
211
|
+
settledAt?: number;
|
|
212
|
+
createdAt?: number;
|
|
213
|
+
updatedAt?: number;
|
|
214
|
+
}
|
|
215
|
+
export interface FundDetails {
|
|
216
|
+
/** int64 fund-detail ID — server may return as string (e.g. "4733519770"). */
|
|
217
|
+
id?: string | number;
|
|
218
|
+
account?: string;
|
|
219
|
+
segType?: string;
|
|
220
|
+
fundType?: string;
|
|
221
|
+
currency?: string;
|
|
222
|
+
amount?: number;
|
|
223
|
+
balance?: number;
|
|
224
|
+
occurTime?: number;
|
|
225
|
+
remark?: string;
|
|
226
|
+
externalId?: string;
|
|
227
|
+
}
|
|
228
|
+
export interface FundingHistoryItem {
|
|
229
|
+
id?: number;
|
|
230
|
+
refId?: string;
|
|
231
|
+
type?: number;
|
|
232
|
+
typeDesc?: string;
|
|
233
|
+
currency?: string;
|
|
234
|
+
amount?: number;
|
|
235
|
+
businessDate?: string;
|
|
236
|
+
status?: string;
|
|
237
|
+
statusDesc?: string;
|
|
238
|
+
completedStatus?: boolean;
|
|
239
|
+
createdAt?: number;
|
|
240
|
+
updatedAt?: number;
|
|
241
|
+
}
|
|
242
|
+
export interface TransferItem {
|
|
243
|
+
symbol?: string;
|
|
244
|
+
quantity?: number;
|
|
245
|
+
expiry?: string;
|
|
246
|
+
strike?: string;
|
|
247
|
+
right?: string;
|
|
248
|
+
secType?: string;
|
|
249
|
+
}
|
|
250
|
+
export interface PositionTransferRecord {
|
|
251
|
+
id?: string;
|
|
252
|
+
fromAccount?: string;
|
|
253
|
+
toAccount?: string;
|
|
254
|
+
market?: string;
|
|
255
|
+
status?: string;
|
|
256
|
+
submitTime?: number;
|
|
257
|
+
transfers?: TransferItem[];
|
|
258
|
+
}
|
|
259
|
+
export interface PositionTransferDetail {
|
|
260
|
+
id?: string;
|
|
261
|
+
fromAccount?: string;
|
|
262
|
+
toAccount?: string;
|
|
263
|
+
market?: string;
|
|
264
|
+
status?: string;
|
|
265
|
+
submitTime?: number;
|
|
266
|
+
updateTime?: number;
|
|
267
|
+
transfers?: TransferItem[];
|
|
268
|
+
remark?: string;
|
|
269
|
+
}
|
|
270
|
+
export interface PositionTransferExternalRecord {
|
|
271
|
+
id?: string;
|
|
272
|
+
market?: string;
|
|
273
|
+
symbol?: string;
|
|
274
|
+
quantity?: number;
|
|
275
|
+
direction?: string;
|
|
276
|
+
status?: string;
|
|
277
|
+
submitTime?: number;
|
|
278
|
+
updateTime?: number;
|
|
279
|
+
}
|
|
280
|
+
/** 行权检验结果 */
|
|
281
|
+
export interface OptionExerciseCheckResult {
|
|
282
|
+
availableQuantity: number;
|
|
283
|
+
position: number;
|
|
284
|
+
stkPosition: number;
|
|
285
|
+
stkPositionChange: number;
|
|
286
|
+
stkPositionBefore: number;
|
|
287
|
+
stkPositionAfter: number;
|
|
288
|
+
symbol?: string;
|
|
289
|
+
}
|
|
290
|
+
/** 可行权期权持仓条目 */
|
|
291
|
+
export interface OptionExercisePosition {
|
|
292
|
+
contractId?: number;
|
|
293
|
+
symbol?: string;
|
|
294
|
+
stkSymbol?: string;
|
|
295
|
+
expireDate?: string;
|
|
296
|
+
strike?: string;
|
|
297
|
+
callPut?: string;
|
|
298
|
+
market?: string;
|
|
299
|
+
accountId?: number;
|
|
300
|
+
position: number;
|
|
301
|
+
availableQuantity: number;
|
|
302
|
+
}
|
|
303
|
+
/** 可行权持仓分页结果 */
|
|
304
|
+
export interface OptionExercisePositionPageResult {
|
|
305
|
+
pageNum: number;
|
|
306
|
+
pageSize: number;
|
|
307
|
+
itemCount: number;
|
|
308
|
+
pageCount: number;
|
|
309
|
+
items?: OptionExercisePosition[];
|
|
310
|
+
}
|
|
311
|
+
/** 行权申请记录条目 */
|
|
312
|
+
export interface OptionExerciseRecord {
|
|
313
|
+
id?: number;
|
|
314
|
+
contractId?: number;
|
|
315
|
+
symbol?: string;
|
|
316
|
+
stkSymbol?: string;
|
|
317
|
+
expireDate?: string;
|
|
318
|
+
strike?: string;
|
|
319
|
+
callPut?: string;
|
|
320
|
+
/** Exercise | Expire */
|
|
321
|
+
type?: string;
|
|
322
|
+
requestQuantity: number;
|
|
323
|
+
quantity: number;
|
|
324
|
+
/** New | Cancel | Success | Fail */
|
|
325
|
+
status?: string;
|
|
326
|
+
executingDate?: string;
|
|
327
|
+
itmRate: number;
|
|
328
|
+
isForce: boolean;
|
|
329
|
+
reason?: string;
|
|
330
|
+
accountId?: number;
|
|
331
|
+
}
|
|
332
|
+
/** 行权记录分页结果 */
|
|
333
|
+
export interface OptionExerciseRecordPageResult {
|
|
334
|
+
pageNum: number;
|
|
335
|
+
pageSize: number;
|
|
336
|
+
itemCount: number;
|
|
337
|
+
pageCount: number;
|
|
338
|
+
items?: OptionExerciseRecord[];
|
|
339
|
+
}
|
|
@@ -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
10
|
export type { PushClientOptions, TLSSocketLike, TLSSocketFactory } from './push-client';
|
|
@@ -75,6 +75,10 @@ export interface OrderStatusData {
|
|
|
75
75
|
gst: number;
|
|
76
76
|
attrList: string[];
|
|
77
77
|
timeInForce: string;
|
|
78
|
+
/** timestamp (ms) of order info update */
|
|
79
|
+
updateTime: number;
|
|
80
|
+
/** timestamp (ms) of order status update */
|
|
81
|
+
latestTime: number;
|
|
78
82
|
}
|
|
79
83
|
export declare const OrderStatusData: MessageFns<OrderStatusData>;
|
|
80
84
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
@@ -44,10 +44,12 @@ export declare class PushClient {
|
|
|
44
44
|
private useFullTick;
|
|
45
45
|
private socket;
|
|
46
46
|
private _state;
|
|
47
|
+
/** Whether this connect attempt already fell back to unverified TLS */
|
|
48
|
+
private tlsFallback;
|
|
47
49
|
private callbacks;
|
|
48
50
|
/** Subscription state: subject -> Set<symbol> */
|
|
49
51
|
private subscriptions;
|
|
50
|
-
/** Account-level subscriptions */
|
|
52
|
+
/** Account-level subscriptions: subject -> account string used at subscribe time */
|
|
51
53
|
private accountSubs;
|
|
52
54
|
private heartbeatTimer;
|
|
53
55
|
private reconnectTimer;
|
|
@@ -117,6 +119,37 @@ export declare class PushClient {
|
|
|
117
119
|
subscribeKline(symbols: string[]): void;
|
|
118
120
|
/** Unsubscribe from kline data */
|
|
119
121
|
unsubscribeKline(symbols?: string[]): void;
|
|
122
|
+
/**
|
|
123
|
+
* Subscribe to stock top rankings (v0.4.0).
|
|
124
|
+
* @param market US / HK / CN
|
|
125
|
+
* @param indicators LATEST_PRICE / HIGHER / LOWER / VOLUME / AMOUNT / AMPLITUDE / TURNOVER_RATE
|
|
126
|
+
*/
|
|
127
|
+
subscribeStockTop(market: string, indicators: string[]): void;
|
|
128
|
+
/** Unsubscribe from stock top rankings (v0.4.0). */
|
|
129
|
+
unsubscribeStockTop(market: string, indicators: string[]): void;
|
|
130
|
+
/**
|
|
131
|
+
* Subscribe to option top rankings (v0.4.0).
|
|
132
|
+
* @param market US / HK / CN
|
|
133
|
+
*/
|
|
134
|
+
subscribeOptionTop(market: string, indicators: string[]): void;
|
|
135
|
+
/** Unsubscribe from option top rankings (v0.4.0). */
|
|
136
|
+
unsubscribeOptionTop(market: string, indicators: string[]): void;
|
|
137
|
+
/**
|
|
138
|
+
* Subscribe to crypto realtime quotes (v0.4.0).
|
|
139
|
+
* Data is delivered via the `onQuote` callback (same QuoteData body).
|
|
140
|
+
* @param symbols e.g. ["BTCUSD", "ETHUSD"]
|
|
141
|
+
*/
|
|
142
|
+
subscribeCc(symbols: string[]): void;
|
|
143
|
+
/** Unsubscribe from crypto realtime quotes (v0.4.0). */
|
|
144
|
+
unsubscribeCc(symbols?: string[]): void;
|
|
145
|
+
/**
|
|
146
|
+
* Subscribe to market status updates (v0.4.0).
|
|
147
|
+
* Protocol uses dataType=Quote with only the `market` field set.
|
|
148
|
+
* Data is delivered via the `onQuote` callback.
|
|
149
|
+
*/
|
|
150
|
+
subscribeMarket(market: string): void;
|
|
151
|
+
/** Unsubscribe from market status (v0.4.0). */
|
|
152
|
+
unsubscribeMarket(market: string): void;
|
|
120
153
|
/** Subscribe to asset changes */
|
|
121
154
|
subscribeAsset(account?: string): void;
|
|
122
155
|
/** Unsubscribe from asset changes */
|
|
@@ -135,6 +168,6 @@ export declare class PushClient {
|
|
|
135
168
|
unsubscribeTransaction(): void;
|
|
136
169
|
/** Get current market data subscriptions */
|
|
137
170
|
getSubscriptions(): Map<SubjectType, string[]>;
|
|
138
|
-
/** Get account-level subscriptions */
|
|
139
|
-
getAccountSubscriptions(): SubjectType
|
|
171
|
+
/** Get account-level subscriptions: subject -> account */
|
|
172
|
+
getAccountSubscriptions(): Map<SubjectType, string>;
|
|
140
173
|
}
|
|
@@ -16,6 +16,10 @@ export declare enum SubjectType {
|
|
|
16
16
|
OptionTop = "option_top",
|
|
17
17
|
FullTick = "full_tick",
|
|
18
18
|
QuoteBBO = "quote_bbo",
|
|
19
|
+
/** 加密货币实时行情 (v0.4.0) */
|
|
20
|
+
Cc = "cc",
|
|
21
|
+
/** 市场状态 (v0.4.0) */
|
|
22
|
+
Market = "market",
|
|
19
23
|
Asset = "asset",
|
|
20
24
|
Position = "position",
|
|
21
25
|
Order = "order",
|