@tigeropenapi/tigeropen 0.4.0 → 0.4.6

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.
Files changed (55) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/client/api-response.js +21 -2
  3. package/dist/cjs/client/case-convert.js +4 -3
  4. package/dist/cjs/client/http-client.js +122 -5
  5. package/dist/cjs/config/client-config.js +56 -12
  6. package/dist/cjs/config/index.js +3 -1
  7. package/dist/cjs/config/token-manager.js +54 -4
  8. package/dist/cjs/index.js +51 -2
  9. package/dist/cjs/model/enums.js +14 -1
  10. package/dist/cjs/model/order-helpers.js +44 -0
  11. package/dist/cjs/push/push-client.js +40 -15
  12. package/dist/cjs/quote/quote-client.js +14 -2
  13. package/dist/cjs/trade/trade-client.js +57 -8
  14. package/dist/esm/client/api-request.js +1 -1
  15. package/dist/esm/client/api-response.js +22 -3
  16. package/dist/esm/client/case-convert.js +4 -3
  17. package/dist/esm/client/http-client.js +127 -10
  18. package/dist/esm/client/index.js +6 -6
  19. package/dist/esm/config/client-config.js +59 -15
  20. package/dist/esm/config/index.js +4 -3
  21. package/dist/esm/config/token-manager.js +55 -5
  22. package/dist/esm/index.js +15 -1
  23. package/dist/esm/logger/index.js +1 -1
  24. package/dist/esm/model/contract-helpers.js +1 -1
  25. package/dist/esm/model/enums.js +13 -0
  26. package/dist/esm/model/order-helpers.js +43 -1
  27. package/dist/esm/model/order-status.js +1 -1
  28. package/dist/esm/push/index.js +5 -5
  29. package/dist/esm/push/pb/PushData.js +11 -11
  30. package/dist/esm/push/pb/QuoteBasicData.js +1 -1
  31. package/dist/esm/push/pb/Response.js +1 -1
  32. package/dist/esm/push/pb/index.js +17 -17
  33. package/dist/esm/push/proto-message.js +3 -3
  34. package/dist/esm/push/push-client.js +47 -22
  35. package/dist/esm/quote/index.js +1 -1
  36. package/dist/esm/quote/quote-client.js +16 -4
  37. package/dist/esm/signer/index.js +2 -2
  38. package/dist/esm/trade/index.js +1 -1
  39. package/dist/esm/trade/trade-client.js +60 -11
  40. package/dist/types/client/api-response.d.ts +1 -0
  41. package/dist/types/client/case-convert.d.ts +3 -1
  42. package/dist/types/client/http-client.d.ts +32 -1
  43. package/dist/types/config/client-config.d.ts +16 -1
  44. package/dist/types/config/index.d.ts +2 -0
  45. package/dist/types/config/token-manager.d.ts +27 -3
  46. package/dist/types/index.d.ts +22 -1
  47. package/dist/types/model/enums.d.ts +13 -1
  48. package/dist/types/model/order-helpers.d.ts +11 -0
  49. package/dist/types/model/order.d.ts +17 -2
  50. package/dist/types/model/trade-requests.d.ts +65 -0
  51. package/dist/types/model/trade.d.ts +108 -15
  52. package/dist/types/push/push-client.d.ts +5 -3
  53. package/dist/types/quote/quote-client.d.ts +3 -1
  54. package/dist/types/trade/trade-client.d.ts +19 -7
  55. package/package.json +3 -2
@@ -1,5 +1,5 @@
1
- import { createApiRequest } from '../client/api-request';
2
- import { unmarshalData } from '../client/api-response';
1
+ import { createApiRequest } from '../client/api-request.js';
2
+ import { unmarshalData } from '../client/api-response.js';
3
3
  /**
4
4
  * Parse an OCC-style option identifier like "AAPL 260619C00150000"
5
5
  * into its component parts.
@@ -357,9 +357,21 @@ export class QuoteClient {
357
357
  }
358
358
  return acc;
359
359
  }
360
- /** Futures tick trades. wire: future_tick (API v3.0) */
360
+ /** Futures tick trades. wire: future_tick (API v3.0)
361
+ * Server returns {contractCode, items:[...]}; unwrap items and backfill contractCode.
362
+ * endIndex defaults to 30 when not set (consistent with Python/Go SDK). */
361
363
  async getFutureTradeTicks(req) {
362
- return this.callInto('future_tick', req, '3.0');
364
+ if (!req.endIndex)
365
+ req.endIndex = 30;
366
+ const wrap = await this.callInto('future_tick', req, '3.0');
367
+ const items = wrap?.items ?? [];
368
+ if (wrap?.contractCode) {
369
+ for (const item of items) {
370
+ if (!item.contractCode)
371
+ item.contractCode = wrap.contractCode;
372
+ }
373
+ }
374
+ return items;
363
375
  }
