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.
Files changed (84) hide show
  1. package/README.md +55 -2
  2. package/dist/cjs/client/api-response.js +28 -7
  3. package/dist/cjs/client/case-convert.js +4 -3
  4. package/dist/cjs/client/http-client.js +124 -8
  5. package/dist/cjs/client/token-methods.js +42 -0
  6. package/dist/cjs/config/client-config.js +115 -16
  7. package/dist/cjs/config/config-parser.js +19 -9
  8. package/dist/cjs/config/index.js +4 -1
  9. package/dist/cjs/config/token-manager.js +54 -4
  10. package/dist/cjs/index.js +53 -2
  11. package/dist/cjs/model/enums.js +106 -7
  12. package/dist/cjs/model/order-helpers.js +149 -0
  13. package/dist/cjs/model/order-status.js +46 -0
  14. package/dist/cjs/model/quote-requests.js +11 -0
  15. package/dist/cjs/model/trade-requests.js +13 -0
  16. package/dist/cjs/push/index.js +1 -0
  17. package/dist/cjs/push/pb/OrderStatusData.js +24 -0
  18. package/dist/cjs/push/proto-message.js +6 -0
  19. package/dist/cjs/push/push-client.js +117 -19
  20. package/dist/cjs/push/push-message.js +4 -0
  21. package/dist/cjs/push/tick-util.js +172 -0
  22. package/dist/cjs/quote/quote-client.js +584 -42
  23. package/dist/cjs/trade/trade-client.js +334 -32
  24. package/dist/cjs/version.js +4 -0
  25. package/dist/esm/client/api-request.js +1 -1
  26. package/dist/esm/client/api-response.js +29 -8
  27. package/dist/esm/client/case-convert.js +4 -3
  28. package/dist/esm/client/http-client.js +128 -12
  29. package/dist/esm/client/index.js +6 -6
  30. package/dist/esm/client/token-methods.js +37 -0
  31. package/dist/esm/config/client-config.js +118 -20
  32. package/dist/esm/config/config-parser.js +19 -9
  33. package/dist/esm/config/index.js +4 -3
  34. package/dist/esm/config/token-manager.js +55 -5
  35. package/dist/esm/index.js +15 -1
  36. package/dist/esm/logger/index.js +1 -1
  37. package/dist/esm/model/contract-helpers.js +1 -1
  38. package/dist/esm/model/enums.js +104 -6
  39. package/dist/esm/model/order-helpers.js +142 -1
  40. package/dist/esm/model/order-status.js +43 -0
  41. package/dist/esm/model/quote-requests.js +10 -0
  42. package/dist/esm/model/trade-requests.js +12 -0
  43. package/dist/esm/push/index.js +6 -5
  44. package/dist/esm/push/pb/OrderStatusData.js +24 -0
  45. package/dist/esm/push/pb/PushData.js +11 -11
  46. package/dist/esm/push/pb/QuoteBasicData.js +1 -1
  47. package/dist/esm/push/pb/Response.js +1 -1
  48. package/dist/esm/push/pb/index.js +17 -17
  49. package/dist/esm/push/proto-message.js +9 -3
  50. package/dist/esm/push/push-client.js +124 -26
  51. package/dist/esm/push/push-message.js +4 -0
  52. package/dist/esm/push/tick-util.js +165 -0
  53. package/dist/esm/quote/index.js +1 -1
  54. package/dist/esm/quote/quote-client.js +553 -44
  55. package/dist/esm/signer/index.js +2 -2
  56. package/dist/esm/trade/index.js +1 -1
  57. package/dist/esm/trade/trade-client.js +303 -34
  58. package/dist/esm/version.js +1 -0
  59. package/dist/types/client/api-response.d.ts +6 -4
  60. package/dist/types/client/case-convert.d.ts +3 -1
  61. package/dist/types/client/http-client.d.ts +32 -1
  62. package/dist/types/client/token-methods.d.ts +34 -0
  63. package/dist/types/config/client-config.d.ts +22 -1
  64. package/dist/types/config/index.d.ts +3 -1
  65. package/dist/types/config/token-manager.d.ts +27 -3
  66. package/dist/types/index.d.ts +22 -1
  67. package/dist/types/model/enums.d.ts +77 -7
  68. package/dist/types/model/order-helpers.d.ts +52 -1
  69. package/dist/types/model/order-status.d.ts +14 -0
  70. package/dist/types/model/order.d.ts +127 -10
  71. package/dist/types/model/quote-requests.d.ts +356 -0
  72. package/dist/types/model/quote.d.ts +391 -4
  73. package/dist/types/model/trade-requests.d.ts +309 -0
  74. package/dist/types/model/trade.d.ts +231 -5
  75. package/dist/types/push/callbacks.d.ts +3 -7
  76. package/dist/types/push/index.d.ts +1 -0
  77. package/dist/types/push/pb/OrderStatusData.d.ts +4 -0
  78. package/dist/types/push/push-client.d.ts +36 -3
  79. package/dist/types/push/push-message.d.ts +4 -0
  80. package/dist/types/push/tick-util.d.ts +30 -0
  81. package/dist/types/quote/quote-client.d.ts +193 -15
  82. package/dist/types/trade/trade-client.d.ts +136 -18
  83. package/dist/types/version.d.ts +1 -0
  84. package/package.json +5 -2
