@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.
- package/README.md +475 -104
- package/dist/cjs/client/api-request.js +16 -10
- package/dist/cjs/client/api-response.js +23 -3
- package/dist/cjs/client/case-convert.js +35 -0
- package/dist/cjs/client/http-client.js +47 -21
- package/dist/cjs/client/index.js +6 -2
- package/dist/cjs/config/client-config.js +130 -49
- package/dist/cjs/config/domain.js +21 -2
- package/dist/cjs/config/index.js +3 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/model/contract.js +1 -2
- package/dist/cjs/model/enums.js +89 -7
- package/dist/cjs/model/order-helpers.js +9 -9
- package/dist/cjs/model/order-status.js +46 -0
- package/dist/cjs/model/order.js +5 -2
- package/dist/cjs/model/position.js +1 -2
- package/dist/cjs/model/quote-requests.js +11 -0
- package/dist/cjs/model/quote.js +7 -0
- package/dist/cjs/model/trade-requests.js +13 -0
- package/dist/cjs/model/trade.js +2 -0
- package/dist/cjs/push/index.js +6 -3
- package/dist/cjs/push/pb/AssetData.js +208 -0
- package/dist/cjs/push/pb/KlineData.js +184 -0
- package/dist/cjs/push/pb/OptionTopData.js +427 -0
- package/dist/cjs/push/pb/OrderStatusData.js +592 -0
- package/dist/cjs/push/pb/OrderTransactionData.js +256 -0
- package/dist/cjs/push/pb/PositionData.js +316 -0
- package/dist/cjs/push/pb/PushData.js +219 -0
- package/dist/cjs/push/pb/QuoteBBOData.js +160 -0
- package/dist/cjs/push/pb/QuoteBasicData.js +329 -0
- package/dist/cjs/push/pb/QuoteData.js +507 -0
- package/dist/cjs/push/pb/QuoteDepthData.js +220 -0
- package/dist/cjs/push/pb/Request.js +278 -0
- package/dist/cjs/push/pb/Response.js +97 -0
- package/dist/cjs/push/pb/SocketCommon.js +86 -0
- package/dist/cjs/push/pb/StockTopData.js +199 -0
- package/dist/cjs/push/pb/TickData.js +202 -0
- package/dist/cjs/push/pb/TradeTickData.js +308 -0
- package/dist/cjs/push/pb/index.js +49 -0
- package/dist/cjs/push/proto-message.js +135 -0
- package/dist/cjs/push/push-client.js +361 -163
- package/dist/cjs/push/push-message.js +8 -60
- package/dist/cjs/push/varint.js +76 -0
- package/dist/cjs/quote/index.js +3 -2
- package/dist/cjs/quote/quote-client.js +440 -94
- package/dist/cjs/signer/signer.js +10 -10
- package/dist/cjs/trade/trade-client.js +197 -62
- package/dist/esm/client/api-request.js +14 -8
- package/dist/esm/client/api-response.js +22 -3
- package/dist/esm/client/case-convert.js +31 -0
- package/dist/esm/client/http-client.js +48 -22
- package/dist/esm/client/index.js +3 -2
- package/dist/esm/config/client-config.js +131 -51
- package/dist/esm/config/domain.js +20 -2
- package/dist/esm/config/index.js +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/model/contract.js +1 -2
- package/dist/esm/model/enums.js +87 -6
- package/dist/esm/model/order-helpers.js +9 -9
- package/dist/esm/model/order-status.js +43 -0
- package/dist/esm/model/order.js +5 -2
- package/dist/esm/model/position.js +1 -2
- package/dist/esm/model/quote-requests.js +10 -0
- package/dist/esm/model/quote.js +6 -0
- package/dist/esm/model/trade-requests.js +12 -0
- package/dist/esm/model/trade.js +1 -0
- package/dist/esm/push/index.js +4 -2
- package/dist/esm/push/pb/AssetData.js +205 -0
- package/dist/esm/push/pb/KlineData.js +181 -0
- package/dist/esm/push/pb/OptionTopData.js +424 -0
- package/dist/esm/push/pb/OrderStatusData.js +589 -0
- package/dist/esm/push/pb/OrderTransactionData.js +253 -0
- package/dist/esm/push/pb/PositionData.js +313 -0
- package/dist/esm/push/pb/PushData.js +216 -0
- package/dist/esm/push/pb/QuoteBBOData.js +157 -0
- package/dist/esm/push/pb/QuoteBasicData.js +326 -0
- package/dist/esm/push/pb/QuoteData.js +504 -0
- package/dist/esm/push/pb/QuoteDepthData.js +217 -0
- package/dist/esm/push/pb/Request.js +275 -0
- package/dist/esm/push/pb/Response.js +94 -0
- package/dist/esm/push/pb/SocketCommon.js +83 -0
- package/dist/esm/push/pb/StockTopData.js +196 -0
- package/dist/esm/push/pb/TickData.js +199 -0
- package/dist/esm/push/pb/TradeTickData.js +305 -0
- package/dist/esm/push/pb/index.js +25 -0
- package/dist/esm/push/proto-message.js +127 -0
- package/dist/esm/push/push-client.js +329 -164
- package/dist/esm/push/push-message.js +7 -56
- package/dist/esm/push/varint.js +72 -0
- package/dist/esm/quote/index.js +2 -2
- package/dist/esm/quote/quote-client.js +439 -94
- package/dist/esm/signer/signer.js +10 -10
- package/dist/esm/trade/trade-client.js +197 -62
- package/dist/types/client/api-request.d.ts +12 -11
- package/dist/types/client/api-response.d.ts +15 -7
- package/dist/types/client/case-convert.d.ts +16 -0
- package/dist/types/client/http-client.d.ts +26 -14
- package/dist/types/client/index.d.ts +3 -2
- package/dist/types/config/client-config.d.ts +29 -13
- package/dist/types/config/domain.d.ts +9 -0
- package/dist/types/config/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/model/contract.d.ts +13 -29
- package/dist/types/model/enums.d.ts +60 -6
- package/dist/types/model/order-helpers.d.ts +21 -20
- package/dist/types/model/order-status.d.ts +14 -0
- package/dist/types/model/order.d.ts +101 -55
- package/dist/types/model/position.d.ts +26 -24
- package/dist/types/model/quote-requests.d.ts +344 -0
- package/dist/types/model/quote.d.ts +572 -0
- package/dist/types/model/trade-requests.d.ts +195 -0
- package/dist/types/model/trade.d.ts +235 -0
- package/dist/types/push/callbacks.d.ts +32 -51
- package/dist/types/push/index.d.ts +5 -3
- package/dist/types/push/pb/AssetData.d.ts +47 -0
- package/dist/types/push/pb/KlineData.d.ts +43 -0
- package/dist/types/push/pb/OptionTopData.d.ts +76 -0
- package/dist/types/push/pb/OrderStatusData.d.ts +100 -0
- package/dist/types/push/pb/OrderTransactionData.d.ts +51 -0
- package/dist/types/push/pb/PositionData.d.ts +63 -0
- package/dist/types/push/pb/PushData.d.ts +46 -0
- package/dist/types/push/pb/QuoteBBOData.d.ts +35 -0
- package/dist/types/push/pb/QuoteBasicData.d.ts +66 -0
- package/dist/types/push/pb/QuoteData.d.ts +94 -0
- package/dist/types/push/pb/QuoteDepthData.d.ts +37 -0
- package/dist/types/push/pb/Request.d.ts +44 -0
- package/dist/types/push/pb/Response.d.ts +30 -0
- package/dist/types/push/pb/SocketCommon.d.ts +64 -0
- package/dist/types/push/pb/StockTopData.d.ts +37 -0
- package/dist/types/push/pb/TickData.d.ts +44 -0
- package/dist/types/push/pb/TradeTickData.d.ts +53 -0
- package/dist/types/push/pb/index.d.ts +39 -0
- package/dist/types/push/proto-message.d.ts +33 -0
- package/dist/types/push/push-client.d.ts +100 -68
- package/dist/types/push/push-message.d.ts +7 -147
- package/dist/types/push/varint.d.ts +23 -0
- package/dist/types/quote/index.d.ts +2 -2
- package/dist/types/quote/quote-client.d.ts +154 -47
- package/dist/types/signer/signer.d.ts +6 -6
- package/dist/types/trade/trade-client.d.ts +106 -38
- package/package.json +11 -6
|
@@ -1,58 +1,165 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* QuoteClient
|
|
3
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
|
|
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
|
-
*
|
|
29
|
+
* Verify a SHA1WithRSA signature using an RSA public key.
|
|
30
30
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param content -
|
|
33
|
-
* @param
|
|
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(
|
|
36
|
+
export declare function verifyWithRSA(publicKeyBase64: string, content: string, signatureBase64: string): boolean;
|
|
@@ -1,48 +1,116 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TradeClient
|
|
3
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
106
|
+
* Internal position transfer (cross sub-account).
|
|
107
|
+
* @note Uses `fromAccount` / `toAccount` (not `account`).
|
|
16
108
|
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
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.
|
|
4
|
-
"description": "
|
|
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/
|
|
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
|
-
|
|
54
|
+
"vitest": "^1.2.0"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@bufbuild/protobuf": "^2.12.0"
|
|
53
58
|
}
|
|
54
59
|
}
|