@tigeropenapi/tigeropen 0.1.0 → 0.4.0

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 (141) hide show
  1. package/README.md +475 -104
  2. package/dist/cjs/client/api-request.js +16 -10
  3. package/dist/cjs/client/api-response.js +23 -3
  4. package/dist/cjs/client/case-convert.js +35 -0
  5. package/dist/cjs/client/http-client.js +47 -21
  6. package/dist/cjs/client/index.js +6 -2
  7. package/dist/cjs/config/client-config.js +130 -49
  8. package/dist/cjs/config/domain.js +21 -2
  9. package/dist/cjs/config/index.js +3 -1
  10. package/dist/cjs/index.js +1 -1
  11. package/dist/cjs/model/contract.js +1 -2
  12. package/dist/cjs/model/enums.js +89 -7
  13. package/dist/cjs/model/order-helpers.js +9 -9
  14. package/dist/cjs/model/order-status.js +46 -0
  15. package/dist/cjs/model/order.js +5 -2
  16. package/dist/cjs/model/position.js +1 -2
  17. package/dist/cjs/model/quote-requests.js +11 -0
  18. package/dist/cjs/model/quote.js +7 -0
  19. package/dist/cjs/model/trade-requests.js +13 -0
  20. package/dist/cjs/model/trade.js +2 -0
  21. package/dist/cjs/push/index.js +6 -3
  22. package/dist/cjs/push/pb/AssetData.js +208 -0
  23. package/dist/cjs/push/pb/KlineData.js +184 -0
  24. package/dist/cjs/push/pb/OptionTopData.js +427 -0
  25. package/dist/cjs/push/pb/OrderStatusData.js +592 -0
  26. package/dist/cjs/push/pb/OrderTransactionData.js +256 -0
  27. package/dist/cjs/push/pb/PositionData.js +316 -0
  28. package/dist/cjs/push/pb/PushData.js +219 -0
  29. package/dist/cjs/push/pb/QuoteBBOData.js +160 -0
  30. package/dist/cjs/push/pb/QuoteBasicData.js +329 -0
  31. package/dist/cjs/push/pb/QuoteData.js +507 -0
  32. package/dist/cjs/push/pb/QuoteDepthData.js +220 -0
  33. package/dist/cjs/push/pb/Request.js +278 -0
  34. package/dist/cjs/push/pb/Response.js +97 -0
  35. package/dist/cjs/push/pb/SocketCommon.js +86 -0
  36. package/dist/cjs/push/pb/StockTopData.js +199 -0
  37. package/dist/cjs/push/pb/TickData.js +202 -0
  38. package/dist/cjs/push/pb/TradeTickData.js +308 -0
  39. package/dist/cjs/push/pb/index.js +49 -0
  40. package/dist/cjs/push/proto-message.js +135 -0
  41. package/dist/cjs/push/push-client.js +361 -163
  42. package/dist/cjs/push/push-message.js +8 -60
  43. package/dist/cjs/push/varint.js +76 -0
  44. package/dist/cjs/quote/index.js +3 -2
  45. package/dist/cjs/quote/quote-client.js +440 -94
  46. package/dist/cjs/signer/signer.js +10 -10
  47. package/dist/cjs/trade/trade-client.js +197 -62
  48. package/dist/esm/client/api-request.js +14 -8
  49. package/dist/esm/client/api-response.js +22 -3
  50. package/dist/esm/client/case-convert.js +31 -0
  51. package/dist/esm/client/http-client.js +48 -22
  52. package/dist/esm/client/index.js +3 -2
  53. package/dist/esm/config/client-config.js +131 -51
  54. package/dist/esm/config/domain.js +20 -2
  55. package/dist/esm/config/index.js +2 -2
  56. package/dist/esm/index.js +1 -1
  57. package/dist/esm/model/contract.js +1 -2
  58. package/dist/esm/model/enums.js +87 -6
  59. package/dist/esm/model/order-helpers.js +9 -9
  60. package/dist/esm/model/order-status.js +43 -0
  61. package/dist/esm/model/order.js +5 -2
  62. package/dist/esm/model/position.js +1 -2
  63. package/dist/esm/model/quote-requests.js +10 -0
  64. package/dist/esm/model/quote.js +6 -0
  65. package/dist/esm/model/trade-requests.js +12 -0
  66. package/dist/esm/model/trade.js +1 -0
  67. package/dist/esm/push/index.js +4 -2
  68. package/dist/esm/push/pb/AssetData.js +205 -0
  69. package/dist/esm/push/pb/KlineData.js +181 -0
  70. package/dist/esm/push/pb/OptionTopData.js +424 -0
  71. package/dist/esm/push/pb/OrderStatusData.js +589 -0
  72. package/dist/esm/push/pb/OrderTransactionData.js +253 -0
  73. package/dist/esm/push/pb/PositionData.js +313 -0
  74. package/dist/esm/push/pb/PushData.js +216 -0
  75. package/dist/esm/push/pb/QuoteBBOData.js +157 -0
  76. package/dist/esm/push/pb/QuoteBasicData.js +326 -0
  77. package/dist/esm/push/pb/QuoteData.js +504 -0
  78. package/dist/esm/push/pb/QuoteDepthData.js +217 -0
  79. package/dist/esm/push/pb/Request.js +275 -0
  80. package/dist/esm/push/pb/Response.js +94 -0
  81. package/dist/esm/push/pb/SocketCommon.js +83 -0
  82. package/dist/esm/push/pb/StockTopData.js +196 -0
  83. package/dist/esm/push/pb/TickData.js +199 -0
  84. package/dist/esm/push/pb/TradeTickData.js +305 -0
  85. package/dist/esm/push/pb/index.js +25 -0
  86. package/dist/esm/push/proto-message.js +127 -0
  87. package/dist/esm/push/push-client.js +329 -164
  88. package/dist/esm/push/push-message.js +7 -56
  89. package/dist/esm/push/varint.js +72 -0
  90. package/dist/esm/quote/index.js +2 -2
  91. package/dist/esm/quote/quote-client.js +439 -94
  92. package/dist/esm/signer/signer.js +10 -10
  93. package/dist/esm/trade/trade-client.js +197 -62
  94. package/dist/types/client/api-request.d.ts +12 -11
  95. package/dist/types/client/api-response.d.ts +15 -7
  96. package/dist/types/client/case-convert.d.ts +16 -0
  97. package/dist/types/client/http-client.d.ts +26 -14
  98. package/dist/types/client/index.d.ts +3 -2
  99. package/dist/types/config/client-config.d.ts +29 -13
  100. package/dist/types/config/domain.d.ts +9 -0
  101. package/dist/types/config/index.d.ts +2 -2
  102. package/dist/types/index.d.ts +1 -1
  103. package/dist/types/model/contract.d.ts +13 -29
  104. package/dist/types/model/enums.d.ts +60 -6
  105. package/dist/types/model/order-helpers.d.ts +21 -20
  106. package/dist/types/model/order-status.d.ts +14 -0
  107. package/dist/types/model/order.d.ts +101 -55
  108. package/dist/types/model/position.d.ts +26 -24
  109. package/dist/types/model/quote-requests.d.ts +344 -0
  110. package/dist/types/model/quote.d.ts +572 -0
  111. package/dist/types/model/trade-requests.d.ts +195 -0
  112. package/dist/types/model/trade.d.ts +235 -0
  113. package/dist/types/push/callbacks.d.ts +32 -51
  114. package/dist/types/push/index.d.ts +5 -3
  115. package/dist/types/push/pb/AssetData.d.ts +47 -0
  116. package/dist/types/push/pb/KlineData.d.ts +43 -0
  117. package/dist/types/push/pb/OptionTopData.d.ts +76 -0
  118. package/dist/types/push/pb/OrderStatusData.d.ts +100 -0
  119. package/dist/types/push/pb/OrderTransactionData.d.ts +51 -0
  120. package/dist/types/push/pb/PositionData.d.ts +63 -0
  121. package/dist/types/push/pb/PushData.d.ts +46 -0
  122. package/dist/types/push/pb/QuoteBBOData.d.ts +35 -0
  123. package/dist/types/push/pb/QuoteBasicData.d.ts +66 -0
  124. package/dist/types/push/pb/QuoteData.d.ts +94 -0
  125. package/dist/types/push/pb/QuoteDepthData.d.ts +37 -0
  126. package/dist/types/push/pb/Request.d.ts +44 -0
  127. package/dist/types/push/pb/Response.d.ts +30 -0
  128. package/dist/types/push/pb/SocketCommon.d.ts +64 -0
  129. package/dist/types/push/pb/StockTopData.d.ts +37 -0
  130. package/dist/types/push/pb/TickData.d.ts +44 -0
  131. package/dist/types/push/pb/TradeTickData.d.ts +53 -0
  132. package/dist/types/push/pb/index.d.ts +39 -0
  133. package/dist/types/push/proto-message.d.ts +33 -0
  134. package/dist/types/push/push-client.d.ts +100 -68
  135. package/dist/types/push/push-message.d.ts +7 -147
  136. package/dist/types/push/varint.d.ts +23 -0
  137. package/dist/types/quote/index.d.ts +2 -2
  138. package/dist/types/quote/quote-client.d.ts +154 -47
  139. package/dist/types/signer/signer.d.ts +6 -6
  140. package/dist/types/trade/trade-client.d.ts +106 -38
  141. package/package.json +11 -6