@@ -42,20 +42,42 @@ 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"
46
47
  }
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"
58
+ }
59
+ /**
60
+ * 订单状态枚举。对齐 Java SDK OrderStatus 定义。
61
+ *
62
+ * 服务端 wire 返回的值同时可能是:
63
+ * - 数字: -2 / -1 / 3 / 4 / 5 / 6 / 7 / 8
64
+ * - 字符串: "Invalid" / "Initial" / "PendingCancel" / "Cancelled" /
65
+ * "Submitted" / "Filled" / "Inactive" / "PendingSubmit"
66
+ *
67
+ * Client 层通过 normalizeOrderStatus() 做数字→字符串归一,不做跨别名合并。
68
+ */
48
69
  export declare enum OrderStatus {
49
- PendingNew = "PendingNew",
70
+ Invalid = "Invalid",
50
71
  Initial = "Initial",
72
+ PendingCancel = "PendingCancel",
73
+ Cancelled = "Cancelled",
51
74
  Submitted = "Submitted",
52
- PartiallyFilled = "PartiallyFilled",
53
75
  Filled = "Filled",
54
- Cancelled = "Cancelled",
55
- PendingCancel = "PendingCancel",
56
76
  Inactive = "Inactive",
57
- Invalid = "Invalid"
77
+ PendingSubmit = "PendingSubmit"
58
78
  }
79
+ /** 返回订单状态对应的服务端数字码,未知返回 0。 */
80
+ export declare function orderStatusCode(status: OrderStatus | string): number;
59
81
  /** K 线周期枚举 */