364
376
  /** Futures depth. wire: future_depth */
365
377
  async getFutureDepth(req) {
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * 认证层(RSA Signer)统一导出
3
3
  */
4
- export { loadPrivateKey, signWithRSA, verifyWithRSA } from './signer';
5
- export { getSignContent } from './sign-content';
4
+ export { loadPrivateKey, signWithRSA, verifyWithRSA } from './signer.js';
5
+ export { getSignContent } from './sign-content.js';
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * 交易模块导出
3
3
  */
4
- export { TradeClient } from './trade-client';
4
+ export { TradeClient } from './trade-client.js';
@@ -1,6 +1,6 @@
1
- import { createApiRequest } from '../client/api-request';
2
- import { unmarshalData } from '../client/api-response';
3
- import { normalizeOrderStatus } from '../model/order-status';
1
+ import { createApiRequest } from '../client/api-request.js';
2
+ import { unmarshalData } from '../client/api-response.js';
3
+ import { normalizeOrderStatus } from '../model/order-status.js';
4
4
  /** Normalize `Order.status` field in-place (handles int → string). */
5
5
  function normalizeOrderInPlace(o) {
6
6
  if (o && o.status !== undefined && o.status !== null) {
@@ -22,9 +22,10 @@ function withAccount(req, account) {
22
22
  }
23
23
  /** Trading client wrapping all trade-related APIs. */
24
24
  export class TradeClient {
25
- constructor(httpClient, account) {
25
+ constructor(httpClient, account, secretKey) {
26
26
  this.httpClient = httpClient;
27
27
  this.account = account;
28
+ this.secretKey = secretKey;
28
29
  }
29
30
  async callInto(method, bizParams) {
30
31
  const request = createApiRequest(method, bizParams);
@@ -60,16 +61,26 @@ export class TradeClient {
60
61
  }
61
62
  // === Order operations ===
62
63
  async placeOrder(order) {
63
- return this.callInto('place_order', { ...order, account: this.account });
64
+ const params = { ...order, account: this.account };
65
+ if (!params.secretKey && this.secretKey)
66
+ params.secretKey = this.secretKey;
67
+ return this.callInto('place_order', params);
64
68
  }
65
69
  async previewOrder(order) {
66
70
  return this.callInto('preview_order', { ...order, account: this.account });
67
71
  }
68
72
  async modifyOrder(id, order) {
69
- return this.callInto('modify_order', { ...order, account: this.account, id });
70
- }
71
- async cancelOrder(id) {
72
- return this.callInto('cancel_order', { account: this.account, id });
73
+ const params = { ...order, account: this.account, id };
74
+ if (!params.secretKey && this.secretKey)
75
+ params.secretKey = this.secretKey;
76
+ return this.callInto('modify_order', params);
77
+ }
78
+ async cancelOrder(id, secretKey) {
79
+ const sk = secretKey ?? this.secretKey;
80
+ const params = { account: this.account, id };
81
+ if (sk)
82
+ params.secretKey = sk;
83
+ return this.callInto('cancel_order', params);
73
84
  }
74
85
  // === Order queries (BREAKING v0.4.0) ===
75
86
  /**
@@ -191,9 +202,10 @@ export class TradeClient {
191
202
  async getFundDetails(req) {
192
203
  return this.callIntoItems('fund_details', withAccount(req, this.account));
193
204
  }
194
- /** Funding history (wire method: `transfer_fund`). */
205
+ /** Funding history (wire method: `transfer_fund`).
206
+ * Server returns bare list (no items wrapper). */
195
207
  async getFundingHistory(req) {
196
- return this.callIntoItems('transfer_fund', withAccount(req, this.account));
208
+ return this.callInto('transfer_fund', withAccount(req, this.account));
197
209
  }
198
210
  // ===== v0.4.0 NEW: Internal / external position transfer =====
199
211
  /**
@@ -227,4 +239,41 @@ export class TradeClient {
227
239
  merged.accountId = this.account;
228
240
  return this.callIntoItems('position_transfer_external_records', merged);
229
241
  }
242
+ /** 行权检验:预估行权/作废后正股持仓变化 (wire: option_exercise_check) */
243
+ async checkOptionExercise(req) {
244
+ const merged = { ...req };
245
+ if (!merged.account)
246
+ merged.account = this.account;
247
+ return this.callInto('option_exercise_check', merged);
248
+ }
249
+ /** 查询可行权持仓列表 (wire: option_exercise_position) */
250
+ async getOptionExercisePositions(req) {
251
+ const merged = { ...req };
252
+ if (!merged.account)
253
+ merged.account = this.account;
254
+ return this.callInto('option_exercise_position', merged);
255
+ }
256
+ /** 提交行权/作废申请 (wire: option_exercise_submit) */
257
+ async submitOptionExercise(req) {
258
+ const merged = { ...req };
259
+ if (!merged.account)
260
+ merged.account = this.account;
261
+ const result = await this.callInto('option_exercise_submit', merged);
262
+ return result ?? false;
263
+ }
264
+ /** 分页查询行权记录 (wire: option_exercise_record) */
265
+ async getOptionExerciseRecords(req) {
266
+ const merged = { ...req };
267
+ if (!merged.account)
268
+ merged.account = this.account;
269
+ return this.callInto('option_exercise_record', merged);
270
+ }
271
+ /** 撤销行权申请 (wire: option_exercise_cancel) */
272
+ async cancelOptionExercise(req) {
273
+ const merged = { ...req };
274
+ if (!merged.account)
275
+ merged.account = this.account;
276
+ const result = await this.callInto('option_exercise_cancel', merged);
277
+ return result ?? false;
278
+ }
230
279
  }
@@ -14,6 +14,7 @@ export interface ApiResponse {
14
14
  /**
15
15
  * Parse the raw HTTP response body.
16
16
  * Throws TigerError when code != 0.
17
+ * Large integers in the outer envelope are not an issue (only inner `data` contains int64 IDs).
17
18
  */
18
19
  export declare function parseApiResponse(body: string): ApiResponse;
19
20
  /**
@@ -11,6 +11,8 @@ export declare function camelToSnake(key: string): string;
11
11
  /**
12
12
  * Recursively convert all object keys from camelCase to snake_case.
13
13
  * Preserves arrays, primitives, and Date/null/undefined.
14
- * Keys already containing an underscore are kept as-is (already snake_case).
14
+ *
15
+ * Note: camelToSnake is idempotent for pure snake_case keys (no uppercase
16
+ * letters → no replacements), so no pre-check is needed.
15
17
  */
16
18
  export declare function keysToSnakeCase(value: unknown): unknown;
@@ -5,6 +5,7 @@
5
5
  * Uses Node.js built-in fetch (Node 18+).
6
6
  */
7
7
  import type { ClientConfig } from '../config/client-config';
8
+ import { TokenManager, type TokenManagerOptions } from '../config/token-manager';
8
9
  import { RetryPolicy } from './retry';
9
10
  import { type ApiResponse } from './api-response';
10
11
  import type { ApiRequest } from './api-request';
@@ -16,9 +17,16 @@ export declare class HttpClient {
16
17
  private retryPolicy;
17
18
  /** Override the target URL (used by quote client to hit quote server) */
18
19
  private targetUrl;
20
+ /** non-null when auto-refresh is active */
21
+ private tokenManager;
19
22
  constructor(config: ClientConfig, retryPolicy?: RetryPolicy, options?: {
20
23
  useQuoteServerUrl?: boolean;
21
24
  });
25
+ /**
26
+ * Stop the background token auto-refresh timer.
27
+ * Call this when the HttpClient is no longer needed to avoid timer leaks.
28
+ */
29
+ close(): void;
22
30
  /**
23
31
  * Build common request parameters
24
32
  */
@@ -41,9 +49,32 @@ export declare class HttpClient {
41
49
  *
42
50
  * @param apiMethod - API method name (e.g. "market_state", "place_order")
43
51
  * @param requestJson - Raw biz_content JSON string
52
+ * @param version - Optional API version override (default: "2.0")
44
53
  * @returns Raw response JSON string, unparsed
45
54
  */
46
- execute(apiMethod: string, requestJson: string): Promise<string>;
55
+ execute(apiMethod: string, requestJson: string, version?: string): Promise<string>;
56
+ /**
57
+ * 调用 user_token_refresh 接口获取新 token,返回新 token 字符串。
58
+ * 此方法仅查询,不修改 config 中的 token。
59
+ */
60
+ queryToken(): Promise<string>;
61
+ /**
62
+ * 刷新 token:调用接口获取新 token 后更新 config.token。
63
+ *
64
+ * @param tokenManager - 可选外部 TokenManager;若提供则调用 setToken() 写文件并触发回调。
65
+ * 若 NewHttpClient 已自动启动内部 TokenManager,其内存 token 也会同步更新。
66
+ */
67
+ refreshToken(tokenManager?: TokenManager | null): Promise<void>;
68
+ /**
69
+ * 启动后台 token 自动刷新。
70
+ *
71
+ * @param tokenManager - 可为 null:SDK 内部自动创建一个仅内存的 TokenManager,
72
+ * 适合直接通过 token 在代码里设置、不使用文件的场景。
73
+ * @param options - 仅在 tokenManager 为 null 时生效,用于配置内部 TokenManager
74
+ * (refreshDuration / refreshInterval / tokenWriter / tokenLoader)。
75
+ * @returns 使用或创建的 TokenManager 实例
76
+ */
77
+ startTokenAutoRefresh(tokenManager: TokenManager | null, options?: TokenManagerOptions): TokenManager;
47
78
  /** Delay for the specified milliseconds */
48
79
  private sleep;
49
80
  /**
@@ -9,6 +9,12 @@ export interface ClientConfig {
9
9
  timeout: number;
10
10
  token?: string;
11
11
  tokenRefreshDuration?: number;
12
+ /** 后台 token 检查间隔(毫秒),仅 tokenRefreshDuration > 0 时生效,默认 5 分钟 */
13
+ tokenCheckInterval?: number;
14
+ /** 自定义 token 加载函数,替代默认的文件加载 */
15
+ tokenLoader?: () => Promise<string> | string;
16
+ /** token 刷新写入后的可选回调 */
17
+ tokenWriter?: (token: string) => void;
12
18
  serverUrl: string;
13
19
  /** Quote server URL for quote-specific requests; falls back to serverUrl */
14
20
  quoteServerUrl: string;
@@ -27,13 +33,22 @@ export interface ClientConfigOptions {
27
33
  timeout?: number;
28
34
  token?: string;
29
35
  tokenRefreshDuration?: number;
36
+ /** 后台 token 检查间隔(毫秒),仅 tokenRefreshDuration > 0 时生效,默认 5 分钟 */
37
+ tokenCheckInterval?: number;
38
+ /** 自定义 token 加载函数,替代默认的文件加载 */
39
+ tokenLoader?: () => Promise<string> | string;
40
+ /** token 刷新写入后的可选回调 */
41
+ tokenWriter?: (token: string) => void;
30
42
  serverUrl?: string;
31
43
  /** Explicit quote server URL; resolved dynamically if not set */
32
44
  quoteServerUrl?: string;
33
45
  /** Enable dynamic domain resolution (default: true) */
34
46
  enableDynamicDomain?: boolean;
35
- /** Explicit properties file path (synchronous read) */
47
+ /** Explicit properties file path or directory (synchronous read).
48
+ * If a directory is given, appends 'tiger_openapi_config.properties' automatically. */
36
49
  propertiesFilePath?: string;
50
+ /** Override Tiger public key (e.g. for sandbox/QA environments) */
51
+ tigerPublicKey?: string;
37
52
  }
38
53
  /**
39
54
  * Load and parse a Java-style properties file.
@@ -4,4 +4,6 @@
4
4
  export { parsePropertiesFile, parsePropertiesString } from './config-parser';
5
5
  export { createClientConfig, loadPropertiesFile } from './client-config';
6
6
  export type { ClientConfig, ClientConfigOptions } from './client-config';
7
+ export { TokenManager } from './token-manager';
8
+ export type { TokenManagerOptions, RefreshFn } from './token-manager';
7
9
  export { queryDomains, resolveDynamicServerUrl, resolveDynamicQuoteServerUrl } from './domain';
@@ -4,6 +4,10 @@ export interface TokenManagerOptions {
4
4
  refreshInterval?: number;
5
5
  /** Token 刷新阈值(秒),0 表示不刷新,最小 30 秒 */
6
6
  refreshDuration?: number;
7
+ /** 自定义 token 加载函数,优先于文件加载 */
8
+ tokenLoader?: () => Promise<string> | string;
9
+ /** token 写入后的回调(SetToken 成功后触发,SyncToken 不触发) */
10
+ tokenWriter?: (token: string) => void;
7
11
  }
8
12
  /** Token 刷新函数类型 */
9
13
  export type RefreshFn = () => Promise<string>;
@@ -13,16 +17,36 @@ export type RefreshFn = () => Promise<string>;
13
17
  export declare class TokenManager {
14
18
  private token;
15
19
  private filePath;
20
+ /** 仅当显式传入 filePath 时才写文件(fileEnabled = true) */
21
+ private fileEnabled;
16
22
  private refreshInterval;
17
23
  private refreshDuration;
18
24
  private timer;
25
+ private tokenLoader;
26
+ private tokenWriter;
19
27
  constructor(options?: TokenManagerOptions);
20
- /** 从 properties 文件加载 Token */
21
- loadToken(): string;
28
+ /**
29
+ * 从 properties 文件(或自定义 tokenLoader)加载 Token。
30
+ * 若设置了 tokenLoader,优先调用;否则从 properties 文件读取。
31
+ */
32
+ loadToken(): Promise<string>;
33
+ /**
34
+ * 同步版文件加载(仅用于无 tokenLoader 时的兼容入口)。
35
+ * 建议优先使用 loadToken()(异步)。
36
+ */
37
+ loadTokenSync(): string;
22
38
  /** 获取当前 Token */
23
39
  getToken(): string;
24
- /** 设置 Token 并更新文件 */
40
+ /**
41
+ * 设置 Token;若启用了文件持久化(显式传入 filePath),则同步写文件。
42
+ * 成功后触发 tokenWriter 回调(如有)。
43
+ */
25
44
  setToken(token: string): void;
45
+ /**
46
+ * 仅更新内存中的 token,不写文件,不触发 tokenWriter 回调。
47
+ * 用于多个组件共享 token 时的内部同步。
48
+ */
49
+ syncToken(token: string): void;
26
50
  /** 将 Token 保存到 properties 文件 */
27
51
  private saveTokenToFile;
28
52
  /**
@@ -15,4 +15,25 @@
15
15
  * @packageDocumentation
16
16
  */
17
17
  /** SDK 版本号 */
18
- export declare const VERSION = "0.4.0";
18
+ export declare const VERSION = "0.4.6";
19
+ export { createClientConfig, loadPropertiesFile } from './config';
20
+ export type { ClientConfig, ClientConfigOptions } from './config';
21
+ export { TokenManager } from './config';
22
+ export type { TokenManagerOptions, RefreshFn } from './config';
23
+ export { HttpClient } from './client';
24
+ export { TigerError, classifyErrorCode } from './client';
25
+ export type { ErrorCategory } from './client';
26
+ export { QuoteClient, parseOptionIdentifier } from './quote';
27
+ export { TradeClient } from './trade';
28
+ export { PushClient, ConnectionState, SubjectType } from './push';
29
+ export type { PushClientOptions } from './push';
30
+ export type { Order, OrderRequest } from './model/order';
31
+ export { marketOrder, limitOrder, stopOrder, stopLimitOrder } from './model/order-helpers';
32
+ export { normalizeOrderStatus } from './model/order-status';
33
+ export type { Contract } from './model/contract';
34
+ export type { Position } from './model/position';
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
+ 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
+ export type { MarketState, Brief, Kline, KlineItem, Timeline, TimelineItem, TradeTick, TradeTickItem, Depth, DepthLevel, OptionExpiration, OptionChain, OptionChainRow, OptionSymbol, FutureExchange, FutureContractInfo, FutureQuote, FutureKline, FutureKlineItem, FutureDepth, FutureTradeTickItem, FutureTradingTime, FinancialDailyItem, FinancialReportItem, CorporateAction, 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, BarsRequest, BarsByPageRequest, FutureBriefRequest, FutureBarsRequest, FutureBarsByPageRequest, FutureTradeTicksRequest, FutureDepthRequest, FutureContractSingleRequest, FutureContinuousContractsRequest, FutureHistoryMainContractRequest, FutureTradingTimesRequest, AllFutureContractsRequest, OptionBarsRequest, 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
+ export { OrderStatus, SecurityType, OrderType, TimeInForce, Market, Currency, QuoteRight, SegmentType, OrderSortBy, CorporateActionType, IndustryLevel, SortDirection, OptionAnalysisPeriod, FinancialReportPeriod, Language, License, BarPeriod, orderStatusCode, } from './model/enums';
@@ -42,7 +42,19 @@ export declare enum OrderType {
42
42
  AL = "AL",
43
43
  TWAP = "TWAP",
44
44
  VWAP = "VWAP",
45
- OCA = "OCA"
45
+ OCA = "OCA",
46
+ ICEBERG = "ICEBERG"
47
+ }
48
+ /** 冰山单价格类型 */
49
+ export declare enum PriceType {
50
+ /** 限价 */
51
+ LIMIT_PRICE = "LIMIT_PRICE",
52
+ /** 卖一价 */
53
+ ASK_PRICE = "ASK_PRICE",
54
+ /** 买一价 */
55
+ BID_PRICE = "BID_PRICE",
56
+ /** 最新价 */
57
+ LATEST_PRICE = "LATEST_PRICE"
46
58
  }
47
59
  /**
48
60
  * 订单状态枚举。对齐 Java SDK OrderStatus 定义。
@@ -3,6 +3,7 @@
3
3
  * All helpers return an `OrderRequest` with sensible defaults.
4
4
  */
5
5
  import type { OrderRequest, OrderLegRequest, AlgoParamsRequest } from './order';
6
+ import { PriceType } from './enums';
6
7
  /** Market order */
7
8
  export declare function marketOrder(account: string, symbol: string, secType: string, action: string, quantity: number): OrderRequest;
8
9
  /** Limit order */
@@ -19,5 +20,15 @@ export declare function auctionLimitOrder(account: string, symbol: string, secTy
19
20
  export declare function auctionMarketOrder(account: string, symbol: string, secType: string, action: string, quantity: number): OrderRequest;
20
21
  /** Algo order (TWAP / VWAP) */
21
22
  export declare function algoOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number, algoType: string, params: AlgoParamsRequest): OrderRequest;
23
+ /**
24
+ * Iceberg order (basic) — only displaySize required.
25
+ */
26
+ export declare function icebergOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number, displaySize: number): OrderRequest;
27
+ /**
28
+ * Iceberg order (full params).
29
+ * Pass `priceType` as empty string to use server default (LIMIT_PRICE).
30
+ * Pass `startTime` / `endTime` as 0 to omit the time window.
31
+ */
32
+ export declare function icebergOrderFull(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number, displaySize: number, minDisplaySize?: number, checkIntervals?: number, priceType?: PriceType | string, startTime?: number, endTime?: number): OrderRequest;
22
33
  /** Attached profit / loss leg */
23
34
  export declare function orderLeg(legType: string, price: number, timeInForce: string): OrderLegRequest;
@@ -22,8 +22,9 @@ export interface AlgoParams {
22
22
  /** Order response model (returned by order query methods). */
23
23
  export interface Order {
24
24
  account?: string;
25
- id?: number;
26
- orderId?: number;
25
+ /** int64 order ID — may be a string when it exceeds Number.MAX_SAFE_INTEGER */
26
+ id?: number | string;
27
+ orderId?: number | string;
27
28
  externalId?: string;
28
29
  action?: string;
29
30
  orderType?: string;
@@ -82,6 +83,8 @@ export interface OrderRequest {
82
83
  account?: string;
83
84
  /** Global order ID (required for modify) */
84
85
  id?: number;
86
+ /** Institutional account trading key (client fills it in automatically if set) */
87
+ secretKey?: string;
85
88
  /** Account-level order ID */
86
89
  orderId?: number;
87
90
  /** BUY / SELL */
@@ -124,6 +127,18 @@ export interface OrderRequest {
124
127
  remark?: string;
125
128
  /** User mark */
126
129
  userMark?: string;
130
+ /** 冰山单:展示数量 */
131
+ displaySize?: number;
132
+ /** 冰山单:最小展示数量 */
133
+ minDisplaySize?: number;
134
+ /** 冰山单:价检间隔(秒) */
135
+ checkIntervals?: number;
136
+ /** 冰山单:价格类型(LIMIT_PRICE / ASK_PRICE / BID_PRICE / LATEST_PRICE) */
137
+ priceType?: string;
138
+ /** 冰山单:生效开始时间(epoch ms) */
139
+ startTime?: number;
140
+ /** 冰山单:生效结束时间(epoch ms) */
141
+ endTime?: number;
127
142
  }
128
143
  /** Attached leg for request side */
129
144
  export interface OrderLegRequest {
@@ -193,3 +193,68 @@ export interface PositionTransferExternalRecordsRequest {
193
193
  limit?: number;
194
194
  lang?: string;
195
195
  }
196
+ /** 行权检验请求 (wire: option_exercise_check) */
197
+ export interface OptionExerciseCheckRequest {
198
+ account?: string;
199
+ secretKey?: string;
200
+ /** 期权合约 ID */
201
+ contractId: number;
202
+ /** Exercise | Expire */
203
+ type: string;
204
+ quantity?: number;
205
+ /** yyyy-MM-dd,Exercise 类型建议填 */
206
+ executingDate?: string;
207
+ /** Exercise 类型建议填 */
208
+ isForce?: boolean;
209
+ /** 0–10,Expire 类型专用 */
210
+ itmRate?: number;
211
+ lang?: string;
212
+ }
213
+ /** 查询可行权持仓请求 (wire: option_exercise_position) */
214
+ export interface OptionExercisePositionRequest {
215
+ account?: string;
216
+ secretKey?: string;
217
+ /** Exercise | Expire */
218
+ type: string;
219
+ lang?: string;
220
+ }
221
+ /** 提交行权申请请求 (wire: option_exercise_submit) */
222
+ export interface OptionExerciseSubmitRequest {
223
+ account?: string;
224
+ secretKey?: string;
225
+ contractId: number;
226
+ /** Exercise | Expire */
227
+ type: string;
228
+ quantity: number;
229
+ /** Exercise 必填,yyyy-MM-dd */
230
+ executingDate?: string;
231
+ /** Exercise 必填 */
232
+ isForce?: boolean;
233
+ /** 0–10,Expire 专用 */
234
+ itmRate?: number;
235
+ lang?: string;
236
+ }
237
+ /** 分页查询行权记录请求 (wire: option_exercise_record) */
238
+ export interface OptionExerciseRecordsRequest {
239
+ account?: string;
240
+ secretKey?: string;
241
+ /** 从 1 开始,默认 1 */
242
+ page?: number;
243
+ /** 1–100,默认 20 */
244
+ size?: number;
245
+ /** New | Cancel | Success | Fail */
246
+ status?: string;
247
+ /** Exercise | Expire */
248
+ type?: string;
249
+ symbol?: string;
250
+ /** symbol | expire_date | strike | is_call */
251
+ orderBy?: string;
252
+ lang?: string;
253
+ }
254
+ /** 撤销行权申请请求 (wire: option_exercise_cancel) */
255
+ export interface OptionExerciseCancelRequest {
256
+ account?: string;
257
+ secretKey?: string;
258
+ id: number;
259
+ lang?: string;
260
+ }