@tigeropenapi/tigeropen 0.5.3 → 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.
@@ -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
- /** Quote permission detail. wire: get_quote_permission */
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
- beginDate?: string;
337
- endDate?: string;
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
- beginDate?: string;
344
- endDate?: string;
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
- /** Industry list row (industry_list). */
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
- date?: string;
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
- beginTime?: number;
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?: number;
169
- /** 毫秒时间戳 */
170
- endDate?: number;
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
- id?: string;
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: TradeTickData) => void;
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;
@@ -7,8 +7,9 @@
7
7
  */
8
8
  import { HttpClient } from '../client/http-client';
9
9
  import type { ClientConfig } from '../config/client-config';
10
+ import type { TokenManager } from '../config/token-manager';
10
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';
11
- 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';
12
13
  /**
13
14
  * Parse an OCC-style option identifier like "AAPL 260619C00150000"
14
15
  * into its component parts.
@@ -28,6 +29,18 @@ export declare class QuoteClient {
28
29
  constructor(httpClient: HttpClient);
29
30
  /** Create a QuoteClient directly from a ClientConfig — no need to construct HttpClient manually. */
30
31
  static fromConfig(config: ClientConfig): QuoteClient;
32
+ /** Call the `user_token_refresh` API and return the new token. Read-only. */
33
+ queryToken(): Promise<string>;
34
+ /** Refresh the token and update the in-memory config token. */
35
+ refreshToken(tokenManager?: TokenManager | null): Promise<void>;
36
+ /**
37
+ * Start background token auto-refresh. Returns a TokenManager to stop with `tm.stopAutoRefresh()`.
38
+ *
39
+ * @param refreshDurationSecs - Refresh threshold in seconds (minimum 30).
40
+ * @param checkIntervalMs - How often to check, in milliseconds (default 300 000 / 5 min).
41
+ * @param tokenWriter - Optional callback invoked after each successful refresh.
42
+ */
43
+ startTokenAutoRefresh(refreshDurationSecs: number, checkIntervalMs?: number, tokenWriter?: (token: string) => void): TokenManager;
31
44
  private callInto;
32
45
  /**
33
46
  * Some endpoints return either a list or a single object depending on the
@@ -44,6 +57,7 @@ export declare class QuoteClient {
44
57
  getBrief(req: BriefRequest): Promise<Brief[]>;
45
58
  getKline(req: KlineRequest): Promise<Kline[]>;
46
59
  getTimeline(symbols: string[]): Promise<Timeline[]>;
60
+ getTimeline(req: TimelineRequest): Promise<Timeline[]>;
47
61
  /** Tick-by-tick trades. wire: trade_tick */
48
62
  getTradeTick(req: TradeTickRequest): Promise<TradeTick[]>;
49
63
  /** Depth snapshot. wire: quote_depth */