@@ -1,58 +1,165 @@
1
1
  /**
2
- * QuoteClient 行情查询客户端
3
- * 封装所有行情相关 API,通过 HttpClient 发送请求
2
+ * QuoteClient — market-data client.
3
+ *
4
+ * All methods return strongly-typed responses from the `model` package.
5
+ * Request parameters are written in camelCase in TypeScript and are
6
+ * converted to snake_case on the wire automatically.
4
7
  */
5
8
  import type { HttpClient } from '../client/http-client';
9
+ import type { MarketState, Brief, Kline, KlineItem, Timeline, TradeTick, Depth, OptionExpiration, OptionChain, FutureExchange, FutureContractInfo, FutureQuote, FutureKline, FutureKlineItem, FinancialDailyItem, FinancialReportItem, CorporateAction, CapitalFlow, CapitalDistribution, ScannerResult, QuotePermission, FinancialDailyRequest, FinancialReportRequest, CorporateActionRequest, FutureKlineRequest, MarketScannerRequest, SymbolName, TradeMeta, StockDetail, StockBroker, StockIndustry, TradeRankItem, ShortInterest, KlineQuota, OptionAnalysis, OptionSymbol, FutureMainContractHistory, FutureTradingTime, FutureTradeTickItem, FutureDepth, WarrantBrief, WarrantFilterResult, IndustryItem, IndustryStock, TradingCalendarItem, ExchangeRate, FinancialCurrency, QuoteOvernight, MarketScannerTags, FundContractInfo, FundQuote, FundHistoryQuote } from '../model/quote';
10
+ import type { BriefRequest, DepthQuoteRequest, TradeTickRequest, FutureBriefRequest, SymbolsRequest, TradeMetasRequest, StockDetailsRequest, StockDelayBriefsRequest, BarsRequest, BarsByPageRequest, TimelineHistoryRequest, TradeRankRequest, ShortInterestRequest, StockBrokerRequest, StockFundamentalRequest, StockIndustryRequest, KlineQuotaRequest, QuotePermissionRequest, OptionBarsRequest, OptionTradeTicksRequest, OptionTimelineRequest, OptionDepthRequest, OptionSymbolsRequest, OptionAnalysisRequest, FutureContractSingleRequest, AllFutureContractsRequest, FutureContinuousContractsRequest, FutureHistoryMainContractRequest, FutureBarsRequest, FutureBarsByPageRequest, FutureTradeTicksRequest, FutureDepthRequest, FutureTradingTimesRequest, FundSymbolsRequest, FundContractsRequest, FundQuoteRequest, FundHistoryQuoteRequest, WarrantBriefsRequest, WarrantFilterRequest, IndustryListRequest, IndustryStocksRequest, TradingCalendarRequest, FinancialExchangeRateRequest, FinancialCurrencyRequest, MarketScannerTagsRequest, QuoteOvernightRequest } from '../model/quote-requests';
6
11
  /**
7
- * 行情查询客户端,封装所有行情相关 API。
12
+ * Parse an OCC-style option identifier like "AAPL 260619C00150000"
13
+ * into its component parts.
8
14
  */
