@tigeropenapi/tigeropen 0.5.4 → 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 +53 -0
- package/dist/cjs/push/index.js +1 -0
- package/dist/cjs/push/push-client.js +5 -3
- 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 +43 -3
- package/dist/esm/push/index.js +1 -0
- package/dist/esm/push/push-client.js +5 -3
- 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 +43 -3
- package/dist/types/index.d.ts +1 -1
- 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 +71 -14
- package/dist/types/model/trade-requests.d.ts +12 -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 +1 -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 +15 -0
- package/package.json +3 -1
|
@@ -9,6 +9,7 @@ import { HttpClient } from '../client/http-client.js';
|
|
|
9
9
|
import { createApiRequest } from '../client/api-request.js';
|
|
10
10
|
import { unmarshalData } from '../client/api-response.js';
|
|
11
11
|
import * as tokenMethods from '../client/token-methods.js';
|
|
12
|
+
import { getTradeCondByCode, isUsStockSymbol } from '../push/tick-util.js';
|
|
12
13
|
/**
|
|
13
14
|
* resolveOptionTimezone returns the timezone string to use for expiry conversion.
|
|
14
15
|
* Explicit tz takes precedence; otherwise infer from symbol (.HK suffix → Asia/Hong_Kong, else America/New_York).
|
|
@@ -148,12 +149,22 @@ export class QuoteClient {
|
|
|
148
149
|
async getKline(req) {
|
|
149
150
|
return this.callInto('kline', req);
|
|
150
151
|
}
|
|
151
|
-
async getTimeline(
|
|
152
|
-
|
|
152
|
+
async getTimeline(symbolsOrRequest) {
|
|
153
|
+
const req = Array.isArray(symbolsOrRequest) ? { symbols: symbolsOrRequest } : symbolsOrRequest;
|
|
154
|
+
return this.callInto('timeline', req, req.secType === 'CC' ? '3.0' : undefined);
|
|
153
155
|
}
|
|
154
156
|
/** Tick-by-tick trades. wire: trade_tick */
|
|
155
157
|
async getTradeTick(req) {
|
|
156
|
-
|
|
158
|
+
const out = await this.callInto('trade_tick', req);
|
|
159
|
+
for (const tick of out) {
|
|
160
|
+
const isUs = isUsStockSymbol(tick.symbol);
|
|
161
|
+
for (const item of tick.items) {
|
|
162
|
+
if (item.cond && item.cond.length > 0) {
|
|
163
|
+
item.cond = getTradeCondByCode(isUs, item.cond[0]);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return out;
|
|
157
168
|
}
|
|
158
169
|
/** Depth snapshot. wire: quote_depth */
|
|
159
170
|
async getQuoteDepth(req) {
|
|
@@ -319,6 +330,7 @@ export class QuoteClient {
|
|
|
319
330
|
while (acc.length < totalSize) {
|
|
320
331
|
const sub = {
|
|
321
332
|
symbols: req.symbol ? [req.symbol] : undefined,
|
|
333
|
+
secType: req.secType,
|
|
322
334
|
period: req.period,
|
|
323
335
|
right: req.right,
|
|
324
336
|
beginTime,
|
|
@@ -369,7 +381,7 @@ export class QuoteClient {
|
|
|
369
381
|
async getStockIndustry(req) {
|
|
370
382
|
return this.callInto('stock_industry', req);
|
|
371
383
|
}
|
|
372
|
-
/**
|
|
384
|
+
/** Market data permission entries. wire: get_quote_permission */
|
|
373
385
|
async getQuotePermission(req) {
|
|
374
386
|
return this.callInto('get_quote_permission', req);
|
|
375
387
|
}
|
|
@@ -380,9 +392,16 @@ export class QuoteClient {
|
|
|
380
392
|
// ==========================================================================
|
|
381
393
|
// Batch 4: option / future extensions
|
|
382
394
|
// ==========================================================================
|
|
383
|
-
/** Option tick trades. wire: option_trade_tick
|
|
395
|
+
/** Option tick trades. wire: option_trade_tick
|
|
396
|
+
*
|
|
397
|
+
* Server expects `biz_content` as a top-level JSON array (matches Java's
|
|
398
|
+
* `BatchApiModel` and Python's `MultipleContractParams.to_openapi_dict`).
|
|
399
|
+
* We unwrap the request here so the array is emitted directly instead of
|
|
400
|
+
* `{"contracts": [...]}`. Sending it as an object triggers
|
|
401
|
+
* `biz param error(failed to parse parameters in 'biz_content')`.
|
|
402
|
+
*/
|
|
384
403
|
async getOptionTradeTicks(req) {
|
|
385
|
-
return this.callInto('option_trade_tick', req);
|
|
404
|
+
return this.callInto('option_trade_tick', req.contracts ?? []);
|
|
386
405
|
}
|
|
387
406
|
/** Option intraday timeline. wire: option_timeline */
|
|
388
407
|
async getOptionTimeline(req) {
|
|
@@ -421,10 +440,16 @@ export class QuoteClient {
|
|
|
421
440
|
return this.callInto('future_main_contract', req);
|
|
422
441
|
}
|
|
423
442
|
/** Futures K-line. wire: future_kline
|
|
424
|
-
* beginTime / endTime default to -1 when unset (server requires them present).
|
|
443
|
+
* beginTime / endTime default to -1 when unset (server requires them present).
|
|
444
|
+
* Server expects `contract_codes` (plural) — normalize singular `contractCode`
|
|
445
|
+
* to the plural form so callers can pass either shape. */
|
|
425
446
|
async getFutureKline(req) {
|
|
447
|
+
const contractCodes = req.contractCodes
|
|
448
|
+
?? (req.contractCode ? [req.contractCode] : undefined);
|
|
449
|
+
const { contractCode: _drop, ...rest } = req;
|
|
426
450
|
const body = {
|
|
427
|
-
...
|
|
451
|
+
...rest,
|
|
452
|
+
...(contractCodes ? { contractCodes } : {}),
|
|
428
453
|
beginTime: req.beginTime ?? -1,
|
|
429
454
|
endTime: req.endTime ?? -1,
|
|
430
455
|
};
|
|
@@ -442,8 +467,9 @@ export class QuoteClient {
|
|
|
442
467
|
endTime = -1;
|
|
443
468
|
const acc = [];
|
|
444
469
|
while (acc.length < totalSize) {
|
|
470
|
+
// Server rejects singular `contract_code` — send the plural form.
|
|
445
471
|
const sub = {
|
|
446
|
-
|
|
472
|
+
contractCodes: req.contractCode ? [req.contractCode] : undefined,
|
|
447
473
|
period: req.period,
|
|
448
474
|
beginTime,
|
|
449
475
|
endTime,
|
|
@@ -522,9 +548,30 @@ export class QuoteClient {
|
|
|
522
548
|
async getWarrantFilter(req) {
|
|
523
549
|
return this.callInto('warrant_filter', req);
|
|
524
550
|
}
|
|
525
|
-
/** Industry list. wire: industry_list
|
|
526
|
-
|
|
527
|
-
|
|
551
|
+
/** Industry list. wire: industry_list
|
|
552
|
+
*
|
|
553
|
+
* `industryLevel` is required by the server — omitting it returns
|
|
554
|
+
* `industry level error, all supported is: [GSECTOR, GGROUP, GIND, GSUBIND]`.
|
|
555
|
+
* Defaults to `GGROUP` when unset, matching Python SDK's
|
|
556
|
+
* `IndustryLevel.GGROUP` default.
|
|
557
|
+
*
|
|
558
|
+
* Wire fields differ from other endpoints (see `IndustryItem`): server sends
|
|
559
|
+
* `nameCN` / `nameEN` / `industryLevel`. This method hydrates the
|
|
560
|
+
* backwards-compat `name` (from `nameEN || nameCN`) and mirrors
|
|
561
|
+
* `industryLevel` to `level` so existing callers keep working.
|
|
562
|
+
*/
|
|
563
|
+
async getIndustryList(req = {}) {
|
|
564
|
+
const payload = { industryLevel: 'GGROUP', ...req };
|
|
565
|
+
const items = await this.callInto('industry_list', payload);
|
|
566
|
+
if (!Array.isArray(items))
|
|
567
|
+
return [];
|
|
568
|
+
for (const it of items) {
|
|
569
|
+
if (it.name === undefined)
|
|
570
|
+
it.name = it.nameEN || it.nameCN;
|
|
571
|
+
if (it.level === undefined)
|
|
572
|
+
it.level = it.industryLevel;
|
|
573
|
+
}
|
|
574
|
+
return items;
|
|
528
575
|
}
|
|
529
576
|
/** Stocks inside an industry. wire: industry_stock_list */
|
|
530
577
|
async getIndustryStocks(req) {
|
|
@@ -109,14 +109,54 @@ export class TradeClient {
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
// === Order operations ===
|
|
112
|
+
/**
|
|
113
|
+
* Prepare an order request for the wire.
|
|
114
|
+
*
|
|
115
|
+
* The gateway expects `algo_params` as a `[{tag, value}, ...]` array
|
|
116
|
+
* (matching the Python SDK's AlgoParams.to_dict serialization), not the
|
|
117
|
+
* plain object shape that reads naturally in TypeScript. This helper
|
|
118
|
+
* normalizes the object form into the array form on outbound payloads
|
|
119
|
+
* so callers can pass the natural object and TWAP/VWAP orders work end
|
|
120
|
+
* to end without wire-format workarounds.
|
|
121
|
+
*
|
|
122
|
+
* Fields with undefined/null values are dropped; empty algoParams
|
|
123
|
+
* becomes an empty array rather than being stripped, matching the
|
|
124
|
+
* Python SDK behavior when the user passes an empty AlgoParams().
|
|
125
|
+
*/
|
|
126
|
+
marshalOrderForWire(order) {
|
|
127
|
+
const { algoParams, ...rest } = order;
|
|
128
|
+
const withAccount = { ...rest, account: this.account };
|
|
129
|
+
if (algoParams === undefined)
|
|
130
|
+
return withAccount;
|
|
131
|
+
// Already a tag/value array (advanced callers who want raw control)
|
|
132
|
+
if (Array.isArray(algoParams)) {
|
|
133
|
+
withAccount.algoParams = algoParams;
|
|
134
|
+
return withAccount;
|
|
135
|
+
}
|
|
136
|
+
// Object shape → tag/value array.
|
|
137
|
+
// Keys are converted to snake_case explicitly here (e.g. `startTime` →
|
|
138
|
+
// `start_time`) so they land correctly in the `tag` string that the
|
|
139
|
+
// gateway reads. `keysToSnakeCase` only rewrites object *keys*, not
|
|
140
|
+
// string *values*, so `tag` would be left camelCase if we didn't do
|
|
141
|
+
// this conversion ourselves.
|
|
142
|
+
const tagValues = [];
|
|
143
|
+
for (const [key, value] of Object.entries(algoParams)) {
|
|
144
|
+
if (value === undefined || value === null)
|
|
145
|
+
continue;
|
|
146
|
+
const snakeKey = key.replace(/[A-Z]/g, (c) => '_' + c.toLowerCase());
|
|
147
|
+
tagValues.push({ tag: snakeKey, value });
|
|
148
|
+
}
|
|
149
|
+
withAccount.algoParams = tagValues;
|
|
150
|
+
return withAccount;
|
|
151
|
+
}
|
|
112
152
|
async placeOrder(order) {
|
|
113
|
-
return this.callInto('place_order',
|
|
153
|
+
return this.callInto('place_order', this.marshalOrderForWire(order));
|
|
114
154
|
}
|
|
115
155
|
async previewOrder(order) {
|
|
116
|
-
return this.callInto('preview_order',
|
|
156
|
+
return this.callInto('preview_order', this.marshalOrderForWire(order));
|
|
117
157
|
}
|
|
118
158
|
async modifyOrder(id, order) {
|
|
119
|
-
return this.callInto('modify_order', { ...
|
|
159
|
+
return this.callInto('modify_order', { ...this.marshalOrderForWire(order), id });
|
|
120
160
|
}
|
|
121
161
|
async cancelOrder(id, secretKey) {
|
|
122
162
|
const params = { account: this.account, id };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -35,5 +35,5 @@ export type { Position } from './model/position';
|
|
|
35
35
|
export type { Asset, AssetSegment, PrimeAsset, PreviewResult, PlaceOrderResult, OrderIdResult, Transaction, ManagedAccount, AnalyticsAsset, AggregateAssets, EstimateTradableQuantity, ForexOrderResult, SegmentFund, SegmentFundAvailableItem, SegmentFundHistoryItem, FundDetails, FundingHistoryItem, PositionTransferRecord, PositionTransferDetail, PositionTransferExternalRecord, OptionExerciseCheckResult, OptionExercisePositionPageResult, OptionExerciseRecordPageResult, } from './model/trade';
|
|
36
36
|
export type { OrdersRequest, GetOrderRequest, OrderTransactionsRequest, PositionsRequest, AssetsRequest, ManagedAccountsRequest, DerivativeContractsRequest, AnalyticsAssetRequest, AggregateAssetsRequest, EstimateTradableQuantityRequest, ForexOrderRequest, SegmentFundRequest, FundDetailsRequest, FundingHistoryRequest, PositionTransferRequest, PositionTransferRecordsRequest, PositionTransferDetailRequest, PositionTransferExternalRecordsRequest, OptionExerciseCheckRequest, OptionExercisePositionRequest, OptionExerciseSubmitRequest, OptionExerciseRecordsRequest, OptionExerciseCancelRequest, } from './model/trade-requests';
|
|
37
37
|
export type { MarketState, Brief, Kline, KlineItem, Timeline, TimelineItem, TradeTick, TradeTickItem, Depth, DepthLevel, OptionExpiration, OptionChain, OptionChainRow, OptionSymbol, OptionChainFilter, OptionChainFilterGreeks, Range, FutureExchange, FutureContractInfo, FutureQuote, FutureKline, FutureKlineItem, FutureDepth, FutureTradeTickItem, FutureTradingTime, FinancialDailyItem, FinancialReportItem, CorporateAction, CorporateSymbolChange, CorporateDelisting, CorporateIPO, CapitalFlow, CapitalFlowItem, CapitalDistribution, ScannerResult, ScannerResultItem, QuotePermission, SymbolName, TradeMeta, StockDetail, StockBroker, StockBrokerItem, ShortInterest, StockIndustry, IndustryItem, IndustryStock, WarrantBrief, WarrantFilterResult, FundContractInfo, FundQuote, FundHistoryQuote, QuoteOvernight, KlineQuota, MarketScannerTag, MarketScannerTags, OptionAnalysis, OptionLeg, OptionVolatilityPoint, ExchangeRate, FinancialCurrency, BrokerDetail, TradingCalendarItem, FutureMainContractHistory, } from './model/quote';
|
|
38
|
-
export type { BriefRequest, DepthQuoteRequest, TradeTickRequest, KlineRequest, KlineByPageRequest, FutureBriefRequest, FutureKlineRequest, FutureKlineByPageRequest, FutureTradeTicksRequest, FutureDepthRequest, FutureContractSingleRequest, FutureContinuousContractsRequest, FutureHistoryMainContractRequest, FutureTradingTimesRequest, AllFutureContractsRequest, OptionTradeTicksRequest, OptionTimelineRequest, OptionDepthRequest, OptionSymbolsRequest, OptionAnalysisRequest, OptionQueryItem, ShortInterestRequest, StockBrokerRequest, StockDetailsRequest, StockFundamentalRequest, StockIndustryRequest, StockDelayBriefsRequest, SymbolsRequest, TradeMetasRequest, TradeRankRequest, TimelineHistoryRequest, TradingCalendarRequest, KlineQuotaRequest, QuotePermissionRequest, QuoteOvernightRequest, IndustryListRequest, IndustryStocksRequest, FundSymbolsRequest, FundContractsRequest, FundQuoteRequest, FundHistoryQuoteRequest, WarrantBriefsRequest, WarrantFilterRequest, MarketScannerTagsRequest, FinancialCurrencyRequest, FinancialExchangeRateRequest, } from './model/quote-requests';
|
|
38
|
+
export type { BriefRequest, DepthQuoteRequest, TradeTickRequest, KlineRequest, KlineByPageRequest, TimelineRequest, FutureBriefRequest, FutureKlineRequest, FutureKlineByPageRequest, FutureTradeTicksRequest, FutureDepthRequest, FutureContractSingleRequest, FutureContinuousContractsRequest, FutureHistoryMainContractRequest, FutureTradingTimesRequest, AllFutureContractsRequest, OptionTradeTicksRequest, OptionTimelineRequest, OptionDepthRequest, OptionSymbolsRequest, OptionAnalysisRequest, OptionQueryItem, ShortInterestRequest, StockBrokerRequest, StockDetailsRequest, StockFundamentalRequest, StockIndustryRequest, StockDelayBriefsRequest, SymbolsRequest, TradeMetasRequest, TradeRankRequest, TimelineHistoryRequest, TradingCalendarRequest, KlineQuotaRequest, QuotePermissionRequest, QuoteOvernightRequest, IndustryListRequest, IndustryStocksRequest, FundSymbolsRequest, FundContractsRequest, FundQuoteRequest, FundHistoryQuoteRequest, WarrantBriefsRequest, WarrantFilterRequest, MarketScannerTagsRequest, FinancialCurrencyRequest, FinancialExchangeRateRequest, } from './model/quote-requests';
|
|
39
39
|
export { OrderStatus, SecurityType, OrderType, TimeInForce, Market, Currency, QuoteRight, SegmentType, OrderSortBy, CorporateActionType, IndustryLevel, SortDirection, OptionAnalysisPeriod, FinancialReportPeriod, Language, License, BarPeriod, orderStatusCode, } from './model/enums';
|
|
@@ -12,11 +12,28 @@ export interface OrderLeg {
|
|
|
12
12
|
timeInForce?: string;
|
|
13
13
|
quantity?: number;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Algo order parameters — response side.
|
|
17
|
+
*
|
|
18
|
+
* The response shape flattens the [{tag, value}, ...] wire form into an
|
|
19
|
+
* object, and the server historically emits `startTime` / `endTime` as
|
|
20
|
+
* epoch-ms numbers (matching what the request side sends). Some legacy
|
|
21
|
+
* paths still return the raw string; accept both.
|
|
22
|
+
*
|
|
23
|
+
* Note: `algoStrategy` on the response side is server-echoed; on the
|
|
24
|
+
* request side it lives on `OrderRequest`, not `AlgoParamsRequest`.
|
|
25
|
+
*/
|
|
16
26
|
export interface AlgoParams {
|
|
17
27
|
algoStrategy?: string;
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
/** Epoch-ms; server may echo as string on legacy paths */
|
|
29
|
+
startTime?: number | string;
|
|
30
|
+
/** Epoch-ms; server may echo as string on legacy paths */
|
|
31
|
+
endTime?: number | string;
|
|
32
|
+
/** Whether to minimize trade count (VWAP) */
|
|
33
|
+
noTakeLiq?: boolean;
|
|
34
|
+
/** Whether to allow completion after end_time (TWAP / VWAP) */
|
|
35
|
+
allowPastEndTime?: boolean;
|
|
36
|
+
/** Participation rate 0.01–0.5 (VWAP only) */
|
|
20
37
|
participationRate?: number;
|
|
21
38
|
}
|
|
22
39
|
/** Order response model (returned by order query methods). */
|
|
@@ -135,10 +152,18 @@ export interface OrderRequest {
|
|
|
135
152
|
checkIntervals?: number;
|
|
136
153
|
/** 冰山单:价格类型(LIMIT_PRICE / ASK_PRICE / BID_PRICE / LATEST_PRICE) */
|
|
137
154
|
priceType?: string;
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
155
|
+
/**
|
|
156
|
+
* 冰山单:生效开始时间(epoch ms)。
|
|
157
|
+
* Wire note: the gateway accepts both `number` (epoch ms) and `string`
|
|
158
|
+
* (epoch ms as string) for ICEBERG orders; `number | string` keeps
|
|
159
|
+
* TypeScript callers who pass `String(now)` from hitting a compile error.
|
|
160
|
+
*/
|
|
161
|
+
startTime?: number | string;
|
|
162
|
+
/**
|
|
163
|
+
* 冰山单:生效结束时间(epoch ms)。
|
|
164
|
+
* Same dual-type note as `startTime` above.
|
|
165
|
+
*/
|
|
166
|
+
endTime?: number | string;
|
|
142
167
|
/** GTD 到期时间(epoch ms) */
|
|
143
168
|
expireTime?: number;
|
|
144
169
|
/** 盘后委托价格 */
|
|
@@ -180,6 +205,17 @@ export interface OrderRequest {
|
|
|
180
205
|
contractLegs?: ContractLegRequest[];
|
|
181
206
|
/** 组合单类型(如 MLEG) */
|
|
182
207
|
comboType?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Algo strategy name for TWAP / VWAP orders (e.g. `'TWAP'`, `'VWAP'`).
|
|
210
|
+
* Lives on `OrderRequest`, not inside `algoParams` — the Python SDK
|
|
211
|
+
* places it at the top-level order object, and the gateway expects
|
|
212
|
+
* `algo_strategy` as a sibling of `algo_params`.
|
|
213
|
+
*
|
|
214
|
+
* Note: `AlgoParamsRequest` intentionally omits this field (see its
|
|
215
|
+
* doc-comment). Pass `algoStrategy` here and `algoParams` as the
|
|
216
|
+
* companion object.
|
|
217
|
+
*/
|
|
218
|
+
algoStrategy?: string;
|
|
183
219
|
}
|
|
184
220
|
/** Single leg of a multi-leg option order (MLEG) */
|
|
185
221
|
export interface ContractLegRequest {
|
|
@@ -198,10 +234,25 @@ export interface OrderLegRequest {
|
|
|
198
234
|
timeInForce?: string;
|
|
199
235
|
quantity?: number;
|
|
200
236
|
}
|
|
201
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Algo parameters for request side (TWAP / VWAP).
|
|
239
|
+
*
|
|
240
|
+
* Fields match the Python SDK's AlgoParams. On the wire, the SDK marshals
|
|
241
|
+
* this object into the `[{tag, value}, ...]` array shape the gateway
|
|
242
|
+
* expects — callers should just pass the natural object.
|
|
243
|
+
*
|
|
244
|
+
* `algoStrategy` is intentionally not here: it lives on the parent
|
|
245
|
+
* `OrderRequest`, not inside `algoParams`.
|
|
246
|
+
*/
|
|
202
247
|
export interface AlgoParamsRequest {
|
|
203
|
-
|
|
204
|
-
startTime?:
|
|
205
|
-
|
|
248
|
+
/** Epoch-ms start time (TWAP / VWAP only) */
|
|
249
|
+
startTime?: number;
|
|
250
|
+
/** Epoch-ms end time (TWAP / VWAP only) */
|
|
251
|
+
endTime?: number;
|
|
252
|
+
/** Try to minimize trade count (VWAP only) */
|
|
253
|
+
noTakeLiq?: boolean;
|
|
254
|
+
/** Allow completing after end_time (TWAP / VWAP only) */
|
|
255
|
+
allowPastEndTime?: boolean;
|
|
256
|
+
/** Participation rate 0.01–0.5 (VWAP only) */
|
|
206
257
|
participationRate?: number;
|
|
207
258
|
}
|
|
@@ -27,6 +27,7 @@ export interface TradeTickRequest {
|
|
|
27
27
|
beginIndex?: number;
|
|
28
28
|
endIndex?: number;
|
|
29
29
|
limit?: number;
|
|
30
|
+
tradeSession?: string;
|
|
30
31
|
lang?: string;
|
|
31
32
|
}
|
|
32
33
|
/** Real-time futures quotes. wire: future_brief */
|
|
@@ -80,6 +81,7 @@ export interface KlineRequest {
|
|
|
80
81
|
/** K-line client-side pagination wrapper. */
|
|
81
82
|
export interface KlineByPageRequest {
|
|
82
83
|
symbol?: string;
|
|
84
|
+
secType?: string;
|
|
83
85
|
period?: string;
|
|
84
86
|
beginTime?: number;
|
|
85
87
|
endTime?: number;
|
|
@@ -89,6 +91,11 @@ export interface KlineByPageRequest {
|
|
|
89
91
|
lang?: string;
|
|
90
92
|
tradeSession?: string;
|
|
91
93
|
}
|
|
94
|
+
/** Intraday timeline request. wire: timeline */
|
|
95
|
+
export interface TimelineRequest {
|
|
96
|
+
symbols?: string[];
|
|
97
|
+
secType?: string;
|
|
98
|
+
}
|
|
92
99
|
/** Historical intraday timeline. wire: history_timeline */
|
|
93
100
|
export interface TimelineHistoryRequest {
|
|
94
101
|
symbols?: string[];
|
|
@@ -134,7 +141,7 @@ export interface KlineQuotaRequest {
|
|
|
134
141
|
withDetails?: boolean;
|
|
135
142
|
lang?: string;
|
|
136
143
|
}
|
|
137
|
-
/**
|
|
144
|
+
/** Market data permission entry request. wire: get_quote_permission */
|
|
138
145
|
export interface QuotePermissionRequest {
|
|
139
146
|
beginDate?: string;
|
|
140
147
|
endDate?: string;
|
|
@@ -154,9 +161,21 @@ export interface OptionQueryItem {
|
|
|
154
161
|
endIndex?: number;
|
|
155
162
|
pageToken?: string;
|
|
156
163
|
}
|
|
157
|
-
/** Option tick trades. wire: option_trade_tick
|
|
164
|
+
/** Option tick trades. wire: option_trade_tick
|
|
165
|
+
*
|
|
166
|
+
* **Wire contract:** the server expects `biz_content` to be a **top-level
|
|
167
|
+
* JSON array** (`[{symbol, expiry, ...}, ...]`), not `{"contracts": [...]}`.
|
|
168
|
+
* This matches Java (`BatchApiModel.items` serialized directly) and Python
|
|
169
|
+
* (`MultipleContractParams.to_openapi_dict` returns a list).
|
|
170
|
+
*
|
|
171
|
+
* The client unwraps `contracts` before serialization; sending it as an
|
|
172
|
+
* object caused `biz param error(failed to parse parameters in 'biz_content')`.
|
|
173
|
+
* `lang` is retained for API symmetry but is not sent on the wire — the
|
|
174
|
+
* gateway has no `lang` input for this method.
|
|
175
|
+
*/
|
|
158
176
|
export interface OptionTradeTicksRequest {
|
|
159
177
|
contracts?: OptionQueryItem[];
|
|
178
|
+
/** Retained for API symmetry; wire is a top-level array, so `lang` is not sent. */
|
|
160
179
|
lang?: string;
|
|
161
180
|
}
|
|
162
181
|
/** Option intraday timeline. wire: option_timeline */
|
|
@@ -37,6 +37,7 @@ export interface Brief {
|
|
|
37
37
|
export interface KlineItem {
|
|
38
38
|
time: number;
|
|
39
39
|
volume: number;
|
|
40
|
+
volumeDecimal?: number | null;
|
|
40
41
|
open: number;
|
|
41
42
|
close: number;
|
|
42
43
|
high: number;
|
|
@@ -52,6 +53,7 @@ export interface Kline {
|
|
|
52
53
|
export interface TimelineItem {
|
|
53
54
|
time: number;
|
|
54
55
|
volume: number;
|
|
56
|
+
volumeDecimal?: number | null;
|
|
55
57
|
price: number;
|
|
56
58
|
avgPrice: number;
|
|
57
59
|
}
|
|
@@ -71,6 +73,9 @@ export interface TradeTickItem {
|
|
|
71
73
|
volume: number;
|
|
72
74
|
price: number;
|
|
73
75
|
type: string;
|
|
76
|
+
partCode?: string;
|
|
77
|
+
partName?: string;
|
|
78
|
+
cond?: string;
|
|
74
79
|
}
|
|
75
80
|
export interface TradeTick {
|
|
76
81
|
symbol: string;
|
|
@@ -116,6 +121,12 @@ export interface OptionLeg {
|
|
|
116
121
|
theta?: number;
|
|
117
122
|
vega?: number;
|
|
118
123
|
rho?: number;
|
|
124
|
+
markPrice?: number;
|
|
125
|
+
preMarkPrice?: number;
|
|
126
|
+
markTimestamp?: number;
|
|
127
|
+
midPrice?: number;
|
|
128
|
+
preMidPrice?: number;
|
|
129
|
+
midTimestamp?: number;
|
|
119
130
|
}
|
|
120
131
|
export interface OptionChainRow {
|
|
121
132
|
put?: OptionLeg;
|
|
@@ -328,20 +339,39 @@ export interface FinancialDailyRequest {
|
|
|
328
339
|
beginDate: string;
|
|
329
340
|
endDate: string;
|
|
330
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Financial report request.
|
|
344
|
+
*
|
|
345
|
+
* **Wire types (breaking):** `beginDate` / `endDate` are epoch-ms integers,
|
|
346
|
+
* not date strings. Python SDK converts via `date_str_to_timestamp` before
|
|
347
|
+
* sending; sending raw strings makes the gateway reject with
|
|
348
|
+
* `biz param error(failed to parse parameters in 'biz_content')`.
|
|
349
|
+
*/
|
|
331
350
|
export interface FinancialReportRequest {
|
|
332
351
|
symbols: string[];
|
|
333
352
|
market: string;
|
|
334
353
|
fields: string[];
|
|
335
354
|
periodType: string;
|
|
336
|
-
|
|
337
|
-
|
|
355
|
+
/** epoch-ms start time */
|
|
356
|
+
beginDate?: number;
|
|
357
|
+
/** epoch-ms end time */
|
|
358
|
+
endDate?: number;
|
|
338
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Corporate action request.
|
|
362
|
+
*
|
|
363
|
+
* **Wire types (breaking):** `beginDate` / `endDate` are epoch-ms integers,
|
|
364
|
+
* matching `FinancialReportRequest`. Server rejects string dates with
|
|
365
|
+
* `biz param error(failed to parse parameters in 'biz_content')`.
|
|
366
|
+
*/
|
|
339
367
|
export interface CorporateActionRequest {
|
|
340
368
|
symbols: string[];
|
|
341
369
|
market: string;
|
|
342
370
|
actionType: string;
|
|
343
|
-
|
|
344
|
-
|
|
371
|
+
/** epoch-ms start time */
|
|
372
|
+
beginDate?: number;
|
|
373
|
+
/** epoch-ms end time */
|
|
374
|
+
endDate?: number;
|
|
345
375
|
}
|
|
346
376
|
export interface FutureKlineRequest {
|
|
347
377
|
contractCodes: string[];
|
|
@@ -552,10 +582,32 @@ export interface WarrantFilterResult {
|
|
|
552
582
|
pageSize?: number;
|
|
553
583
|
page?: number;
|
|
554
584
|
}
|
|
555
|
-
/**
|
|
585
|
+
/**
|
|
586
|
+
* Industry list row (industry_list).
|
|
587
|
+
*
|
|
588
|
+
* **Wire fields (breaking):** the server returns `nameCN` / `nameEN` /
|
|
589
|
+
* `industryLevel`, not `name` / `level` (matches Python SDK's
|
|
590
|
+
* `IndustryListResponse` which reads `ind.get('nameCN')`,
|
|
591
|
+
* `ind.get('nameEN')`, `ind.get('industryLevel')`).
|
|
592
|
+
* Since responses come back already-camelCase (no snake→camel step) and the
|
|
593
|
+
* server keeps `nameCN` / `nameEN` in mixed case, the fields are exposed
|
|
594
|
+
* exactly as sent.
|
|
595
|
+
*
|
|
596
|
+
* `name` and `level` are backwards-compat aliases populated by
|
|
597
|
+
* `getIndustryList` after the raw response is decoded — `name` mirrors
|
|
598
|
+
* `nameEN || nameCN`, `level` mirrors `industryLevel`.
|
|
599
|
+
*/
|
|
556
600
|
export interface IndustryItem {
|
|
557
601
|
id?: string;
|
|
602
|
+
/** Chinese name. Wire: `nameCN`. */
|
|
603
|
+
nameCN?: string;
|
|
604
|
+
/** English name. Wire: `nameEN`. */
|
|
605
|
+
nameEN?: string;
|
|
606
|
+
/** Industry level. Wire: `industryLevel`. */
|
|
607
|
+
industryLevel?: string;
|
|
608
|
+
/** Convenience alias: `nameEN || nameCN`. Populated by `getIndustryList`. */
|
|
558
609
|
name?: string;
|
|
610
|
+
/** @deprecated Use `industryLevel`. Mirrored by `getIndustryList` for back-compat. */
|
|
559
611
|
level?: string;
|
|
560
612
|
}
|
|
561
613
|
/** Stock belonging to an industry (industry_stock_list). */
|
|
@@ -573,12 +625,15 @@ export interface TradingCalendarItem {
|
|
|
573
625
|
isTrading?: boolean;
|
|
574
626
|
sessionType?: string;
|
|
575
627
|
}
|
|
628
|
+
/** Single day's FX rate value within an ExchangeRate.dailyValueList entry. */
|
|
629
|
+
export interface ExchangeRateDailyValue {
|
|
630
|
+
date?: number;
|
|
631
|
+
value?: number;
|
|
632
|
+
}
|
|
576
633
|
/** FX rate (financial_exchange_rate). */
|
|
577
634
|
export interface ExchangeRate {
|
|
578
635
|
currency?: string;
|
|
579
|
-
|
|
580
|
-
rate?: number;
|
|
581
|
-
baseCurrency?: string;
|
|
636
|
+
dailyValueList?: ExchangeRateDailyValue[];
|
|
582
637
|
}
|
|
583
638
|
/** Financial currency per symbol (financial_currency). */
|
|
584
639
|
export interface FinancialCurrency {
|
|
@@ -589,17 +644,19 @@ export interface FinancialCurrency {
|
|
|
589
644
|
/** Overnight quote (quote_overnight). */
|
|
590
645
|
export interface QuoteOvernight {
|
|
591
646
|
symbol?: string;
|
|
647
|
+
latestPrice?: number;
|
|
648
|
+
askPrice?: number;
|
|
649
|
+
askSize?: number;
|
|
650
|
+
bidPrice?: number;
|
|
651
|
+
bidSize?: number;
|
|
592
652
|
preClose?: number;
|
|
593
|
-
open?: number;
|
|
594
|
-
close?: number;
|
|
595
|
-
high?: number;
|
|
596
|
-
low?: number;
|
|
597
653
|
volume?: number;
|
|
598
654
|
amount?: number;
|
|
655
|
+
timestamp?: number;
|
|
656
|
+
tradingStatus?: number;
|
|
599
657
|
change?: number;
|
|
600
658
|
changeRate?: number;
|
|
601
|
-
|
|
602
|
-
endTime?: number;
|
|
659
|
+
amplitude?: number;
|
|
603
660
|
}
|
|
604
661
|
/** Single market-scanner tag. */
|
|
605
662
|
export interface MarketScannerTag {
|
|
@@ -157,6 +157,14 @@ export interface SegmentFundRequest {
|
|
|
157
157
|
limit?: number;
|
|
158
158
|
lang?: string;
|
|
159
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
|
+
*/
|
|
160
168
|
export interface FundDetailsRequest {
|
|
161
169
|
account?: string;
|
|
162
170
|
/** Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. */
|
|
@@ -164,10 +172,10 @@ export interface FundDetailsRequest {
|
|
|
164
172
|
segTypes?: string[];
|
|
165
173
|
fundType?: string;
|
|
166
174
|
currency?: string;
|
|
167
|
-
/**
|
|
168
|
-
startDate?:
|
|
169
|
-
/**
|
|
170
|
-
endDate?:
|
|
175
|
+
/** yyyy-MM-dd 日期字符串 */
|
|
176
|
+
startDate?: string;
|
|
177
|
+
/** yyyy-MM-dd 日期字符串 */
|
|
178
|
+
endDate?: string;
|
|
171
179
|
limit?: number;
|
|
172
180
|
pageToken?: string;
|
|
173
181
|
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
10
|
export type { PushClientOptions, TLSSocketLike, TLSSocketFactory } from './push-client';
|
|
@@ -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;
|