@@ -116,11 +130,18 @@ export declare class QuoteClient {
116
130
  getStockFundamental(req: StockFundamentalRequest): Promise<Record<string, unknown>>;
117
131
  /** Stock industry classification (array). wire: stock_industry */
118
132
  getStockIndustry(req: StockIndustryRequest): Promise<StockIndustry[]>;
119
- /** Quote permission detail. wire: get_quote_permission */
133
+ /** Market data permission entries. wire: get_quote_permission */
120
134
  getQuotePermission(req: QuotePermissionRequest): Promise<QuotePermission[]>;
121
135
  /** K-line quota usage. wire: kline_quota */
122
136
  getKlineQuota(req: KlineQuotaRequest): Promise<KlineQuota[]>;
123
- /** 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
+ */
124
145
  getOptionTradeTicks(req: OptionTradeTicksRequest): Promise<TradeTick[]>;
125
146
  /** Option intraday timeline. wire: option_timeline */
126
147
  getOptionTimeline(req: OptionTimelineRequest): Promise<Timeline[]>;
@@ -141,7 +162,9 @@ export declare class QuoteClient {
141
162
  /** Historical main contracts. wire: future_main_contract */
142
163
  getFutureHistoryMainContract(req: FutureHistoryMainContractRequest): Promise<FutureMainContractHistory[]>;
143
164
  /** Futures K-line. wire: future_kline
144
- * 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. */
145
168
  getFutureKline(req: FutureKlineRequest): Promise<FutureKline[]>;
146
169
  /** Client-side paginated futures K-line fetch. */
147
170
  getFutureKlineByPage(req: FutureKlineByPageRequest): Promise<FutureKlineItem[]>;
@@ -167,8 +190,19 @@ export declare class QuoteClient {
167
190
  getWarrantBriefs(req: WarrantBriefsRequest): Promise<WarrantBrief[]>;
168
191
  /** Warrant filter (paged). wire: warrant_filter */
169
192
  getWarrantFilter(req: WarrantFilterRequest): Promise<WarrantFilterResult | undefined>;
170
- /** Industry list. wire: industry_list */
171
- getIndustryList(req: IndustryListRequest): Promise<IndustryItem[]>;
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[]>;
172
206
  /** Stocks inside an industry. wire: industry_stock_list */
173
207
  getIndustryStocks(req: IndustryStocksRequest): Promise<IndustryStock[]>;
174
208
  /** Corporate split (flattened). wire: corporate_action (action_type=split) */
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import { HttpClient } from '../client/http-client';
11
11
  import type { ClientConfig } from '../config/client-config';
12
+ import type { TokenManager } from '../config/token-manager';
12
13
  import type { OrderRequest, Order } from '../model/order';
13
14
  import type { Contract } from '../model/contract';
14
15
  import type { Position } from '../model/position';
@@ -22,6 +23,24 @@ export declare class TradeClient {
22
23
  constructor(httpClient: HttpClient, account: string, secretKey?: string);
23
24
  /** Create a TradeClient directly from a ClientConfig — no need to construct HttpClient manually. */
24
25
  static fromConfig(config: ClientConfig, account: string, secretKey?: string): TradeClient;
26
+ /** Call the `user_token_refresh` API and return the new token. Read-only. */
27
+ queryToken(): Promise<string>;
28
+ /**
29
+ * Refresh the token: call the API, update the in-memory config token, and
30
+ * optionally persist via the provided TokenManager (file + writer callback).
31
+ *
32
+ * @param tokenManager - optional TokenManager for file persistence and writer callback
33
+ */
34
+ refreshToken(tokenManager?: TokenManager | null): Promise<void>;
35
+ /**
36
+ * Start background token auto-refresh. Returns a TokenManager that can be
37
+ * used to stop the background task via `tm.stopAutoRefresh()`.
38
+ *
39
+ * @param refreshDurationSecs - Refresh threshold in seconds (minimum 30).
40
+ * @param checkIntervalMs - How often to check, in milliseconds (default 300 000 / 5 min).
41
+ * @param tokenWriter - Optional callback invoked after each successful refresh.
42
+ */
43
+ startTokenAutoRefresh(refreshDurationSecs: number, checkIntervalMs?: number, tokenWriter?: (token: string) => void): TokenManager;
25
44
  private callInto;
26
45
  /** Strip `{items: [...]}` envelope used by most trade read endpoints. */
27
46
  private callIntoItems;
@@ -32,6 +51,21 @@ export declare class TradeClient {
32
51
  * `symbol` is the underlying (e.g. "AAPL"); `expiry` is "YYYYMMDD".
33
52
  */
34
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;
35
69
  placeOrder(order: OrderRequest): Promise<PlaceOrderResult | undefined>;
36
70
  previewOrder(order: OrderRequest): Promise<PreviewResult | undefined>;
37
71
  modifyOrder(id: number | string, order: OrderRequest): Promise<OrderIdResult | undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tigeropenapi/tigeropen",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
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",
@@ -30,6 +30,8 @@
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",
34
36
  "clean": "rm -rf dist",
35
37
  "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"