15
+ export declare function parseOptionIdentifier(identifier: string): {
16
+ symbol: string;
17
+ expiryMs: number;
18
+ right: string;
19
+ strike: number;
20
+ };
21
+ /** Market data client wrapping all quote-related APIs. */
9
22
  export declare class QuoteClient {
10
23
  private httpClient;
11
24
  constructor(httpClient: HttpClient);
25
+ private callInto;
12
26
  /**
13
- * 内部通用方法:构造请求、发送、返回 data 字段
27
+ * Some endpoints return either a list or a single object depending on the
28
+ * server response shape (future_contract_by_contract_code /
29
+ * future_continuous_contracts). Unify into an array.
14
30
  */
15
- private execute;
16
- /** 获取市场状态 */
17
- marketState(market: string): Promise<unknown>;
18
- /** 获取实时报价 */
19
- quoteRealTime(symbols: string[]): Promise<unknown>;
20
- /** 获取 K 线数据 */
21
- kline(symbol: string, period: string): Promise<unknown>;
22
- /** 获取分时数据 */
23
- timeline(symbols: string[]): Promise<unknown>;
24
- /** 获取逐笔成交数据 */
25
- tradeTick(symbols: string[]): Promise<unknown>;
26
- /** 获取深度行情 */
27
- quoteDepth(symbol: string): Promise<unknown>;
28
- /** 获取期权到期日 */
29
- optionExpiration(symbol: string): Promise<unknown>;
30
- /** 获取期权链 */
31
- optionChain(symbol: string, expiry: string): Promise<unknown>;
32
- /** 获取期权报价 */
33
- optionBrief(identifiers: string[]): Promise<unknown>;
34
- /** 获取期权 K 线 */
35
- optionKline(identifier: string, period: string): Promise<unknown>;
36
- /** 获取期货交易所列表 */
37
- futureExchange(): Promise<unknown>;
38
- /** 获取期货合约列表 */
39
- futureContracts(exchange: string): Promise<unknown>;
40
- /** 获取期货实时报价 */
41
- futureRealTimeQuote(symbols: string[]): Promise<unknown>;
42
- /** 获取期货 K 线 */
43
- futureKline(symbol: string, period: string): Promise<unknown>;
44
- /** 获取财务日报 */
45
- financialDaily(symbol: string): Promise<unknown>;
46
- /** 获取财务报告 */
47
- financialReport(symbol: string): Promise<unknown>;
48
- /** 获取公司行动 */
49
- corporateAction(symbol: string): Promise<unknown>;
50
- /** 获取资金流向 */
51
- capitalFlow(symbol: string): Promise<unknown>;
52
- /** 获取资金分布 */
53
- capitalDistribution(symbol: string): Promise<unknown>;
54
- /** 选股器 */
55
- marketScanner(params: Record<string, unknown>): Promise<unknown>;
56
- /** 获取行情权限 */
57
- grabQuotePermission(): Promise<unknown>;
31
+ private callIntoListOrObject;
32
+ /** Unwrap server {"items":[...]} envelope. */
33
+ private callIntoItems;
34
+ getMarketState(market: string): Promise<MarketState[]>;
35
+ /** Real-time stock briefs. wire: quote_real_time */
36
+ getBrief(req: BriefRequest): Promise<Brief[]>;
37
+ getKline(symbol: string, period: string): Promise<Kline[]>;
38
+ getTimeline(symbols: string[]): Promise<Timeline[]>;
39
+ /** Tick-by-tick trades. wire: trade_tick */
40
+ getTradeTick(req: TradeTickRequest): Promise<TradeTick[]>;
41
+ /** Depth snapshot. wire: quote_depth */
42
+ getQuoteDepth(req: DepthQuoteRequest): Promise<Depth[]>;
43
+ getOptionExpiration(symbol: string): Promise<OptionExpiration[]>;
44
+ /** Option chain; `expiry` is "YYYY-MM-DD". */
45
+ getOptionChain(symbol: string, expiry: string): Promise<OptionChain[]>;
46
+ getOptionBrief(identifiers: string[]): Promise<Brief[]>;
47
+ getOptionKline(identifier: string, period: string): Promise<Kline[]>;
48
+ getFutureExchange(): Promise<FutureExchange[]>;
49
+ getFutureContracts(exchange: string): Promise<FutureContractInfo[]>;
50
+ /** Real-time futures quotes. wire: future_real_time_quote */
51
+ getFutureRealTimeQuote(req: FutureBriefRequest): Promise<FutureQuote[]>;
52
+ /** Futures K-line; use -1 for unbounded beginTime / endTime. */
53
+ getFutureKline(req: FutureKlineRequest): Promise<FutureKline[]>;
54
+ getFinancialDaily(req: FinancialDailyRequest): Promise<FinancialDailyItem[]>;
55
+ getFinancialReport(req: FinancialReportRequest): Promise<FinancialReportItem[]>;
56
+ /**
57
+ * Corporate actions. Server returns {symbol: [...]}, this method flattens into a single list.
58
+ */
59
+ getCorporateAction(req: CorporateActionRequest): Promise<CorporateAction[]>;
60
+ getCapitalFlow(symbol: string, market: string, period: string): Promise<CapitalFlow | undefined>;
61
+ getCapitalDistribution(symbol: string, market: string): Promise<CapitalDistribution | undefined>;
62
+ marketScanner(req: MarketScannerRequest): Promise<ScannerResult | undefined>;
63
+ grabQuotePermission(): Promise<QuotePermission[]>;
64
+ /** All symbol codes (string list). wire: all_symbols */
65
+ getSymbols(req: SymbolsRequest): Promise<string[]>;
66
+ /** All symbols with names. wire: all_symbol_names */
67
+ getSymbolNames(req: SymbolsRequest): Promise<SymbolName[]>;
68
+ /** Trade meta (lot size / tick size). wire: quote_stock_trade */
69
+ getTradeMetas(req: TradeMetasRequest): Promise<TradeMeta[]>;
70
+ /** Stock details. wire: stock_detail. Server returns {items:[...]}. */
71
+ getStockDetails(req: StockDetailsRequest): Promise<StockDetail[]>;
72
+ /** Delayed stock briefs. wire: quote_delay */
73
+ getStockDelayBriefs(req: StockDelayBriefsRequest): Promise<Brief[]>;
74
+ /** K-line bars (full request). wire: kline */
75
+ getBars(req: BarsRequest): Promise<Kline[]>;
76
+ /**
77
+ * Client-side paginated K-line fetch — loops over getBars until TotalSize
78
+ * bars are collected. Items are returned oldest-first, matching
79
+ * Python/Go get_bars_by_page behaviour.
80
+ */
81
+ getBarsByPage(req: BarsByPageRequest): Promise<KlineItem[]>;
82
+ /** Historical intraday timeline. wire: history_timeline */
83
+ getTimelineHistory(req: TimelineHistoryRequest): Promise<Timeline[]>;
84
+ /** Trade rank (top movers / volume). wire: trade_rank */
85
+ getTradeRank(req: TradeRankRequest): Promise<TradeRankItem[]>;
86
+ /** Short interest / shortable. wire: quote_shortable_stocks */
87
+ getShortInterest(req: ShortInterestRequest): Promise<ShortInterest[]>;
88
+ /** Broker queue. wire: stock_broker */
89
+ getStockBroker(req: StockBrokerRequest): Promise<StockBroker | undefined>;
90
+ /** Stock fundamentals (server returns grouped map). wire: stock_fundamental */
91
+ getStockFundamental(req: StockFundamentalRequest): Promise<Record<string, unknown>>;
92
+ /** Stock industry classification (array). wire: stock_industry */
93
+ getStockIndustry(req: StockIndustryRequest): Promise<StockIndustry[]>;
94
+ /** Quote permission detail. wire: get_quote_permission */
95
+ getQuotePermission(req: QuotePermissionRequest): Promise<QuotePermission[]>;
96
+ /** K-line quota usage. wire: kline_quota */
97
+ getKlineQuota(req: KlineQuotaRequest): Promise<KlineQuota[]>;
98
+ /** Option K-line. wire: option_kline (v2.0) */
99
+ getOptionBars(req: OptionBarsRequest): Promise<Kline[]>;
100
+ /** Option tick trades. wire: option_trade_tick */
101
+ getOptionTradeTicks(req: OptionTradeTicksRequest): Promise<TradeTick[]>;
102
+ /** Option intraday timeline. wire: option_timeline */
103
+ getOptionTimeline(req: OptionTimelineRequest): Promise<Timeline[]>;
104
+ /** Option depth. wire: option_depth */
105
+ getOptionDepth(req: OptionDepthRequest): Promise<Depth[]>;
106
+ /** Available option symbols. wire: option_symbol */
107
+ getOptionSymbols(req: OptionSymbolsRequest): Promise<OptionSymbol[]>;
108
+ /** Option analysis (volatility). wire: option_analysis */
109
+ getOptionAnalysis(req: OptionAnalysisRequest): Promise<OptionAnalysis[]>;
110
+ /** Single futures contract by code. wire: future_contract_by_contract_code */
111
+ getFutureContract(req: FutureContractSingleRequest): Promise<FutureContractInfo[]>;
112
+ /** All futures contracts. wire: future_contracts */
113
+ getAllFutureContracts(req: AllFutureContractsRequest): Promise<FutureContractInfo[]>;
114
+ /** Current main contract. wire: future_current_contract */
115
+ getCurrentFutureContract(req: FutureContractSingleRequest): Promise<FutureContractInfo | undefined>;
116
+ /** Continuous main contracts. wire: future_continuous_contracts */
117
+ getFutureContinuousContracts(req: FutureContinuousContractsRequest): Promise<FutureContractInfo[]>;
118
+ /** Historical main contracts. wire: future_main_contract */
119
+ getFutureHistoryMainContract(req: FutureHistoryMainContractRequest): Promise<FutureMainContractHistory[]>;
120
+ /**
121
+ * Futures K-line (full request with index pagination). wire: future_kline
122
+ * begin_time / end_time default to -1 when unset (server requires them present).
123
+ */
124
+ getFutureBars(req: FutureBarsRequest): Promise<FutureKline[]>;
125
+ /** Client-side paginated futures K-line fetch. */
126
+ getFutureBarsByPage(req: FutureBarsByPageRequest): Promise<FutureKlineItem[]>;
127
+ /** Futures tick trades. wire: future_tick (API v3.0) */
128
+ getFutureTradeTicks(req: FutureTradeTicksRequest): Promise<FutureTradeTickItem[]>;
129
+ /** Futures depth. wire: future_depth */
130
+ getFutureDepth(req: FutureDepthRequest): Promise<FutureDepth[]>;
131
+ /** Futures trading times (single-object response). wire: future_trading_date */
132
+ getFutureTradingTimes(req: FutureTradingTimesRequest): Promise<FutureTradingTime | undefined>;
133
+ /** Fund symbols. wire: fund_all_symbols */
134
+ getFundSymbols(req: FundSymbolsRequest): Promise<string[]>;
135
+ /** Fund contracts. wire: fund_contracts */
136
+ getFundContracts(req: FundContractsRequest): Promise<FundContractInfo[]>;
137
+ /** Fund real-time NAV. wire: fund_quote */
138
+ getFundQuote(req: FundQuoteRequest): Promise<FundQuote[]>;
139
+ /** Fund historical NAV. wire: fund_history_quote */
140
+ getFundHistoryQuote(req: FundHistoryQuoteRequest): Promise<FundHistoryQuote[]>;
141
+ /** Warrant briefs. wire: warrant_briefs */
142
+ getWarrantBriefs(req: WarrantBriefsRequest): Promise<WarrantBrief[]>;
143
+ /** Warrant filter (paged). wire: warrant_filter */
144
+ getWarrantFilter(req: WarrantFilterRequest): Promise<WarrantFilterResult | undefined>;
145
+ /** Industry list. wire: industry_list */
146
+ getIndustryList(req: IndustryListRequest): Promise<IndustryItem[]>;
147
+ /** Stocks inside an industry. wire: industry_stock_list */
148
+ getIndustryStocks(req: IndustryStocksRequest): Promise<IndustryStock[]>;
149
+ /** Corporate split (flattened). wire: corporate_action (action_type=split) */
150
+ getCorporateSplit(req: CorporateActionRequest): Promise<CorporateAction[]>;
151
+ /** Corporate dividend (flattened). wire: corporate_action (action_type=dividend) */
152
+ getCorporateDividend(req: CorporateActionRequest): Promise<CorporateAction[]>;
153
+ /** Corporate earnings calendar (flattened). wire: corporate_action (action_type=earning) */
154
+ getCorporateEarningsCalendar(req: CorporateActionRequest): Promise<CorporateAction[]>;
155
+ /** Financial currency per symbol. wire: financial_currency */
156
+ getFinancialCurrency(req: FinancialCurrencyRequest): Promise<FinancialCurrency[]>;
157
+ /** FX rates. wire: financial_exchange_rate */
158
+ getFinancialExchangeRate(req: FinancialExchangeRateRequest): Promise<ExchangeRate[]>;
159
+ /** Trading calendar. wire: trading_calendar */
160
+ getTradingCalendar(req: TradingCalendarRequest): Promise<TradingCalendarItem[]>;
161
+ /** Available market-scanner tags. wire: market_scanner_tags */
162
+ getMarketScannerTags(req: MarketScannerTagsRequest): Promise<MarketScannerTags | undefined>;
163
+ /** Overnight quote. wire: quote_overnight */
164
+ getQuoteOvernight(req: QuoteOvernightRequest): Promise<QuoteOvernight[]>;
58
165
  }