60
82
  export declare enum BarPeriod {
61
83
  Day = "day",
@@ -93,5 +115,53 @@ export declare enum License {
93
115
  export declare enum TimeInForce {
94
116
  DAY = "DAY",
95
117
  GTC = "GTC",
118
+ GTD = "GTD",
96
119
  OPG = "OPG"
97
120
  }
121
+ /** 订单排序字段 */
122
+ export declare enum OrderSortBy {
123
+ LatestCreated = "LATEST_CREATED",
124
+ LatestStatusUpdated = "LATEST_STATUS_UPDATED"
125
+ }
126
+ /** 账户分部类型 */
127
+ export declare enum SegmentType {
128
+ All = "ALL",
129
+ Sec = "SEC",
130
+ Fut = "FUT",
131
+ Fund = "FUND"
132
+ }
133
+ /** 公司行动类型 */
134
+ export declare enum CorporateActionType {
135
+ Split = "split",
136
+ Dividend = "dividend",
137
+ Earning = "earning",
138
+ SymbolChange = "symbol_change",
139
+ Delisting = "delisting",
140
+ IPO = "ipo"
141
+ }
142
+ /** 行业级别 (1~4 级) */
143
+ export declare enum IndustryLevel {
144
+ GSector = "GSECTOR",
145
+ GGroup = "GGROUP",
146
+ GInd = "GIND",
147
+ GSubInd = "GSUBIND"
148
+ }
149
+ /** 排序方向 */
150
+ export declare enum SortDirection {
151
+ No = "SortDir_No",
152
+ Ascend = "SortDir_Ascend",
153
+ Descend = "SortDir_Descend"
154
+ }
155
+ /** 期权分析周期 */
156
+ export declare enum OptionAnalysisPeriod {
157
+ ThreeYear = "3year",
158
+ FiftyTwoWeek = "52week",
159
+ TwentySixWeek = "26week",
160
+ ThirteenWeek = "13week"
161
+ }
162
+ /** 财报类型 */
163
+ export declare enum FinancialReportPeriod {
164
+ Annual = "Annual",
165
+ Quarterly = "Quarterly",
166
+ LTM = "LTM"
167
+ }
@@ -2,7 +2,8 @@
2
2
  * Order construction helpers.
3
3
  * All helpers return an `OrderRequest` with sensible defaults.
4
4
  */
5
- import type { OrderRequest, OrderLegRequest, AlgoParamsRequest } from './order';
5
+ import type { OrderRequest, OrderLegRequest, AlgoParamsRequest, ContractLegRequest } 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,55 @@ 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. `displaySize` is required; all other parameters are optional.
25
+ * Pass `priceType` as empty string to use the server default (LIMIT_PRICE).
26
+ * Pass `startTime` / `endTime` as 0 to omit the time window.
27
+ */
28
+ export declare function icebergOrder(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
29
  /** Attached profit / loss leg */
23
30
  export declare function orderLeg(legType: string, price: number, timeInForce: string): OrderLegRequest;
31
+ /**
32
+ * Market order by cash amount (instead of quantity).
33
+ * Server uses `isQuantityByAmount=true` + `amount` field.
34
+ */
35
+ export declare function marketOrderByAmount(account: string, symbol: string, secType: string, action: string, amount: number): OrderRequest;
36
+ /**
37
+ * Limit order by cash amount (instead of quantity).
38
+ */
39
+ export declare function limitOrderByAmount(account: string, symbol: string, secType: string, action: string, amount: number, limitPrice: number): OrderRequest;
40
+ /**
41
+ * Trailing stop order using a fixed price offset (auxPrice) instead of a percentage.
42
+ * Use `trailOrder()` for percentage-based trailing stops.
43
+ */
44
+ export declare function trailOrderByPrice(account: string, symbol: string, secType: string, action: string, quantity: number, auxPrice: number): OrderRequest;
45
+ /**
46
+ * Limit order with attached profit/loss legs (bracket order).
47
+ * At most 2 legs are supported.
48
+ *
49
+ * @param orderLegs - Array of `OrderLegRequest` (use `orderLeg()` helper)
50
+ */
51
+ export declare function limitOrderWithLegs(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number, orderLegs: OrderLegRequest[]): OrderRequest;
52
+ /**
53
+ * Multi-leg (combo/MLEG) order for options combos.
54
+ *
55
+ * @param contractLegs - Array of `ContractLegRequest` (use `contractLeg()` helper)
56
+ * @param comboType - e.g. `'MLEG'`
57
+ */
58
+ export declare function comboOrder(account: string, action: string, quantity: number, orderType: string, contractLegs: ContractLegRequest[], comboType?: string, limitPrice?: number, auxPrice?: number, trailingPercent?: number): OrderRequest;
59
+ /**
60
+ * OCA (One-Cancels-All) order.
61
+ * Server expects `orderType: 'OCA'` and an `ocaOrders` list.
62
+ *
63
+ * @param ocaOrders - The contained orders (use any order helper to build each)
64
+ */
65
+ export declare function ocaOrder(account: string, symbol: string, secType: string, action: string, quantity: number, ocaOrders: OrderRequest[]): OrderRequest;
66
+ /**
67
+ * Build a single leg for a multi-leg (MLEG / combo) order.
68
+ *
69
+ * @param symbol - Underlying symbol
70
+ * @param secType - Security type (e.g. `'OPT'`)
71
+ * @param action - `'BUY'` or `'SELL'`
72
+ * @param ratio - Number of contracts for this leg
73
+ */
74
+ export declare function contractLeg(symbol: string, secType: string, action: string, ratio: number, expiry?: string, strike?: string, right?: string): ContractLegRequest;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Order status normalization.
3
+ *
4
+ * 服务端返回的订单状态有时是整数(-2/-1/3/4/5/6/7/8),有时是字符串
5
+ * ("Invalid"/"Submitted"/...)。本模块把二者统一为 Java SDK OrderStatus 的
6
+ * 字符串值。不做跨别名合并。
7
+ *
8
+ * 对齐 Java SDK OrderStatus.java。
9
+ */
10
+ /**
11
+ * 把服务端可能返回的 string/number 订单状态归一为字符串。
12
+ * 字符串原样透传;数字按映射表转换;其他输入返回空串。
13
+ */
14
+ export declare function normalizeOrderStatus(raw: unknown): string;
@@ -12,18 +12,36 @@ export interface OrderLeg {
12
12
  timeInForce?: string;
13
13
  quantity?: number;
14
14
  }
15
- /** Algo order parameters — response side */
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
- startTime?: string;
19
- endTime?: string;
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). */
23
40
  export interface Order {
24
41
  account?: string;
25
- id?: number;
26
- orderId?: number;
42
+ /** int64 order ID — may be a string when it exceeds Number.MAX_SAFE_INTEGER */
43
+ id?: number | string;
44
+ orderId?: number | string;
27
45
  externalId?: string;
28
46
  action?: string;
29
47
  orderType?: string;
@@ -82,6 +100,8 @@ export interface OrderRequest {
82
100
  account?: string;
83
101
  /** Global order ID (required for modify) */
84
102
  id?: number;
103
+ /** Institutional account trading key (client fills it in automatically if set) */
104
+ secretKey?: string;
85
105
  /** Account-level order ID */
86
106
  orderId?: number;
87
107
  /** BUY / SELL */
@@ -124,18 +144,115 @@ export interface OrderRequest {
124
144
  remark?: string;
125
145
  /** User mark */
126
146
  userMark?: string;
147
+ /** 冰山单:展示数量 */
148
+ displaySize?: number;
149
+ /** 冰山单:最小展示数量 */
150
+ minDisplaySize?: number;
151
+ /** 冰山单:价检间隔(秒) */
152
+ checkIntervals?: number;
153
+ /** 冰山单:价格类型(LIMIT_PRICE / ASK_PRICE / BID_PRICE / LATEST_PRICE) */
154
+ priceType?: string;
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;
167
+ /** GTD 到期时间(epoch ms) */
168
+ expireTime?: number;
169
+ /** 盘后委托价格 */
170
+ afterHoursPrice?: number;
171
+ /** 批次号 */
172
+ batchNo?: number;
173
+ /** 资金类型(CASH / MARGIN) */
174
+ segType?: string;
175
+ /** 按金额下单:委托金额 */
176
+ amount?: number;
177
+ /** 按金额下单:现金金额(wire: cash_amount,与 amount 二选一) */
178
+ cashAmount?: number;
179
+ /**
180
+ * @deprecated 服务端不再需要此字段,by-amount 订单直接设置 `cashAmount`。
181
+ * 保留仅为向前兼容,新代码勿使用。
182
+ */
183
+ isQuantityByAmount?: boolean;
184
+ /** 账户分配列表(机构账户) */
185
+ allocAccounts?: string[];
186
+ /** 各账户分配份额(与 allocAccounts 一一对应) */
187
+ allocShares?: number[];
188
+ /** 下单来源 */
189
+ source?: string;
190
+ /** 下单渠道 */
191
+ channel?: string;
192
+ /** 虚拟订单类型 */
193
+ virtualOrderType?: string;
194
+ /** 虚拟订单 ID */
195
+ virtualId?: string;
196
+ /** 止盈订单 ID(bracket 关联) */
197
+ profitTakerOrderId?: number;
198
+ /** 止损订单 ID(bracket 关联) */
199
+ stopLossOrderId?: number;
200
+ /** 本地流水号 */
201
+ localNo?: string;
202
+ /** OCA 订单组(One-Cancels-All) */
203
+ ocaOrders?: OrderRequest[];
204
+ /** 多腿期权各腿(MLEG) */
205
+ contractLegs?: ContractLegRequest[];
206
+ /** 组合单类型(如 MLEG) */
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;
219
+ }
220
+ /** Single leg of a multi-leg option order (MLEG) */
221
+ export interface ContractLegRequest {
222
+ symbol?: string;
223
+ secType?: string;
224
+ expiry?: string;
225
+ strike?: string;
226
+ right?: string;
227
+ action?: string;
228
+ ratio?: number;
127
229
  }
128
- /** Attached leg for request side */
230
+ /** Attached profit/loss leg for order request side */
129
231
  export interface OrderLegRequest {
130
232
  legType: string;
131
233
  price?: number;
132
234
  timeInForce?: string;
133
235
  quantity?: number;
134
236
  }
135
- /** Algo parameters for request side */
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
+ */
136
247
  export interface AlgoParamsRequest {
137
- algoStrategy?: string;
138
- startTime?: string;
139
- endTime?: string;
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) */
140
257
  participationRate?: number;
141
258
  }