@@ -26,11 +26,11 @@ export declare function loadPrivateKey(keyStr: string): KeyObject;
26
26
  */
27
27
  export declare function signWithRSA(privateKeyStr: string, content: string): string;
28
28
  /**
29
- * 使用 RSA 公钥验证 SHA1WithRSA 签名。
29
+ * Verify a SHA1WithRSA signature using an RSA public key.
30
30
  *
31
- * @param publicKey - 公钥对象
32
- * @param content - 原始内容
33
- * @param signature - Base64 编码的签名字符串
34
- * @returns 验签是否成功
31
+ * @param publicKeyBase64 - Base64-encoded public key (DER / PKCS#1 or SPKI)
32
+ * @param content - Original content that was signed
33
+ * @param signatureBase64 - Base64-encoded signature
34
+ * @returns Whether the signature is valid
35
35
  */
36
- export declare function verifyWithRSA(publicKey: KeyObject, content: string, signature: string): boolean;
36
+ export declare function verifyWithRSA(publicKeyBase64: string, content: string, signatureBase64: string): boolean;
@@ -1,48 +1,116 @@
1
1
  /**
2
- * TradeClient 交易客户端
3
- * 封装所有交易相关 API,通过 HttpClient 发送请求
2
+ * TradeClient — trading client.
3
+ *
4
+ * All methods return strongly-typed responses; request parameters are
5
+ * written in camelCase in TypeScript and converted to snake_case on the wire.
6
+ *
7
+ * v0.4.0: 所有查询类方法改为 Request 对象签名(OrdersRequest 等),补齐 17
8
+ * 个新方法(账户管理 / 资产分析 / 资金调拨 / 持仓划转等)。
4
9
  */
5
10
  import type { HttpClient } from '../client/http-client';
6
- import type { Order } from '../model/order';
7
- /**
8
- * 交易客户端,封装所有交易相关 API。
9
- */
11
+ import type { OrderRequest, Order } from '../model/order';
12
+ import type { Contract } from '../model/contract';
13
+ import type { Position } from '../model/position';
14
+ import type { Asset, PrimeAsset, PreviewResult, PlaceOrderResult, OrderIdResult, Transaction, ManagedAccount, AnalyticsAsset, AggregateAssets, EstimateTradableQuantity, ForexOrderResult, SegmentFund, SegmentFundHistoryItem, FundDetails, FundingHistoryItem, PositionTransferRecord, PositionTransferDetail, PositionTransferExternalRecord } from '../model/trade';
15
+ import type { OrdersRequest, GetOrderRequest, OrderTransactionsRequest, PositionsRequest, AssetsRequest, ManagedAccountsRequest, DerivativeContractsRequest, AnalyticsAssetRequest, AggregateAssetsRequest, EstimateTradableQuantityRequest, ForexOrderRequest, SegmentFundRequest, FundDetailsRequest, FundingHistoryRequest, PositionTransferRequest, PositionTransferRecordsRequest, PositionTransferDetailRequest, PositionTransferExternalRecordsRequest } from '../model/trade-requests';
16
+ /** Trading client wrapping all trade-related APIs. */
10
17
  export declare class TradeClient {
11
18
  private httpClient;
12
19
  private account;
13
20
  constructor(httpClient: HttpClient, account: string);
21
+ private callInto;
22
+ /** Strip `{items: [...]}` envelope used by most trade read endpoints. */
23
+ private callIntoItems;
24
+ getContract(symbol: string, secType: string): Promise<Contract[]>;
25
+ getContracts(symbols: string[], secType: string): Promise<Contract[]>;
26
+ /**
27
+ * Derivative contracts (OPT / WAR / IOPT only).
28
+ * `symbol` is the underlying (e.g. "AAPL"); `expiry` is "YYYYMMDD".
29
+ */
30
+ getQuoteContract(symbol: string, secType: string, expiry: string): Promise<Contract[]>;
31
+ placeOrder(order: OrderRequest): Promise<PlaceOrderResult | undefined>;
32
+ previewOrder(order: OrderRequest): Promise<PreviewResult | undefined>;
33
+ modifyOrder(id: number, order: OrderRequest): Promise<OrderIdResult | undefined>;
34
+ cancelOrder(id: number): Promise<OrderIdResult | undefined>;
35
+ /**
36
+ * Query all historical orders. v0.4.0: optional OrdersRequest for filtering.
37
+ *
38
+ * @example
39
+ * // Default (unfiltered)
40
+ * await tc.getOrders();
41
+ * // Filter by status
42
+ * await tc.getOrders({ states: ['Filled'], limit: 100 });
43
+ */
44
+ getOrders(req?: OrdersRequest): Promise<Order[]>;
45
+ /** Query active (open) orders. v0.4.0: supports ParentId to filter attached legs. */
46
+ getActiveOrders(req?: OrdersRequest): Promise<Order[]>;
47
+ /** Query inactive/cancelled orders. */
48
+ getInactiveOrders(req?: OrdersRequest): Promise<Order[]>;
49
+ /**
50
+ * Query filled orders. v0.4.0 BREAKING: signature changed from positional
51
+ * (startDateMs, endDateMs) to OrdersRequest object.
52
+ *
53
+ * @example
54
+ * // Last 30 days
55
+ * const now = Date.now();
56
+ * await tc.getFilledOrders({ startDate: now - 30*24*3600*1000, endDate: now });
57
+ */
58
+ getFilledOrders(req?: OrdersRequest): Promise<Order[]>;
59
+ /**
60
+ * Get a single order by ID (v0.4.0 new).
61
+ * Wire method: `orders` with id/order_id param; server returns a single Order object
62
+ * (not `{items:[]}` envelope).
63
+ *
64
+ * Returns `undefined` if no match.
65
+ */
66
+ getOrder(req: GetOrderRequest): Promise<Order | undefined>;
67
+ /**
68
+ * Query order transaction details. v0.4.0 BREAKING: all fields now optional
69
+ * (previously symbol/secType required).
70
+ */
71
+ getOrderTransactions(req: OrderTransactionsRequest): Promise<Transaction[]>;
72
+ /** Query positions. v0.4.0: supports Symbol / SecType / Currency / Market filters. */
73
+ getPositions(req?: PositionsRequest): Promise<Position[]>;
74
+ /** Query assets. v0.4.0: supports sub-account list and aggregation options. */
75
+ getAssets(req?: AssetsRequest): Promise<Asset[]>;
76
+ /** Query prime assets. v0.4.0: takes AssetsRequest for filters. */
77
+ getPrimeAssets(req?: AssetsRequest): Promise<PrimeAsset | undefined>;
78
+ /** Query managed sub-accounts (institutional). */
79
+ getManagedAccounts(req?: ManagedAccountsRequest): Promise<ManagedAccount[]>;
80
+ /**
81
+ * Query derivative contracts list. Same wire as getQuoteContract but accepts
82
+ * full request struct. Python: `get_derivative_contracts`.
83
+ */
84
+ getDerivativeContracts(req: DerivativeContractsRequest): Promise<Contract[]>;
85
+ /** Daily P&L / net-value / holding-value analytics. */
86
+ getAnalyticsAsset(req: AnalyticsAssetRequest): Promise<AnalyticsAsset[]>;
87
+ /** Aggregate assets (prime) by base currency. */
88
+ getAggregateAssets(req?: AggregateAssetsRequest): Promise<AggregateAssets | undefined>;
89
+ /** Estimate tradable quantity given order parameters. */
90
+ getEstimateTradableQuantity(req: EstimateTradableQuantityRequest): Promise<EstimateTradableQuantity | undefined>;
91
+ /** Place forex order (sub-account base-currency swap). */
92
+ placeForexOrder(req: ForexOrderRequest): Promise<ForexOrderResult | undefined>;
93
+ /** Query amount available for inter-segment transfer. Returns array. */
94
+ getSegmentFundAvailable(req: SegmentFundRequest): Promise<SegmentFund[]>;
95
+ /** Query segment fund transfer history. Server returns plain array (no items wrapper). */
96
+ getSegmentFundHistory(req: SegmentFundRequest): Promise<SegmentFundHistoryItem[]>;
97
+ /** Execute an inter-segment fund transfer. */
98
+ transferSegmentFund(req: SegmentFundRequest): Promise<SegmentFund | undefined>;
99
+ /** Cancel a pending inter-segment transfer. */
100
+ cancelSegmentFund(req: SegmentFundRequest): Promise<SegmentFund | undefined>;
101
+ /** Fund-movement details (by segment / currency / fund-type). */
102
+ getFundDetails(req: FundDetailsRequest): Promise<FundDetails[]>;
103
+ /** Funding history (wire method: `transfer_fund`). */
104
+ getFundingHistory(req: FundingHistoryRequest): Promise<FundingHistoryItem[]>;
14
105
  /**
15
- * 内部通用方法:构造请求、发送、返回 data 字段
106
+ * Internal position transfer (cross sub-account).
107
+ * @note Uses `fromAccount` / `toAccount` (not `account`).
16
108
  */
17
- private execute;
18
- /** 查询单个合约 */
19
- contract(symbol: string, secType: string): Promise<unknown>;
20
- /** 批量查询合约 */
21
- contracts(symbols: string[], secType: string): Promise<unknown>;
22
- /** 查询衍生品合约 */
23
- quoteContract(symbol: string, secType: string): Promise<unknown>;
24
- /** 下单 */
25
- placeOrder(order: Order): Promise<unknown>;
26
- /** 预览订单 */
27
- previewOrder(order: Order): Promise<unknown>;
28
- /** 修改订单 */
29
- modifyOrder(id: number, order: Order): Promise<unknown>;
30
- /** 取消订单 */
31
- cancelOrder(id: number): Promise<unknown>;
32
- /** 查询全部订单 */
33
- orders(): Promise<unknown>;
34
- /** 查询待成交订单 */
35
- activeOrders(): Promise<unknown>;
36
- /** 查询已撤销订单 */
37
- inactiveOrders(): Promise<unknown>;
38
- /** 查询已成交订单 */
39
- filledOrders(): Promise<unknown>;
40
- /** 查询持仓 */
41
- positions(): Promise<unknown>;
42
- /** 查询资产 */
43
- assets(): Promise<unknown>;
44
- /** 查询综合账户资产 */
45
- primeAssets(): Promise<unknown>;
46
- /** 查询订单成交明细 */
47
- orderTransactions(id: number): Promise<unknown>;
109
+ transferPosition(req: PositionTransferRequest): Promise<PositionTransferRecord | undefined>;
110
+ /** Query internal position transfer records. Uses `accountId` (wire: `account_id`). */
111
+ getPositionTransferRecords(req: PositionTransferRecordsRequest): Promise<PositionTransferRecord[]>;
112
+ /** Query single internal position transfer detail by ID. */
113
+ getPositionTransferDetail(req: PositionTransferDetailRequest): Promise<PositionTransferDetail | undefined>;
114
+ /** Query external position transfer records (DWAC / FOP / etc.). */
115
+ getPositionTransferExternalRecords(req: PositionTransferExternalRecordsRequest): Promise<PositionTransferExternalRecord[]>;
48
116
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tigeropenapi/tigeropen",
3
- "version": "0.1.0",
4
- "description": "老虎证券 OpenAPI TypeScript SDK",
3
+ "version": "0.4.0",
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",
7
7
  "types": "./dist/types/index.d.ts",
@@ -28,9 +28,11 @@
28
28
  "build:esm": "tsc -p tsconfig.json",
29
29
  "build:cjs": "tsc -p tsconfig.cjs.json",
30
30
  "prepublishOnly": "npm run build",
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",
31
32
  "test": "vitest run",
32
33
  "test:watch": "vitest",
33
- "clean": "rm -rf dist"
34
+ "clean": "rm -rf dist",
35
+ "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"
34
36
  },
35
37
  "keywords": [
36
38
  "tiger",
@@ -45,10 +47,13 @@
45
47
  "node": ">=16.0.0"
46
48
  },
47
49
  "devDependencies": {
48
- "@types/ws": "^8.5.0",
50
+ "@types/node": "^25.6.0",
49
51
  "fast-check": "^3.15.0",
52
+ "ts-proto": "^2.11.6",
50
53
  "typescript": "^5.3.0",
51
- "vitest": "^1.2.0",
52
- "ws": "^8.16.0"
54
+ "vitest": "^1.2.0"
55
+ },
56
+ "dependencies": {
57
+ "@bufbuild/protobuf": "^2.12.0"
53
58
  }
54
59
  }